Re: TreeView, How do you know which row is expanded or not?



<snip>

Currrently I just clear everything in the TreeModel in the View then add everything again base on the data of the Doc, but this does not preserive which rows were expanded and the user must then
rexpend them.

How should I keep the rows expanded, while adding/removeing/moving items?
How can I tell which rows are expanded and not?

<snip>

If you plan on continuing to clear and repopulate your TreeModel whenever your Doc changes, then prior to clearing the TreeModel in preparation for repopulating, you should make a call to TreeModel::get_selected, storing the results in a std::vector<Gtk::TreeModel::Path>. Then iterate the resulting paths to record the pertinent data in the rows pointed to by those paths, storing it in yet another std::vector<your data type>. Then, after re-population of the TreeModel, iterate all its rows looking for matches to the each data item stored in your std::vector and then select and expand matching rows as appropriate.

Of course, you could take new data generated in/by your Doc and use the TreeStore::append, TreeStore::insert, and TreeStore::erase to modify the TreeModel without the necessity for complete repopulation every time the Doc changes. This would also preserve current user selections as well.

Bob Caryl



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]