Re: Obtaining a TreeModel::Row from a TreePath



Chris Vine wrote:
On Saturday 09 April 2005 16:11, Matthias Kaeppler wrote:

Hello,

I want to build list of data objects associated with a row in a tree
view, based on the current selection.
I know I can get the selected rows by calling
TreeSelection::get_selected_rows(), but despite its name, this method
returns a list of TreePathS, and not a list of TreeModel::Rows.

So how can I obtain the rows from the path objects?


To convert a path to an iterator, use Gtk::TreeModel::get_iter(const Gtk::Treemodel::Path&), and then derefence the iterator (a row is just a dereferenced iterator).

However, you probably want to convert all the paths to rows with a suitable functor using Gtk::TreeSelection::selected_for_each_path(). (As an example you can see: http://cvs.sourceforge.net/viewcvs.py/efax-gtk/efax-gtk/src/selected_rows_handle.h?rev=1.4
and
http://cvs.sourceforge.net/viewcvs.py/efax-gtk/efax-gtk/src/selected_rows_handle.cpp?rev=1.3

Chris

Chris

Thanks Chris, that's what I need.

--
Matthias Kaeppler




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