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



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





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