[Gtk-sharp-list] Can I group items in TreeView without rebuilding model?

Michael Hutchinson m.j.hutchinson at gmail.com
Sat Nov 5 19:54:21 EST 2005


I have a TreeView that is displaying a lisi, and I'm looking for a way
to group all items with the same value in a certain column by making
them children of a 'category' node, and I can do this using a
TreeStore. I will need to do the same thing to a tree at some point,
but not grouping the children of the top level.

However, I also need to be able to switch between grouped and
ungrouped views.The easy way seems to be to rebuild/rearrange the
model when the 'mode' changes, though I'm unhappy with this as it
breaks the model/view separation and could cause a performance hit. I
see two ways to do this, using either a TreeStore, which as far as I
can see doesn't allow reparenting rows, or a NodeStore - reparenting
rows is possible, but I /think/ the model involves more interop. Which
is likely to be faster? Is there any better way to do what I'm trying
to do?

Another route I've considered is writing a TreeModel that will group
rows in a child TreeModel by a given column, like the filtering and
sorting TreeModels. This would be more generally useful, and keeps the
model separation intact, but are there any problems I'd need to be
aware of when writing a managed TreeModel? Would it be best to sit it
on top of the filtering TreeModel, as presumably this already does
optimised sorting? And would there be any interest in using such a


Michael Hutchinson

More information about the Gtk-sharp-list mailing list