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



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. 

Hope this helps.

Bob Caryl

Joost Ellerbroek wrote:
Ok, I've found something that atleast works, although I'm not sure if
it's the best way of doing it:


--------------
for (Gtk::TreeModel::iterator iter = pd_expModel->children().begin();iter;)
				if (treesel->is_selected(iter))
					iter = pd_expModel->erase(iter);
				else
					++iter;
-------------
I'd be interested to know if there's a better way of doing this.

cheers,

Joost

On 8/8/06, Joost Ellerbroek <j ellerbroek gmail com> wrote:
  
I want to be able to delete / cut / copy and paste multiple-selections in a
TreeView.

What I do now obviously doesn't work correctly, presumably because the
iterators pointing to the rows change as soon as I change the model?
This is what I do now:
----------------code snippet:
std::vector<Gtk::TreeModel::Path> pathlist =
pView->get_selection()->get_selected_rows();
for (std::vector<Gtk::TreeModel::Path>::iterator i = pathlist.begin(); i !=
pathlist.end(); ++i)
                pd_expModel->erase(pd_expModel->get_iter (*i));
----------------

What would be the correct way to delete a multiple selection from the model?

cheers, Joost


    
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

  


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