I am using PySide to write a plugin browser. Available plugins are stored in a three-dimensional model like this:
pluginType / pluginCategory / pluginName example:
Python / Category A / Toulouse dragon / category b / tools etc.
In my custom view, I am showing all the tools of a given plug-in type (i.e. "python"), regardless of their category:
< Code> (python) Category A / Toulay Category A / Toolb Category A / Tool C Category B / Tool Category B / ToolBeebie Category B / Toolcase Now I am thinking that this view How best to sort, the device was sorted by name regardless of their original class Is. Sorting method in my current proxy model generates a sorted list according to the category above, but what I am doing next:
(Python) Category A / Toulouse Category B / Tool Do I need to convert my proxy model multi-dimensional source model into a one-dimensional form so that it is achieved? Category A / Toolb Category B / EquipmentB Category A / Toulissee Category B / Can go or bay Way to go? I would love to be able to sync a custom view with a custom tree view, which is why I chose the multi-dimensional model Thank you, Frank
Edit 1: What I have here is a simple example. I'm not sure that this is the way to go about it (model structure is 1-dimensional Model), and if it is, then I'm not sure how to properly create data in the proxy model so that it is properly linked to the source model.
Import System * Class Tulmodel (QStandardItemModel) from PySide.QtCore import * from PySide.QtGui import: 'multidimensional model' 'def __init __ (self, parent = None): Super (toolmodel, self) .__ init __ (original) self Settul () def set tools (self): for Contro, to enumerate the container ([ 'plugins', 'python', 'misc']): contItem = QStandardItem (container) self.setItem (contRow, 0, contItem) For catRow, the calculation of category (['CATA', 'catB', 'CATC']): catItem = QStandardItem (category) contItem.setChild (for catRow, catItem) toolRow (['toola', 'toolB', 'toolC']) tools: toolItem = QStandardItem (equipment) catItem.setChild (toolRow, toolItem) class ToolProxyModel (QSortFilterProxyModel): '' 'proxy model sorting and sorting by toolName regardless of category filtering Need to be able to , So I may have to convert the source data Moodel 1-dimensional model?! Certainly how properly I '' '__init def __ (self, parent = None): Super (ToolProxyModel, self) .__ init __ (parent) def SetSourceModel (self, model): ContRow index xrange = 0 (model.rowCount ()): containerItem = model .item (contRow, 0) catRow (containerItem.rowCount (in xrange)) to: categoryItem = containerItem.child (catRow) itemRow (categoryItem.rowCount (in xrange for) ): ToolItem = categoryItem.child (itemRow) # How to create new, 1-dimensional data for yourself? App = QApplication (sys.argv) MainWindow = QWidget () TreeView mainWindow.setLayout (QHBoxLayout ()) model = ToolModel () proxyModel = ToolProxyModel () proxyModel.setSourceModel (model) TreeView = QTreeView () treeView.setModel (model). ExpandAll () listView = QListView () listView.setModel (proxyModel) mainWindow.layout (). AddWidget (TreeView) mainWindow.layout (). AddWidget (listView) mainWindow.show () sys.exit (app.exec_ ()) Edit Or maybe I should ask that to create an ideal model that this curie view Can be used by, but can be sorted in the above mentioned way to appear in the list view?
Sort a quoteable Weave with the Tool_name column (using a sort proxy).
Comments
Post a Comment