[Feature request] Add on-load-state attribute to nodes, so the specific nodes will be always expanded/closed on load/import
Is your feature request related to a problem? Please describe. Some nodes in my tree should be expanded each time I open the cherrytree file due to their logic and importance (e. g. Important notes, Current tasks, a current month in the monthly archive tree, ...). Saving and restoring the last state of the tree helps partially, but not completely. It is not saved as a part of the logic of the document and would be lost, for example, when the file is copied to a different machine or even imported to a different cherrytree document.
Also there are nodes that should be always collapsed on load, regardless of their previous state - for example when I am searching for something in the archive tree, a lot of nodes gets expanded and it is exhausting to be closing all of them to get the clearly collapsed archive tree for the next time I open the archive document. (And I can't just disable saving of the state of the tree, because I'm using the same cherry tree instance of another cherrytree documents, where the tree state should be preserved. Also, the archive could be in the same cherrytree document as active/important notes and still should behave differently.)
For these reasons I'd like to be able to set a fixed on-load/on-import state (expanded/collapsed) to specific nodes or group of nodes (subnodes of a specific node or all its descendants).
Describe the solution you'd like I suggest to add a metadata attribute "StateOnLoad" to each node with a default state "Default" and other possible states "Expanded" and "Collapsed". There must be an easy way to change this attribute to each of its three values for:
- A single node (preferably in the node properties window).
- All children of the selected node (probably using the context menu).
- All descendants of the selected node (probably also using the context menu).
(However, newly created nodes would always have a "Default" StateOnLoad, they won't inherit the state from a parent node.)
Then each time the document is openned or imported to another cherrytree document, each node with non-default "StateOnLoad" would be collapsed or expanded according to the value of its attribute, ignoring the previous state of the tree. However, nodes with "Default" StateOnLoad would behave the same way as nodes behave now.
Would part of your request be satisfied by adding the nodes as bookmarks and using setting the Preference "Nodes in bookmarks always visible" under "Tree Explorer"?
Would part of your request be satisfied by adding the nodes as bookmarks and using setting the Preference "Nodes in bookmarks always visible" under "Tree Explorer"?
Yes, that helps. Thank you!
It is a bit impractical, because it is not enough to set "Important Notes" node as a bookmark, I must set any of its subnodes as a bookmark to force it to be expanded, but it certainly helps to achieve the goal.
I wonder if it would be a good idea when the option "Nodes in bookmarks always visible" is set to also expand all the child nodes. That would probably satisfy your request and is very easy to implement.