Details
-
Suggestion
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
None
Description
Currently, this code behaves as expected:
IntentModel { id: im1 sourceModel: IntentServer sortFunction: function(li, ri) { return li.name < ri.name } } IntentModel { id: im2 sourceModel: im1 } Repeater { model: im2 ... }
However, it breaks if we add actual filtering/sorting to both IntentModels. This is because the current implementation of IntentModel assumes that its source is always IntentServer::instance():
int IntentModel::indexOfIntent(Intent *intent) { int idx = IntentServer::instance()->indexOfIntent(intent); return idx != -1 ? mapFromSource(idx) : idx; }
It should work if we remove that assumption:
int IntentModel::indexOfIntent(Intent *intent) { int idx = -1; if (auto src = qobject_cast<IntentServer*>(sourceModel()) // Most likely idx = src->indexOfIntent(intent); else if (auto src = qobject_cast<IntentModel*>(sourceModel()) // Less likely idx = src->indexOfIntent(intent); return idx != -1 ? mapFromSource(idx) : idx; }
Notes
The QML tools currently don't recognize the IntentModel.sourceModel property, so that ought to be addressed too (see QTBUG-114755 )
Attachments
Issue Links
- is covered by
-
QTBUG-71348 SortFilterProxyModel for QML (make QSortFilterProxyModel available)
- Open