Mark Gaiser schreef op 26-5-2015 om 17:02:
On Tue, May 26, 2015 at 12:35 PM, André Somers <an...@familiesomers.nl
<mailto:an...@familiesomers.nl>> wrote:
I ended up writing my own class that I export to QML for this. It
subclasses QSortFilterProxyModel and exposes a nice QML-friendly
API for
doing filtering and sorting.
That sounds interesting!
Could you share that somewhere (preferably under LGPL, GPL or even BSD)?
Hmm... I can try, but I am not sure I'll get permission for that. It is
part of a closed source package we have developed. So, definately not in
the short term.
I was thinking of writing a wrapper class for that as well.
A thing i also miss is having to ability to set filters
in QSortFilterProxyModel without the need to subclass it. That would
be possible if it takes a lambda as argument for filtering.
Thats something I'd like to do as well, but preferably as an addition to
Qt itself. However, that is not really a friendly QML API either.
I created a QML API where you can add filters to the object. Each filter
has a role it uses to fetch the data, and has some properties like
"equals" and "contains" to set the criteria. Filters can be combined
with OR and AND, negated by NOT and grouped, so you end up with
something like this:
ModelFilter {
id: filteredModel
model: myData.model
combine: ModelFilter.And
Filter { role: "value"; contains: filterText.text }
Filter { role: "someRole"; equals: "aValue" }
}
André
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest