views:

373

answers:

1

How can I restore state of nodes in VirtualStringTree (which ones were expanded) at tree rebuilding?

my application uses VirtualStringTree (one of the best components EVER!). Now, what I need is to rebuild the tree each time the application is started. In most cases however the "new" tree is the same as the one built last time... or at least very similar. What is the best way to restore the state of nodes? Which ones were expanded and so on ... I don't find it convinient to expand all the nodes manually each time I start the app... and so my users, I believe. Unfortunately, due to privacy restrictions I can't save the actual tree to a file and then load it, and compare the existing nodes when rebuilding (adding/removing when neccessary) ... I need some other way, please...

+2  A: 

Store only topology of the tree, e.g. indexes of expanded nodes for each level.

Alternatively, you may form a list of hashes for some invariant nodes value and store hashes only for expanded nodes in that list. That way you will preserve state even if topology is changed, but at the cost of lowered privacy.

actual
Storing hashes of expanded nodes doesn't lower privacy at all, unless the thing you're trying to keep private is the fact that certain nodes were expanded. To get the hash of a node, you must already have the data used to compute the hash, and if you already have that, then what's left to hide?
Rob Kennedy
Rob, I think he refers to the situation where you want to "refresh" data while keeping the topology as best as you can. You'll want to reopen the opened nodes even if a new node is inserted in between. Thus you need the "id" of the open nodes.
François