Associating data with list store



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);
   }
};

As you can see, I've been playing. The two commented out variants of "dataitem" don't even compile. The integer "objindex" (as shown in the tutorial) appears fine, but doesn't really do what I need. If I include "dataitem" (by undefining the magic symbol) then the code builds OK and mostly seems to work except that I get HUGE NUMBERS of GTK warnings and criticals when I run it.

(ovscal:16841): GLib-GObject-WARNING **: gvalue.c:96: cannot initialize GValue with type `(null)', this type has no GTypeValueTable implementation

(ovscal:16841): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed

(ovscal:16841): GLib-GObject-WARNING **: gtype.c:3339: type id `0' is invalid

(ovscal:16841): GLib-GObject-WARNING **: can't peek value table for type `<invalid>' which is not currently referenced

So what am I doing wrong? How am I supposed to associate an arbitrary data item with a ListStore row?

Thanks,
Rob



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