Room filtering.

This commit is contained in:
Black Hat 2018-09-22 22:28:47 +08:00
parent 04d4854352
commit 7c833ce764
5 changed files with 98 additions and 27 deletions

View File

@ -9,6 +9,7 @@ import "form"
Page { Page {
property alias connection: roomListModel.connection property alias connection: roomListModel.connection
property alias filter: roomListForm.filter
id: page id: page

View File

@ -213,13 +213,6 @@ Page {
onCheckedChanged: MSettings.miniMode = checked onCheckedChanged: MSettings.miniMode = checked
} }
Switch {
text: "Rearrange rooms by activity"
checked: MSettings.rearrangeByActivity
onCheckedChanged: MSettings.rearrangeByActivity = checked
}
} }
} }

View File

@ -4,7 +4,6 @@ import Qt.labs.settings 1.0
Settings { Settings {
property bool pressAndHold property bool pressAndHold
property bool rearrangeByActivity
property bool darkTheme property bool darkTheme
property bool miniMode property bool miniMode

View File

@ -14,6 +14,7 @@ import "qrc:/js/util.js" as Util
Item { Item {
property alias listModel: roomListProxyModel.sourceModel property alias listModel: roomListProxyModel.sourceModel
property int filter: 0
property var enteredRoom: null property var enteredRoom: null
Label { Label {
@ -51,11 +52,25 @@ Item {
SortFilterProxyModel { SortFilterProxyModel {
id: roomListProxyModel id: roomListProxyModel
filters: RegExpFilter { filters: [
roleName: "name" RegExpFilter {
pattern: searchField.text roleName: "name"
caseSensitivity: Qt.CaseInsensitive 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 { proxyRoles: ExpressionRole {
name: "display" name: "display"
expression: { expression: {
@ -72,11 +87,9 @@ Item {
sorters: [ sorters: [
RoleSorter { roleName: "category" }, RoleSorter { roleName: "category" },
RoleSorter { RoleSorter {
enabled: MSettings.rearrangeByActivity
roleName: "lastActiveTime" roleName: "lastActiveTime"
sortOrder: Qt.DescendingOrder sortOrder: Qt.DescendingOrder
}, }
StringSorter { roleName: "name" }
] ]
} }

View File

@ -116,25 +116,90 @@ ApplicationWindow {
clip: true clip: true
delegate: SideNavButton { delegate: Column {
property bool expanded: accountListView.currentConnection === connection
width: parent.width width: parent.width
height: width
selected: stackView.currentItem === page && currentConnection === connection spacing: 0
ImageItem { SideNavButton {
anchors.fill: parent width: parent.width
anchors.margins: 12 height: width
hint: user.displayName selected: stackView.currentItem === page && currentConnection === connection
image: user.avatar
ImageItem {
anchors.fill: parent
anchors.margins: 12
hint: user.displayName
image: user.avatar
}
highlightColor: spectralController.color(user.id)
page: roomPage
onClicked: {
accountListView.currentConnection = connection
roomPage.filter = 0
}
} }
highlightColor: spectralController.color(user.id) Column {
width: parent.width
height: expanded ? implicitHeight : 0
page: roomPage spacing: 0
clip: true
onClicked: accountListView.currentConnection = connection SideNavButton {
width: parent.width
height: width
MaterialIcon {
anchors.fill: parent
icon: "\ue7f7"
color: "white"
}
onClicked: roomPage.filter = 1
}
SideNavButton {
width: parent.width
height: width
MaterialIcon {
anchors.fill: parent
icon: "\ue7fd"
color: "white"
}
onClicked: roomPage.filter = 2
}
SideNavButton {
width: parent.width
height: width
MaterialIcon {
anchors.fill: parent
icon: "\ue886"
color: "white"
}
onClicked: roomPage.filter = 3
}
Behavior on height {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
}
} }
} }