aboutsummaryrefslogtreecommitdiff
path: root/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-02-26 09:07:16 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-02-26 09:07:16 +0900
commit91cc0e8db0006beeb91b9e007cd21343984dfb6a (patch)
tree7a79286d7c6e5a99644c3f7141e1cdc8e2459416 /connection.cpp
parente77a53946805649be99f8c0f6ee9c00702348132 (diff)
parentec412621d71b1a7758b15d2b3c5cd5e7b2081ab1 (diff)
downloadlibquotient-91cc0e8db0006beeb91b9e007cd21343984dfb6a.tar.gz
libquotient-91cc0e8db0006beeb91b9e007cd21343984dfb6a.zip
Merge branch 'kitsune-account-data'
Diffstat (limited to 'connection.cpp')
-rw-r--r--connection.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/connection.cpp b/connection.cpp
index 4b7d4abb..52fcc40b 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -520,6 +520,30 @@ QHash< QPair<QString, bool>, Room* > Connection::roomMap() const
return roomMap;
}
+QHash<QString, QVector<Room*>> Connection::tagsToRooms() const
+{
+ QHash<QString, QVector<Room*>> result;
+ for (auto* r: d->roomMap)
+ {
+ for (const auto& tagName: r->tagNames())
+ result[tagName].push_back(r);
+ }
+ for (auto it = result.begin(); it != result.end(); ++it)
+ std::sort(it->begin(), it->end(),
+ [t=it.key()] (Room* r1, Room* r2) {
+ return r1->tags().value(t).order < r2->tags().value(t).order;
+ });
+ return result;
+}
+
+QVector<Room*> Connection::roomsWithTag(const QString& tagName) const
+{
+ QVector<Room*> rooms;
+ std::copy_if(d->roomMap.begin(), d->roomMap.end(), std::back_inserter(rooms),
+ [&tagName] (Room* r) { return r->tags().contains(tagName); });
+ return rooms;
+}
+
QMap<QString, User*> Connection::users() const
{
return d->userMap;