Re: AbstractTreeModel, AbstractListModel



Joel Becker <jlbec evilplan org> writes:

> On Mon, Jul 16, 2001 at 04:59:08PM -0400, Jonathan Blandford wrote:
> > It's not a trivial amount of work, but it's not impossible to implement
> > a GtkTreeModel interface in a fairly small amount of code (especially if
> > you have a good data store like you already do.)  GtkTreeStore is
> > particularly long as it supports things like sorting and Drag and Drop
> > reordering, both of which are somewhat dubious for an xml view.  There
> > is a stupid evil wrapper class in testtreecolumns to represent columns
> > as rows[*], that was written in ~350 lines of code.
> 
> 	Ok, I had more of a look since I mailed.  It seems that the
> drag/drop interface code could be mostly reused verbatim.  Am I right on
> this?  The only thing is on a drop move, treestore does recursive_copy()
> to move the child nodes.  In an XML store, that isn't required, as the
> children will travel with.  I do want reordering, as I'm not 'viewing
> XML', rather I'm viewing and editing a path that is represented in XML.
> 	I don't need (and don't want) the sortable interface.  So, if I
> copied the code verbatim, then removed the sortable code and updated all
> the tree_model_init functions to handle my XML tree, it should work?

The copy is solely so you can copy nodes, not for moves.  There is a
chance that the DND interface will change a little, too.  Much of the
rest of the code is prolly very straightforward.

> 	Basically, I'm trying to judge the trade off between the time
> required for hacking this and the space waste and conceptual ugliness of
> using gtktreestore and mirroring the XML.

I'd avoid mirroring the XML stuff to the tree store if possible. 

Feel free to write if you have more questions.

Thanks,
-Jonathan




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