-
Notifications
You must be signed in to change notification settings - Fork 102
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
Filtering based on unique values of dynamic properties of the model #67
Comments
Answer from @oKcerG via email: There are two problems to solve for your usage that are not supported by the SFPM lib The first one is getting unique values for the different fields of your model. I've already thought about this one but I believe it is out of scope of my lib. A possible api would look like:
With The other problem is adding ValueFilters dynamically to the SFPM. If you want to implement it, I don't mind a PR :) The way I see it, there are 4 possibles API:
From a theroical point of view, I prefer solution 2 with the attached property. It doesn't make the filter aware of its container. 3 is maybe the simplest to do, if you want to do this internally (not contributing it), and don't care about supporting edge cases, I guess that's what I would recommend. 4 is too hard and not flexible enough. In your use case you might want to have a Repeater of ComboBox, and instantiate a ValueFilter in each ComboBox, 1, 2, 3 can do that (3 with ugly Component.onCompleted/onDestruction). With 4 you can't. You'd have to have a Repeater of ComboBox and a FilterRepeater of ValueFilter, and somehow link them. If your list of roles is not know in advance, you can use my QmlModelHelper lib to query it : https://github.com/oKcerG/QmlModelHelper (look at the tests to figure out what it does, or read this unfinished readme : https://gist.github.com/oKcerG/eeea734bdacc51b3ae58650de5f05943 ) |
What would be the most efficient/appropriate way to achieve a model based on the contents of the model itself.
To give an example what I try to achieve: https://www.amazon.com/s?i=electronics-intl-ship&bbn=16225009011&rh=n%3A%2116225009011%2Cn%3A1266092011%2Cn%3A172659&dc&fst=as%3Aoff&qid=1563278627&rnid=1266092011&ref=sr_nr_n_13
Eg: Having a list of "products" which have properties like: "brand", "type", "size" , ...
I would like to be able to filter them based on the contents of these properties.
This should be performed dynamically, as I am not aware of all possible values/categories available.
Also, values may change as filters are being applied dynamically.
Do you have a suggestion on how to achieve this?
I can iterate through the resulting Proxy Model, making a list per property containing all its unique values (and count, to sort).
With this list I could generate QML CheckBoxes, and create ValueFilter's on the fly?
Not sure though if this is the most memory efficient/performant though.
Thanks!
The text was updated successfully, but these errors were encountered: