[Gambas-user] How to handle TreeViewItems and CLASS association

Christopher Brian Jack brian at ...1334...
Tue Oct 17 20:23:53 CEST 2006


> > Also this object has no simple iterator (one that can be used without
> > knowledge of the elements--namely that they have parents and children as
> > is the case in a TreeView).  A simple iterator can be used when it is not
> > required that the traversal follow any order, only that each element be
> > iterated (visited) once.  I know as I already tried FOR EACH with no luck.

> I think too that a FOR EACH on ListView, TreeView, etc. would be useful, but I
> never had the time to do it. It is not as simple as it appears, because
> iterators should care with deleted items.

Simple, in this case, really is only referring to the characteristic of
the iterator only providing the guanratee of accessing all available items
in the collection, NOT the implementation complexity of implementing such
an iterator.  For instance a simple iterator on a hash table may not
even iterate back the items in order of insertion (depends on the hash
function) but it does guarantee iterating all available elements.

I'd suggest having the iterators use virtual classes that implement
read-only elements (similar to the index [] operator) but the issue of not
being able to DIM a virtual class or even sticking it to a variable
storing a Variant (for the iterator cursor variable) is a potential issue.

> You can save and recover the Item property (the internal cursor) by doing:
>
> DIM sSave AS String
>
> sSave = MyTreeView.Item.Key
> ...
> MyTreeView.MoveTo(sSave)

Thanks for the solution.  It never even occurred to me that I could use
the element keys that way.

Now one more question - can the items in a TreeView be associated with an
instance of a storage class?  How about one that can "compound"?

Say the TreeView looks like this:

root
|-n1
|`_n1c1
`-n2

and classes:

classRoot
classN1
classN2
classC1

root should inherit classRoot
n1 should inherit a compound: classRoot+classN1
n1c1 should inherit a compound: classRoot+classN1+classC1
n2 should inherit a compound: classRoot+classN2

(where I have +'s the classes compound up to the root and when compounded
the precedence moves towards the leaf thus allowing overrides of
properties and such).

Now the hitch is that this tree is going to manipulated at runtime so
basically I need a runtime way of handling what is done by "INHERITS" in
class files at compile time.

Should I just let the contents of such classes be kept as database tables?
The only catch here is that a deeply nested class may need to involve
numerous database accesses and that deleteing items and making sure all
associated tables have the entry for that key (the element in the TreeView
being deleted) removed (and the bookkeeping of adding that key to the
relevant tables when inserted) oh and then there's inheritence and
overloading of properties...  OUCH!

I think I really need a middle-ware road here that doesn't have me
reimplementing the entire class system from scratch!  That would just be
ouch, ouch, ouch, ouch, OWWWWWWWWWWWWCH!

.=================================================.
|  Christopher BRIAN Jack aka "Gau of the Veldt"  |
+================================================='
| oevna at ...1544...
`=================================================-
Hi Spambots, my email address is sputnik at ...1334...
Hi Humans, my email address uses rot13 cipher





More information about the User mailing list