From 424405e3e8af446baed99cc8dcf14dd56ad56be6 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 21 Apr 2019 16:53:16 -0400 Subject: [PATCH] Set invited and left rooms position in model Invited rooms at the start, left rooms at the end, with the bonus effect of fixing the roomList height problem. --- harmonyqml/backend/model/list_model.py | 1 - harmonyqml/backend/signal_manager.py | 8 ++++++++ harmonyqml/components/sidePane/RoomList.qml | 9 +++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/harmonyqml/backend/model/list_model.py b/harmonyqml/backend/model/list_model.py index a283476a..71fc9d28 100644 --- a/harmonyqml/backend/model/list_model.py +++ b/harmonyqml/backend/model/list_model.py @@ -197,7 +197,6 @@ class ListModel(QAbstractListModel): if (n <= 0) or (from_ == to) or (qlast == to) or \ not (self.rowCount() > qlast >= 0) or \ not self.rowCount() >= to >= 0: - logging.warning("No need for move or out of range") return qidx = QModelIndex() diff --git a/harmonyqml/backend/signal_manager.py b/harmonyqml/backend/signal_manager.py index 20e1d1dd..916bf847 100644 --- a/harmonyqml/backend/signal_manager.py +++ b/harmonyqml/backend/signal_manager.py @@ -115,6 +115,14 @@ class SignalManager(QObject): ) model.updateOrAppendWhere("roomId", room_id, item) + index = model.indexWhere("roomId", room_id) + + if category == "Invites": + model.move(index, 0) + + elif category == "Left": + model.move(index, len(model)) + def onRoomSyncPrevBatchTokenReceived( diff --git a/harmonyqml/components/sidePane/RoomList.qml b/harmonyqml/components/sidePane/RoomList.qml index 9bbfe819..aa96443b 100644 --- a/harmonyqml/components/sidePane/RoomList.qml +++ b/harmonyqml/components/sidePane/RoomList.qml @@ -8,9 +8,9 @@ ListView { property int childrenHeight: 36 property int sectionHeight: 16 + spacing - property int contentHeight: 0 + property int contentHeight: getContentHeight() - onCountChanged: { + function getContentHeight() { var sections = [] for (var i = 0; i < model.count; i++) { @@ -24,6 +24,11 @@ ListView { sectionHeight * sections.length } + Connections { + target: model + onChanged: getContentHeight() + } + id: roomList spacing: 8 model: Backend.models.rooms.get(forUserId)