enigma-dev / RadialGM

A native IDE for ENIGMA written in C++ using the Qt Framework.
GNU General Public License v3.0
46 stars 22 forks source link

Editor Mapper #151

Closed RobertBColton closed 1 year ago

RobertBColton commented 4 years ago

This pull request introduces a new class which encapsulates the hierarchical data binding of the editors. It abstracts knowledge of how the message models are structured behind an interface that only requires knowledge of the protocol buffer's structure. Things like mapping of master detail interfaces, such as the Room View combobox, is automated by the interface (e.g, pushView). What this would allow us to do is change the model structure later on and not have to recode every editor. It would also allow us to flatten the existing models to solve #127 without having to recode all the editors because the mapper would be responsible for mapping the fields number into the flattened field index.

RobertBColton commented 4 years ago

We don't know if we're going to do this yet because Josh would like all of this in the XML since it's boilerplate. I spent a little time investigating custom properties in the UI XML files again and had some success. The XML would handle the recursive bindings using a stack of mappers then, eliminating the need for this class. We could always do it with string names to map the widget by looking up the field number using the descriptor, but me and Josh both agreed that it would be better to fail at compile time if you misstype a proto field name. I managed to get enums working but there's a couple of issues in that it would require we include treenode.pb.h which already depends on every resource type and would slow down compilation.

  <property name="protoField" stdset="0">
   <set>buffers::TreeNode::kNameFieldNumber</set>
  </property>
...
 <includes>
    <include location="global" impldecl="in declaration">treenode.pb.h</include>
</includes>

I am wondering if we could hijack the MOC source files to handle this stuff so the treenode could be included in the source instead of the declaration. MOC Background Editor Source There's also the extension stuff that lets you do some cool stuff. https://doc.qt.io/qt-5/designer-creating-custom-widgets-extensions.html Designer Property Sheet Extension