Re: [gtkmm] TreeView Design



On Thu, 2002-07-18 at 09:55, Daniel Evison wrote:
> Well, the book chapter doesn't have that extra level of complication, but it
> doesn't address how to make a TreeView connect with underlying (non-gui)
> models in an application.

A model is meant to be non-gui. Maybe you mean non-gtkmm.

>  (Unless I'm missing something).
> Unless the primary store of data in an application is a ListStore 

or a TreeStore.

> I believe
> you would still have to duplicate the data.

Most of the time I think it's OK to use the ListStore or TreeStore. The
standard models don't seem to have much support for stuff like backend
database connections. ETable does that apparently.

>  And so if a field is edited
> then the callback would have to update both the ListStore and the underlying
> model.   Normally I think an application should be written with data-types
> that don't know anything much about the gui widgets that will be used to
> display them, since it may have multiple different kinds of interfaces
> layered on it.

It's an interesting question, but one that would be answered more
completely on gtk-list or gtk-devel-list.

> How would you recommend setting up an editable view on data such as:
> 
> class Employee
> {
> public:
>   accessors/mutators etc
> 
> private:
>    int m_age;
>   std::string m_name;
>   etc;
> };
> 
> std::vector<Employee> employees;
> 
> Would you extract out all the fields from the Employees and copy them into a
> ListStore, or is that not necessary?

Firstly, I'd avoid that and just use ListStore or TreeStore.

If I really had to, then I'd do one of these:
1. Keep them in sync, like you say.
2. Derive a new TreeModel. Very difficult. No examples exists.
3. Investigate TreeView::insert_column_with_data_func() to 
   see what it is and whether it's useful.

I believe that 2. would be preferred by the GTK+ people, but I'm not
aware of any examples.

-- 
Murray Cumming
murrayc usa net
www.murrayc.com




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