Re: [gtkmm] treeview iterator



On Friday 14 May 2004 09:41, Erwan Ancel wrote:
> Hi,
> I would like to know how to get an iterator to the row before the selected
> one. I know that I can parse the whole list, but this is not efficient at
> all.
> This corresponds to a -- operator for the iterator (I can easily get the
> next one with the ++ operator)
> Does anyone know a way to get an iterator to the previous row efficiently ?

I think gtkmm-2.4 provides operator--(), but if you are using an earlier 
version (or want your users to be able to use an earlier version), or if you 
want efficiency when repeatedly iterating backwards, then you need to get at 
the path object, viz:

Gtk::TreeModel::Path tree_path(selected_row_iter);
tree_path.prev(); // tree_path now refers to the list store
                  // preceding the selected one
Gtk::TreeModel::iterator prev_row_iter = [treemodel_ref]->get_iter(tree_path);
                                                                                                   
Chris



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