From 99d59bb49bc586c6cabb31ab937d366af28b81fc Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 15 Apr 2020 16:54:24 -0400 Subject: [PATCH] Use filtered model strictly when neccessary --- src/backend/matrix_client.py | 1 - src/gui/MainPane/AccountRoomsDelegate.qml | 37 +++++++++------------- src/gui/Pages/Chat/RoomPane/MemberView.qml | 19 ++++++----- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 86089415..5c25713f 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -761,7 +761,6 @@ class MatrixClient(nio.AsyncClient): # If a new room was added, wait for onSyncResponse to set the token await asyncio.sleep(0.1) - print( self.lazy_load_filter) response = await self.room_messages( room_id = room_id, start = self.past_tokens[room_id], diff --git a/src/gui/MainPane/AccountRoomsDelegate.qml b/src/gui/MainPane/AccountRoomsDelegate.qml index edb11f89..0aa85ced 100644 --- a/src/gui/MainPane/AccountRoomsDelegate.qml +++ b/src/gui/MainPane/AccountRoomsDelegate.qml @@ -21,8 +21,6 @@ Column { readonly property alias collapsed: account.collapsed readonly property alias roomList: roomList - onFirstSyncDoneChanged: print("fsd") - Account { id: account @@ -39,29 +37,16 @@ Column { height: contentHeight interactive: false - model: HSortFilterProxyModel { - sourceModel: ModelStore.get(accountRooms.userId, "rooms") - - filters: [ - ExpressionFilter { - expression: ! account.collapsed - enabled: ! mainPane.filter - }, - - ExpressionFilter { - expression: utils.filterMatches( - mainPane.filter, model.display_name, - ) - } - ] - } + // https://github.com/oKcerG/SortFilterProxyModel/issues/75 + model: + mainPane.filter ? proxy : + account.collapsed ? null : + proxy.sourceModel delegate: HLoader { asynchronous: false active: firstSyncDone && inView - onInViewChanged: print("iv") - width: roomList.width height: roomList.firstDelegateHeight @@ -95,8 +80,6 @@ Column { contentItem.visibleChildren[0] ? contentItem.visibleChildren[0].implicitHeight : 0 - property var pr: firstDelegateHeight - onPrChanged: print("pr changed:", pr) readonly property bool hasActiveRoom: window.uiState.page === "Pages/Chat/Chat.qml" && @@ -106,6 +89,16 @@ Column { hasActiveRoom ? model.findIndex(window.uiState.pageProperties.roomId) : null + readonly property HSortFilterProxyModel proxy: HSortFilterProxyModel { + sourceModel: ModelStore.get(accountRooms.userId, "rooms") + + filters: ExpressionFilter { + expression: utils.filterMatches( + mainPane.filter, model.display_name, + ) + } + } + Binding on currentIndex { value: diff --git a/src/gui/Pages/Chat/RoomPane/MemberView.qml b/src/gui/Pages/Chat/RoomPane/MemberView.qml index 63e19de9..f325c28f 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView.qml @@ -14,7 +14,17 @@ HColumnLayout { id: memberList clip: true - model: HSortFilterProxyModel { + // https://github.com/oKcerG/SortFilterProxyModel/issues/75 + model: filterField.text ? proxy : proxy.sourceModel + + delegate: MemberDelegate { + width: memberList.width + } + + Layout.fillWidth: true + Layout.fillHeight: true + + readonly property HSortFilterProxyModel proxy: HSortFilterProxyModel { sourceModel: ModelStore.get(chat.userId, chat.roomId, "members") filters: ExpressionFilter { @@ -24,13 +34,6 @@ HColumnLayout { } } - delegate: MemberDelegate { - width: memberList.width - } - - Layout.fillWidth: true - Layout.fillHeight: true - Rectangle { anchors.fill: parent z: -100