From db1a9a0c4c5eaa6d35eef09db540bd3c429b9c80 Mon Sep 17 00:00:00 2001 From: Smitty van Bodegom Date: Wed, 28 Jul 2021 16:20:51 -0400 Subject: [PATCH] Categorize Spaces as such in sidebar Currently they are shown at the bottom, since Neochat doesn't support displaying Spaces yet. --- src/roomlistmodel.cpp | 12 ++++++++++++ src/roomlistmodel.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index b9612413d..e398b1f72 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -353,6 +353,14 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const if (room->isDirectChat()) { return RoomType::Direct; } + const RoomCreateEvent* creationEvent = room->creation(); + QJsonObject contentJson = creationEvent->contentJson(); + QJsonObject::const_iterator typeIter = contentJson.find("type"); + if (typeIter != contentJson.end()) { + if (typeIter.value().toString() == "m.space") { + return RoomType::Space; + } + } return RoomType::Normal; } if (role == UnreadCountRole) { @@ -431,6 +439,8 @@ QString RoomListModel::categoryName(int section) return i18n("Normal"); case 5: return i18n("Low priority"); + case 6: + return i18n("Spaces"); default: return "Deadbeef"; } @@ -449,6 +459,8 @@ QString RoomListModel::categoryIconName(int section) return QStringLiteral("group"); case 5: return QStringLiteral("object-order-lower"); + case 6: + return QStringLiteral("group"); default: return QStringLiteral("tools-report-bug"); } diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 4bcb06142..565562cd3 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -23,6 +23,7 @@ public: Direct, Normal, Deprioritized, + Space, }; Q_ENUM(Types) };