From 298822baeaffdc83386e003099e34819bcd7d18c Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 28 May 2021 22:14:59 +0200 Subject: Move currentRoom/timeline handling to roomlist --- src/timeline/RoomlistModel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/timeline/RoomlistModel.cpp') diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index 63054aa9..ad4177a4 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -341,6 +341,8 @@ RoomlistModel::clear() models.clear(); invites.clear(); roomids.clear(); + currentRoom_ = nullptr; + emit currentRoomChanged(); endResetModel(); } @@ -390,6 +392,17 @@ RoomlistModel::leave(QString roomid) } } +void +RoomlistModel::setCurrentRoom(QString roomid) +{ + nhlog::ui()->debug("Trying to switch to: {}", roomid.toStdString()); + if (models.contains(roomid)) { + currentRoom_ = models.value(roomid); + emit currentRoomChanged(); + nhlog::ui()->debug("Switched to: {}", roomid.toStdString()); + } +} + namespace { enum NotificationImportance : short { @@ -463,6 +476,11 @@ FilteredRoomlistModel::FilteredRoomlistModel(RoomlistModel *model, QObject *pare invalidate(); }); + connect(roomlistmodel, + &RoomlistModel::currentRoomChanged, + this, + &FilteredRoomlistModel::currentRoomChanged); + sort(0); } -- cgit 1.5.1