Re: Associating data with list store



On Sat, 2007-06-02 at 12:26 +0100, Robert Pearce wrote:
> Guys,
> 
> I'm sure somebody here recently posted advice about tagging TreeModel entries with arbitrary data using a hidden column.
> 
> I have an application where a ListStore is shown in a TreeView and each row needs to be associated with an instance of a data class. At the moment it's a horrid kludge because there is a std::vector of the data instances that needs to be kept in the same order as the ListStore. So I tried to take the advice I thought I'd read here.
> 
> class DLF_ModelColumns : public Gtk::TreeModel::ColumnRecord
> {
>  public:
>    Gtk::TreeModelColumn<Glib::ustring>              varname;
>    Gtk::TreeModelColumn<Glib::ustring>              value;
>    Gtk::TreeModelColumn<Glib::ustring>              units;
>    Gtk::TreeModelColumn<Glib::ustring>              description;
> #ifndef SEPARATE_LIST_OF_ITEMS
> //   Gtk::TreeModelColumn< Glib::RefPtr<DLF_ScreenItem> >     dataitem;
>    Gtk::TreeModelColumn<DLF_ScreenItem*>            dataitem;
> //   Gtk::TreeModelColumn< Glib::Value<DLF_ScreenItem*> >            dataitem;
> #endif
>    Gtk::TreeModelColumn<int>            objindex;
> 
>    DLF_ModelColumns() { 
>        add(varname); add(value); add(units); add(description);
> #ifndef SEPARATE_LIST_OF_ITEMS
>        add(dataitem);
> #endif
>        add(objindex);
>    }
> };

have you tried the obvious:


    Gtk::TreeModelColumn<DLF_ScreenItem*> dataitem;

?





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