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

Doriano Blengino doriano.blengino at ...1909...
Tue Jan 26 10:16:24 CET 2010


Kadaitcha Man ha scritto:
> On 26 January 2010 18:58, Doriano Blengino
> <doriano.blengino at ...1909...> wrote:
>
>   
>> What about using two different properties: .Count (all the items) and
>> .Children.Count (only the children of a specific node)?
>>     
>
> I neglected to mention, your idea does not seem to allow for the count
> of root nodes.
>   
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





More information about the User mailing list