Python filtered models for room members

This commit is contained in:
miruka
2020-05-10 14:58:59 -04:00
parent 200f25d23e
commit 37a9332aed
5 changed files with 54 additions and 18 deletions

View File

@@ -38,9 +38,12 @@ QtObject {
function get(...modelId) {
if (modelId.length === 1) modelId = modelId[0]
if (! privates.store[modelId])
if (! privates.store[modelId]) {
privates.py.callCoro("models.ensure_exists_from_qml", [modelId])
privates.store[modelId] =
privates.model.createObject(this, {modelId})
}
return privates.store[modelId]
}

View File

@@ -7,28 +7,25 @@ import "../../../Base"
HColumnLayout {
readonly property alias keybindFocusItem: filterField
readonly property var modelSyncId:
[chat.userId, chat.roomId, "filtered_members"]
HListView {
id: memberList
clip: true
add: null // See the XXX comment in HListView.qml
model: HStringFilterModel {
sourceModel: ModelStore.get(chat.userId, chat.roomId, "members")
field: "display_name"
filter: filterField.text
model: ModelStore.get(modelSyncId)
delegate: MemberDelegate {
id: member
width: memberList.width
ListView.onAdd: ParallelAnimation {
HNumberAnimation {
target: member; property: "opacity"; from: 0; to: 1;
}
HNumberAnimation {
target: member; property: "scale"; from: 0; to: 1;
}
delegate: MemberDelegate {
id: member
width: memberList.width
ListView.onAdd: ParallelAnimation {
HNumberAnimation {
target: member; property: "opacity"; from: 0; to: 1;
}
HNumberAnimation {
target: member; property: "scale"; from: 0; to: 1;
}
}
}
@@ -70,6 +67,9 @@ HColumnLayout {
// declared normally
Component.onCompleted: placeholderText = qsTr("Filter members")
onTextChanged:
py.callCoro("set_substring_filter", [modelSyncId, text])
Behavior on opacity { HNumberAnimation {} }
}