Re: TreeView



[snip]
> P.S> Obligatory Dirty Wish List Dept:
> I frequently want to iterate over every item in a TreeModel in a single
> loop, and the (seemingly) reasonable way to do this would be e.g.
> Gtk::TreeModel MyModel;
> for(TreeIter iter = MyModel.begin(); iter!=MyModel.end(); iter++){
>    (do something constructive with iter)
> }
>
> But I haven't been able to figure out how to do this directly: one can
> iterate over e.g. for(TreeIter iter=MyModel.children().begin();
> iter!=MyModel.children().end(); iter++){
>   (do something constructive with iter)
> }
>
> but that only gets the top level of the hierarchy. One can of course
> recurse on the children's children. One can also do f'rinstance
> something like
>
> //***********************************************************************************
> class MyClass{
> public:
>    vector<TreeIter> m_iter_vec;
>
>    bool store_iter(const TreeIter & iter){
>        m_iter_vec.push_back(iter);
>        return false;
>    };
>   Gtk::TreeModel MyModel;
> };
>
> MyModel.foreach_iter(sigc::mem_fun(*this,&MyClass::store_iter));
>
> for(vector<TreeIter>const_iterator iter=m_iter_vec.begin();
> iter!=m_iter_vec.end(); iter++){
>     (do something constructive with *iter)
> }

I've never used it, but TreeModel::foreach*() should do it:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeModel.html#11fbc9b39c01210e525e7b6cdf91f66f

Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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