HStringFilterModel: Refilter when field changes
This commit is contained in:
parent
7418f0fe93
commit
2bb13bf7f7
|
@ -12,4 +12,9 @@ HFilterModel {
|
||||||
property string field: "id"
|
property string field: "id"
|
||||||
property string filter: ""
|
property string filter: ""
|
||||||
property ListModel sourceModel
|
property ListModel sourceModel
|
||||||
|
|
||||||
|
readonly property Connections sourceModelConnections: Connections {
|
||||||
|
target: sourceModel // model is non-notifiable
|
||||||
|
onFieldsChanged: if (field in changes) refilterAt(index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ QtObject {
|
||||||
|
|
||||||
readonly property Component model: Component {
|
readonly property Component model: Component {
|
||||||
ListModel {
|
ListModel {
|
||||||
|
// Used by HFilterModel
|
||||||
|
signal fieldsChanged(int index, var changes)
|
||||||
|
|
||||||
property var modelId
|
property var modelId
|
||||||
|
|
||||||
function findIndex(id, default_=null) {
|
function findIndex(id, default_=null) {
|
||||||
|
|
|
@ -60,7 +60,10 @@ QtObject {
|
||||||
// JSON.stringify(changedFields))
|
// JSON.stringify(changedFields))
|
||||||
const model = ModelStore.get(syncId)
|
const model = ModelStore.get(syncId)
|
||||||
model.set(indexThen, changedFields)
|
model.set(indexThen, changedFields)
|
||||||
|
|
||||||
if (indexThen !== indexNow) model.move(indexThen, indexNow, 1)
|
if (indexThen !== indexNow) model.move(indexThen, indexNow, 1)
|
||||||
|
|
||||||
|
model.fieldsChanged(indexNow, changedFields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user