From d4b4a7e1ff01f9ca161417cfde563e2882effd7c Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Tue, 17 Oct 2023 22:05:20 +0200 Subject: [PATCH] Only hide replaced rooms if we're joined to the replacement room --- src/models/roomlistmodel.cpp | 3 +++ src/models/roomlistmodel.h | 1 + src/models/sortfilterroomlistmodel.cpp | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/models/roomlistmodel.cpp b/src/models/roomlistmodel.cpp index df0afc3fc..baef96f96 100644 --- a/src/models/roomlistmodel.cpp +++ b/src/models/roomlistmodel.cpp @@ -368,6 +368,9 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const if (role == IsChildSpaceRole) { return SpaceHierarchyCache::instance().isChildSpace(room->id()); } + if (role == ReplacementIdRole) { + return room->successorId(); + } return QVariant(); } diff --git a/src/models/roomlistmodel.h b/src/models/roomlistmodel.h index 141cc1fc6..e1f5140b0 100644 --- a/src/models/roomlistmodel.h +++ b/src/models/roomlistmodel.h @@ -79,6 +79,7 @@ public: RoomIdRole, /**< The room matrix ID. */ IsSpaceRole, /**< Whether the room is a space. */ IsChildSpaceRole, /**< Whether this space is a child of a different space. */ + ReplacementIdRole, /**< The room id of the room replacing this one, if any. */ }; Q_ENUM(EventRoles) diff --git a/src/models/sortfilterroomlistmodel.cpp b/src/models/sortfilterroomlistmodel.cpp index 8d1ffffdb..b6a22aa90 100644 --- a/src/models/sortfilterroomlistmodel.cpp +++ b/src/models/sortfilterroomlistmodel.cpp @@ -3,6 +3,7 @@ #include "sortfilterroomlistmodel.h" +#include "neochatconnection.h" #include "roomlistmodel.h" #include "spacehierarchycache.h" @@ -78,9 +79,15 @@ bool SortFilterRoomListModel::filterAcceptsRow(int source_row, const QModelIndex { Q_UNUSED(source_parent); + if (sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::JoinStateRole).toString() == QStringLiteral("upgraded") + && dynamic_cast(sourceModel()) + ->connection() + ->room(sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::ReplacementIdRole).toString())) { + return false; + } + bool acceptRoom = sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::DisplayNameRole).toString().contains(m_filterText, Qt::CaseInsensitive) - && sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::JoinStateRole).toString() != QStringLiteral("upgraded") && sourceModel()->data(sourceModel()->index(source_row, 0), RoomListModel::IsSpaceRole).toBool() == false; if (m_activeSpaceId.isEmpty()) {