Re: Attach invisible data to a TreeRow?




On Fri, 16 Dec 2005 21:50:39 +0100, Matthias Kaeppler <matthias finitestate org> wrote:

Hello,

I was wondering if it's possible to attach additional, invisible data to a TreeRow in a ListStore. I'm not talking about any actual values which are visible to the user, but some form of meta data which can be used to relate the row to certain other data in an efficient way (e.g. through a pointer). I need this kind of funtionality to map filenames in display format to actual filenames on the disk, in order to avoid having two containers of filenames, one holding the actual names, the other the names in displayable format (this would introduce a lot of redundancy).

I thought about deriving from TreeRow and add a new data field, in fact a pointer to the real filename which matches the displayed name in the row, but that doesn't help because ListStore creates the rows for me using append().


Just add a column to your modelcolumns but don't append a column for that to your treeview.
Here are some code fragments where i do this in my project.

    //Tree model columns:
    class PageListModelColumns : public Gtk::TreeModel::ColumnRecord
    {
    public:
        PageListModelColumns()
        { add(m_col_name); add(m_col_page); }

        Gtk::TreeModelColumn<Glib::ustring> m_col_name;
        Gtk::TreeModelColumn<DialogPage*> m_col_page;
    };
    PageListModelColumns m_PageListColumns;


    //Add the TreeView's view columns:
    m_pPagelist->append_column("Name", m_PageListColumns.m_col_name);
    //m_pPagelist is a treeview

--
Marco



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