From 19fe1c4e7b7a4f4fc155e170fa05194c0aabcafa Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 30 Apr 2020 14:28:12 -0400 Subject: [PATCH] Buggy room filtering --- TODO.md | 1 - src/gui/MainPane/MainPane.qml | 1 + src/gui/MainPane/RoomList.qml | 13 ++++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 37efc778..cef34e35 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,6 @@ - update glass theme - back/front buttons in small window - minimum sizes -- filter - save/restore swipeview current rooms for accounts - lag when switching accounts - message delegate too tall diff --git a/src/gui/MainPane/MainPane.qml b/src/gui/MainPane/MainPane.qml index 2746bc25..c5c2b356 100644 --- a/src/gui/MainPane/MainPane.qml +++ b/src/gui/MainPane/MainPane.qml @@ -39,6 +39,7 @@ HDrawer { RoomList { id: roomList clip: true + filter: filterRoomsField.text Layout.fillWidth: true Layout.fillHeight: true diff --git a/src/gui/MainPane/RoomList.qml b/src/gui/MainPane/RoomList.qml index 57b9a37a..4ff00d27 100644 --- a/src/gui/MainPane/RoomList.qml +++ b/src/gui/MainPane/RoomList.qml @@ -2,12 +2,13 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 +import SortFilterProxyModel 0.2 import ".." import "../Base" HListView { id: roomList - model: ModelStore.get("every_room") + model: filter ? proxyModel : proxyModel.sourceModel section.property: "for_account" section.labelPositioning: @@ -23,6 +24,7 @@ HListView { } + property string filter: "" readonly property var sectionIndice: { const sections = {} const accounts = ModelStore.get("accounts") @@ -95,6 +97,15 @@ HListView { } } + HSortFilterProxyModel { + id: proxyModel + sourceModel: ModelStore.get("every_room") + + filters: ExpressionFilter { + expression: utils.filterMatches(filter, model.display_name) + } + } + Rectangle { anchors.fill: parent z: -100