TreeModel objectNodeMap

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

TreeModel objectNodeMap

Esteban A. Maringolo-3
Hello:

        Looking at the implementation of the TreeModel class in Dolphin XP,
I found that it uses a object to node map, which is a LookupTable.

What I'm wondering is if it support more than one occurrence of the
same object in more than one branch of the tree.

Best regards.

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: TreeModel objectNodeMap

Chris Uppal-3
Esteban,

> Looking at the implementation of the TreeModel class in Dolphin XP,
> I found that it uses a object to node map, which is a LookupTable.
>
> What I'm wondering is if it support more than one occurrence of the
> same object in more than one branch of the tree.

I don't believe so.

I think that tree Views are entitled to assume that items only occur once,
and -- in any case -- the <treeModel> protocol requires #parentOf: rather than
#parentsOf: so there's no way for the model to "tell" the view about multiple
parents, even if it can support them itself.

FWIW, I generally use a layer of simple proxies if I want to allow items to
occur more than once.  So one item may occur "logically" more than one time,
but the physical implementation is that there are several distinct proxy
objects in the tree that all stand for the same "real" object.  It sounds a bit
of a pain, but it really only takes a few minutes to set up the code.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: TreeModel objectNodeMap

James Foster-3
I've found that using the "VirtualTreeModel" does (in a sense) allow the
same object to occur more than once, but there is occasionally unexpected
behavior (e.g., programatically selecting an object selects the specified
object but under which parent?). After some struggling, I broke down and
wrapped all the objects before adding them to the tree. As Chris suggested,
I thought it would be more work than it actually was.

James Foster

"Chris Uppal" <[hidden email]> wrote in message
news:42d4cc2d$0$38038$[hidden email]...

> Esteban,
>
>> Looking at the implementation of the TreeModel class in Dolphin XP,
>> I found that it uses a object to node map, which is a LookupTable.
>>
>> What I'm wondering is if it support more than one occurrence of the
>> same object in more than one branch of the tree.
>
> I don't believe so.
>
> I think that tree Views are entitled to assume that items only occur once,
> and -- in any case -- the <treeModel> protocol requires #parentOf: rather
> than
> #parentsOf: so there's no way for the model to "tell" the view about
> multiple
> parents, even if it can support them itself.
>
> FWIW, I generally use a layer of simple proxies if I want to allow items
> to
> occur more than once.  So one item may occur "logically" more than one
> time,
> but the physical implementation is that there are several distinct proxy
> objects in the tree that all stand for the same "real" object.  It sounds
> a bit
> of a pain, but it really only takes a few minutes to set up the code.
>
>    -- chris
>
>
>
>