Categorize Spaces as such in sidebar

Currently they are shown at the bottom, since Neochat doesn't support
displaying Spaces yet.
This commit is contained in:
Smitty van Bodegom
2021-07-28 16:20:51 -04:00
parent 4658574732
commit db1a9a0c4c
2 changed files with 13 additions and 0 deletions

View File

@@ -353,6 +353,14 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
if (room->isDirectChat()) { if (room->isDirectChat()) {
return RoomType::Direct; 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; return RoomType::Normal;
} }
if (role == UnreadCountRole) { if (role == UnreadCountRole) {
@@ -431,6 +439,8 @@ QString RoomListModel::categoryName(int section)
return i18n("Normal"); return i18n("Normal");
case 5: case 5:
return i18n("Low priority"); return i18n("Low priority");
case 6:
return i18n("Spaces");
default: default:
return "Deadbeef"; return "Deadbeef";
} }
@@ -449,6 +459,8 @@ QString RoomListModel::categoryIconName(int section)
return QStringLiteral("group"); return QStringLiteral("group");
case 5: case 5:
return QStringLiteral("object-order-lower"); return QStringLiteral("object-order-lower");
case 6:
return QStringLiteral("group");
default: default:
return QStringLiteral("tools-report-bug"); return QStringLiteral("tools-report-bug");
} }

View File

@@ -23,6 +23,7 @@ public:
Direct, Direct,
Normal, Normal,
Deprioritized, Deprioritized,
Space,
}; };
Q_ENUM(Types) Q_ENUM(Types)
}; };