I am writing gui application. I want to implement following structure:
project tree with nodes of different type and behavior (i.e. when right clicking or selecting there can be different menu options)
Editor window, which can be dynamically splitted vertically and horisontally, to add more edit areas. Each edit area corresponds to one node of project tree.
I am using c++/qt, but have the problem in design rather than programming languages and libraries.
Currently, to implement project tree I created abstract interface of tree node which contains link to parent and to children. For each node of specific type I make new class. Because I am using Qt, I have a model, which acts like a intermediate object between view and actual tree. It seems correct that information from visual representaion can't leak to this tree.
I have the following problems with implementation:
Is it right to use this tree as a holder of all my data? Can I use it to hold information about objects I'm editing, or should I use external holder for all data, but have link to it from my nodes?
- In case of holding information about objects, the information about visual representation, already passed to objects (they know structure of the tree).
- In case of link to external holder, I can't understand how to create such link and support dynamic creation/deletion of nodes.
When I click on view item, I want somehow to make data inside node to be opened for editing in selected edit area.
- I can't figure out how to do it without dynamic_cast'ing to specific type of node and passing that internal information to currently selected edit area.
- Another badly looking approach, which come to my mind is to introduce virtual function in node, but node can't implement the logic of this function, because it relates to visual representation.
Example of tree:
Models is entities which can be edited by own vector graphics editor, Materials is table-like key-value properties, where each key can be attached to some primitives in graphics editor.