Replace SortFilterProxyModel by DelegateModel

This commit is contained in:
miruka
2020-04-30 16:37:03 -04:00
parent 19fe1c4e7b
commit 69a525d317
9 changed files with 83 additions and 64 deletions

View File

@@ -2,7 +2,6 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import SortFilterProxyModel 0.2
import "../../.."
import "../../../Base"
@@ -14,26 +13,17 @@ HColumnLayout {
id: memberList
clip: true
// https://github.com/oKcerG/SortFilterProxyModel/issues/75
model: filterField.text ? proxy : proxy.sourceModel
model: HFilterModel {
model: ModelStore.get(chat.userId, chat.roomId, "members")
delegate: MemberDelegate { width: memberList.width }
delegate: MemberDelegate {
width: memberList.width
acceptItem: item =>
utils.filterMatches(filterField.text, item.display_name)
}
Layout.fillWidth: true
Layout.fillHeight: true
readonly property HSortFilterProxyModel proxy: HSortFilterProxyModel {
sourceModel: ModelStore.get(chat.userId, chat.roomId, "members")
filters: ExpressionFilter {
expression: utils.filterMatches(
filterField.text, model.display_name,
)
}
}
Rectangle {
anchors.fill: parent
z: -100
@@ -68,6 +58,8 @@ HColumnLayout {
// declared normally
Component.onCompleted: placeholderText = qsTr("Filter members")
onTextChanged: memberList.model.refilterAll()
Behavior on opacity { HNumberAnimation {} }
}