I am trying to create a model/view system for plugins. Each plugin has different attributes, which should be displayed in a QTreeView.
I am confused, however, if the view's number of rows does not match the number of items in the model.
For instance, I want to display the plugins like this:
(root)
+-Transform Nodes 2 nodes
| +-Move
| | +-Inputs
| | | input1 image
| | +-Attributes 2 attributes
| | Xpos float
| | Ypos float
| +-Rotate
| +-Inputs
| | input1 image
| +-Attributes 1 attribute
| angle float
+-Color Nodes 2 nodes
+-Brightness
| +-Inputs
| | input1 image
| +-Attributes 1 attribute
| amount float
+-etc... etc...
(root)
+-Transform Nodes 2 nodes
| +-Move
| | +-Inputs
| | | input1 image
| | +-Attributes 2 attributes
| | Xpos float
| | Ypos float
| +-Rotate
| +-Inputs
| | input1 image
| +-Attributes 1 attribute
| angle float
+-Color Nodes 2 nodes
+-Brightness
| +-Inputs
| | input1 image
| +-Attributes 1 attribute
| amount float
+-etc... etc...
To copy to clipboard, switch view to plain text mode
which leads me to believe that I have 2 groups, and 2 children in each group (potentially many of each, but for this example...), and certain rows have two columns, but others only have one. The inputs and attributes are not child items, they only exist in the view and are really members of pluginItem.
The problem is, while the model has 2 groups of 2 items, the view has 19 (and more) rows. Also, another problem is that the row number of a particular item is determined by which parents are expanded/collapsed (but this may already be contained in the QTreeView code).
Does it make more sense to:
1) create a pluginGroup class which contains pluginItem children that reports many rows when displayed, or
2) create a pluginGroup class which contains pluginItem children that contains pluginDisplayGroup children that contains pluginDisplayAttribute children, or
3) create a generic pluginRow item which may be either a child or parent and has a flag in it to determine usage, or
4) create a pluginItem array in the model, which stores the group name, where the view somehow splits the rows based on unique group names, or
5) some other framework that I'm not thinking of.
Another, more minor thing, is that if I want the view to expand/collapse based on a single click... where do I insert this trigger? Do I need a delegate?
I would like to use 4 or 1 above, but I am confused about where the additonal rows are generated... 4 makes the most sense, because that's what the model really should be.
Bookmarks