Re: custom treemodel?



On 5/19/06, Murray Cumming <murrayc murrayc com> wrote:
On Fri, 2006-05-19 at 12:05 -0400, Paul Davis wrote:
> libardour is the backend to multiple UIs (not all of them graphical). it
> is not allowed to have a dependency on the code used by any particular
> UI implementation. i.e. its not OK for the curses implementation to have
> to link against GTK, or vice versa.

So I suggest you put a smartpointer or pointer to the data items in a
ListStore or TreeStore and just use
- cell_data_func() to show appropriate parts of the data item in
appropriate columns
- CellRenderer signals to handle user edits of the cells.

I do that in glom, for instance here:
http://cvs.gnome.org/viewcvs/glom/glom/mode_data/dialog_layout_list.h?view=markup

In this case, you'd have no advantage by using a custom model with an
underlying std::list, compared to a regular ListStore or TreeStore.
Well, I suppose you might get some cleverness by reusing your container.

So if I understand correctly, you have a ListModel and an underlying
data container.The ListModel has the same number of elements as your
underlying data store, but contains shared_ptrs to the elements of
your data store instead of copying the actual data into the liststore?

If I summarized that correctly, it's an improvement over copying the
values into a liststore, but it still doesn't completely solve the
problem of synchronizing the data.  Since the ListStore items point to
the actual underlying data, changing a value in the liststore would
also change the underlying data.  On the other hand, if you added or
removed an item in the underlying data store, you'd have to also
explicitly add or remove a shared pointer in the ListModel.  Right?
What I would like is to have one canonical data store that can be
manipulated either through the standard container interface or the
TreeModel interface and not have to worry about synchronization
between the two.  Is that a pipe dream?

Jonner



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