Summary, from comments:
- Use QDataWidgetMapper for data mapping. You may create 3 mapping. For each frame.
- Use QStackedWidget for editor frames
- On each selection change - set mapping and show necessary widget.
Question
I'm doing a character animation editor.
My character is represented in a QTreeView like this
And etc.
There is a basic abstract Item
class that Character
, Animation
and Frame
inherits from.
The restrictions are:
Character
items can have any number of ONLY Animation
itemsAnimations
items can have any number of ONLY Frame
itemsFrame
items can not have any childrenNow, everything that inherits from Item
have a name. Then every type of item adds its own attributes (Animation
can have Wrap mode, FPS; Frame
can have duration).
So each level of the tree has different data set.
Now I want to add another widget that allows editing the data of each Item
. The widget will be broken into 3 parts (sections): Data related to character, data related to animation and data related to frame.
When the user selects an item in the tree, the widget will autofill itself according to the following rules:
Character
=> Fill only character sectionAnimation
=> Fill the animation section + do step 1
with the character that is the parent of this animationFrame
=> Fill the frame section + do step 2
with the animation that is the parent of this frameI can distinguish between selected items (I can tell if it either Character, Animation of Frame). I can access the parent item from the selected child.
My problem is that I don't know how to map the data between my tree's model and the editing widgets. I looked into QDataWidgetMapper but it does not help, it looks like it works on models that have the same item, while my model have different items per level.
I might have a major design flaw, or I simply don't know how to achieve what I'm trying to implement.
I'd like some guidance.
P.S.
Here is an image of the main screen hierarchy and the 3 sections
Solution
Summary, from comments: