-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT Custom model interface #1917
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a good framework, but I had some thoughts on how we could get more type safety and reusability from the code.
}; | ||
|
||
// Index / Column ID, Name / Column Title, Data Type, ReadOnly? | ||
using DataItemProperty = std::tuple<int, std::string, PropertyType, Flags<PropertyFlag>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this might be a bit clearer as a struct
. That would allow us to do diProp.index
instead of std::get<0>(diProp)
. Of course, we could still overload std::get if we really needed to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, for sure! I was using the std::tuple
just to quickly spin up a working example, although all the std::get<>
pollution quickly became rather tiresome. struct
or class
definitely the way to go.
6b55320
to
84f684c
Compare
@rprospero here is the stuff I came up with when looking into custom model interfaces. Still uses a template class sitting alongside the data (here focussing just on
std::vector
and tables) but the template derives from a concrete base class which the Qt model leverages to do all the work.Thoughts on how any of this (if any!) can work with your own approach welcome!