Use two sortfilterproxymodel.

Prepare for #53
This commit is contained in:
Black Hat 2018-09-23 21:09:49 +08:00
parent 7c833ce764
commit f3693d819d
1 changed files with 32 additions and 21 deletions

View File

@ -13,7 +13,7 @@ import "qrc:/qml/menu"
import "qrc:/js/util.js" as Util
Item {
property alias listModel: roomListProxyModel.sourceModel
property alias listModel: sortedRoomListModel.sourceModel
property int filter: 0
property var enteredRoom: null
@ -50,27 +50,8 @@ Item {
}
SortFilterProxyModel {
id: roomListProxyModel
id: sortedRoomListModel
filters: [
RegExpFilter {
roleName: "name"
pattern: searchField.text
caseSensitivity: Qt.CaseInsensitive
},
ExpressionFilter {
enabled: filter === 1
expression: unreadCount > 0
},
ExpressionFilter {
enabled: filter === 2
expression: category === 1 || category === 2 || category === 4
},
ExpressionFilter {
enabled: filter === 3
expression: category === 3 || category === 5
}
]
proxyRoles: ExpressionRole {
name: "display"
expression: {
@ -93,6 +74,36 @@ Item {
]
}
SortFilterProxyModel {
id: roomListProxyModel
sourceModel: sortedRoomListModel
filters: [
RegExpFilter {
roleName: "name"
pattern: searchField.text
caseSensitivity: Qt.CaseInsensitive
},
ExpressionFilter {
enabled: filter === 1
expression: unreadCount > 0
},
IndexFilter {
enabled: filter === 1
maximumIndex: 16
},
ExpressionFilter {
enabled: filter === 2
expression: category === 1 || category === 2 || category === 4
},
ExpressionFilter {
enabled: filter === 3
expression: category === 3 || category === 5
}
]
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true