[Qt-interest] FW: QAbstractItemModel: Hiding rows
Arnold Krille
arnold at arnoldarts.de
Fri Jul 10 10:32:10 CEST 2009
Hi,
On Thursday 09 July 2009 22:46:51 Eric Clark wrote:
> This is not "simply" a removal of rows. My model is setup to get its
> information from a hierarchial tree structure already defined by a
> different object in my application. The other object always has these items
> in its list of children, no matter if they are hidden or not. The "hidden"
> part is only a GUI preference because some of the objects are not to be
> shown in the TreeView, but they are still there. Removing the rows would
> cause very bad bugs, since the rowCount always returns the number of
> children and the ability to get a child by row number would be screwed up
> because I would have to index things based on their visibility, not their
> existence in the children array. Not exposing it via the model is not an
> option as that would make my life very difficult. I would have to reorder
> indexes all the time, and have to have lots of extra code.
So actually your model is already a proxy to the real data:-) And all you want
to know is what method of hiding some data from the proxies is least costly.
As I said, either 1) hide it directly in your model (yes, that involves index-
reordering) or 2) do it via a proxymodel (yes, that involves index-
reordering)...
The model-view concept is actualy working like this: The views show everything
exported by the model. And its the models responsibility to hide what is not
to be shown.
If you try to introduce a new role, you also have to implement your own
views/delegates to be used with your model. And that is counter-productive.
The advantage of the model-view-pattern is that (almost) all views can display
the data given in the model. Some my not look interesting (imagine a chart-
view coupled to a QDirModel:), but all work without modifications or big
specializations.
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090710/2e21534a/attachment.bin
More information about the Qt-interest-old
mailing list