Re: [gtkmm] i can delete toolbar ButtonElements...
- From: cedric <cedric probesys com>
- To: Matthew Walton <matthew alledora co uk>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] i can delete toolbar ButtonElements...
- Date: Mon, 03 May 2004 10:44:41 +0200
Matthew Walton a écrit :
cedric wrote:
ps: Matthew Walton, once (1 or 2 weeks ago ;-D ) you told me than
there were a better way to delete several lines of a ListStore than
the way i tried to use. i ve no other idea, so could you tell me how
to do it in a "clean" way? my purpose is not to recopy some code, but
to learn! ;-) thanks too!
Sorry, I forgot... lots of other things going on at the moment (as
usual!)
you re forgiven! ;-)
I'm not sure that I'd actually describe it as cleaner, but what I'm
doing in my media player app to delete the selected items is:
- get a vector of the selected items from the TreeView::Selection
object (it will be a vector of TreeModel::Path objects)
- iterate through it backwards
- for each one, turn the path into an iterator and erase it
I'd point you at the code, but it's got a lot of signal triggering
code and other such things around it, so here's a simplified version,
assuming your TreeModel is accessed through a Glib::RefPtr called model:
std::vector<Gtk::TreeModel::Path> items =
model->get_selection()->get_selected_items();
for(std::vector<Gtk::TreeModel::Path>::reverse_iterator riter =
items.rbegin(); riter != items.rend(); riter++) {
Gtk::TreeModel::iterator iter = model->get_iter(*riter);
model->erase(iter);
}
So that may not be the best way, but it works for me :-) If you don't
want to iterate backwards for whatever reason, your way is probably a
lot better.
it s no matter it s done backward or forward, the important thing is
that it works, and it works!!! i ve just had to make some minor
modifications, but nothing difficult! i ve almost get to the goal alone,
but you brought me the missing step: thanks a lot!!!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]