Open trisyoungs opened 2 months ago
@rprospero Thoughts?
I've had a similar idea and I guess it's time to try and formalise a bit of the design. Or it's just time for me to vastly overengineer something.
We're likely thinking of the same design (i.e. a template class that takes a reference to a vector and can be passed callbacks for insertion, update, and delete). Here are the issues that I'm currently worried about.
QVariant asTableRow(&T value, int column, int role)
and bool writeTableRow(QVariant value, &T old, int column, int role)
. There would be two additional template functions int tableColumns<T>()
and QVariant tableColumnHeaders<T>(int column, int role)
. If we implement these overloads and specialise the template functions for the types, then it should be possible to drop in our template model class with no extra boiler plate.
Describe the feature / issue There are many reasons to use models for managing the viewing and editing of our data in the Dissolve GUI, however there is something of a disconnect in the way we manage data between the CLI "core" code and the Qt GUI.
Can we implement a custom "model" which sits alongside, e.g., a
std::vector<CustomData>
and provides "row" addition and deletion, read/write access to data, much as a QtAbstractItemModel does, but without any of the Qt? A companion Qt class in the GUI could then be designed to directly use this non-Qt model to achieve the desired result in the GUI. Why bother doing this? I'm thinking this would allow: