diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-27 19:51:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-27 19:51:08 +0900 |
commit | 375bea5ee67a90c6419acf50c06c05ed0435c772 (patch) | |
tree | 76f0a1c830797fe1b17b3bea67ddaf7fb53cbd6a /connection.cpp | |
parent | e80bfd2fc710d4780a2c22bde9d605a41bd4aaa4 (diff) | |
parent | efeeca097a3c69991683615366f07625855ba2ac (diff) | |
download | libquotient-375bea5ee67a90c6419acf50c06c05ed0435c772.tar.gz libquotient-375bea5ee67a90c6419acf50c06c05ed0435c772.zip |
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'connection.cpp')
-rw-r--r-- | connection.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/connection.cpp b/connection.cpp index 6a3cd957..98e534b8 100644 --- a/connection.cpp +++ b/connection.cpp @@ -519,6 +519,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; @@ -574,7 +598,7 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState) { qCDebug(MAIN) << "Deleting Invite state for room" << prevInvite->id(); emit aboutToDeleteRoom(prevInvite); - delete prevInvite; + prevInvite->deleteLater(); } } @@ -602,7 +626,7 @@ void Connection::setHomeserver(const QUrl& url) emit homeserverChanged(homeserver()); } -static constexpr int CACHE_VERSION_MAJOR = 2; +static constexpr int CACHE_VERSION_MAJOR = 3; static constexpr int CACHE_VERSION_MINOR = 0; void Connection::saveState(const QUrl &toFile) const |