Re: How to delete a multiple selection from a ListStore?



According to the docs, a path stored in the RowReference continually points to the same row it did when it was created (so long as that row continues to exist) even when the TreeModel is modified (by adding or deleting rows); hence, you derive an iter from the Gtk::TreeModel::Path provided by the RowReference and then use erase to rid yourself of the row in question. I am assuming that you know how to get an iter from a Gtk::TreeModel::Path.

Bob Caryl

Joost Ellerbroek wrote:
I don't get how your RowReferences method would work, you need a
TreeIter for the erase method, don't you?
My second method does work though; is it terribly inefficient, or do
you think I'll survive? :)

Joost

On 8/8/06, Murray Cumming <murrayc murrayc com> wrote:

> Convert your original list of selected rows into a list of
> Gtk::TreeModel::RowReferences. Using this list you can use the paths it
> contains when you loop through the list calling the model's erase
> method.  The path each Gtk::TreeModel::RowReference contains remains
> valid so long as the row to which it points exists regardless of the
> fact that you are changing the model by deleting rows.

I've never quite understood the need for this class. A path is already
only a potential path. When you convert it to an iter then the iter will
be invalid if the path isn't valid at that time. (In the example code,
he's not checking the result of get_iter(), I see.)

And if we were just storing paths then the paths wouldn't indicate the
same rows if we have deleted the rows before the intended row.

Maybe RowReference always provides a valid (at the time, sometimes
different than originally) path.


Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com






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