[Gambas-user] TreeView.Count value differs using qt rather than gtk

Benoît Minisini gambas at ...1...
Tue Jan 26 21:06:32 CET 2010


> Doriano Blengino ha scritto:
> > Actually I expressed myself badly. Example:
> >
> > Tree1:
> >   - item0
> >   - item1
> >     - item1.0
> >
> > Tree1.count is  3      (global count)
> > Tree1.Children.count is 2 (tree1 has two children)
> > Tree1.Children[0] is item0
> > Tree1.Children[0].count is 0
> > Tree1.Children[1] is item1
> > Tree1.Children[1].count is 1
> > Tree1.Children[1].Children[0] is item1.0
> >
> > AChild = Tree1.Children[1]
> > for subchild in Achild
> >   ...   ' just the single child of item1: item1.0
> > next
> >
> > ask("Sure to copy " & tree1.count & " file/directories?)   ' we will
> > copy 3 items
> > for child in Tree1.children
> >    processchild(subchild)   ' this line will execute two times
> > next
> >
> > sub processchild(child as TreeChild)
> >   dim subchild as TreeChild
> >
> >   ' do something with it
> >   alert("Copying " & child.text & "...)
> >   ' are there subchildren? Do them recursively
> >   for subchild in child.children
> >     processchild(subchild)
> >   next
> > end
> 
> The Doriano's way could be a good choice IMHO.
> However, I think that the differences between the two components should
> be resolved: how it will be implemented it's not so relevant for me
> (currently both implementations works correctly), the important is to
> have a unique behavior.
> Thanks everybody, especially to the gambas developers who are doing a
> great job.
> --
> Matteo
> 

Wow. Too many mails. The Kadaitcha syndrome apparently :-)

You guys forget that tree nodes do not really exist in Gambas. There are no 
objects associated with them. 

You have just an internal pointer pointing at a node (not necessarily the 
selected one). You get it with the Item property, and you change it with the 
Move*() methods.

The Item property returns a "virtual" Gambas object, i.e. an object that you 
cannot use outside of the line you read the Item property (actually you can 
use it with the WITH keyword, but it is an exception).

So Item.Children will return the number of children items of a specific node. 
So how can I get the number of root items? The Count property. But of course 
then things are ambiguous, and gb.gtk got a different behaviour than gb.qt!

So maybe Count should return the number of nodes (the gb.gtk way), it is more 
coherent with the Count properties in other classes. And should I create 
another property that returns the number of root items. I think this is the 
best solution. Now I must find a good name for that property...

-- 
Benoît Minisini




More information about the User mailing list