aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-04-04 21:27:38 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-04-06 20:32:48 +0900
commit432e7fd7107d8260e0016a1adcd8d94263dc1044 (patch)
tree71171a541e508f7a97b1d843c707c7ef296374cb /lib/connection.cpp
parent8035ec464ce797abab5e464c2cfb485f7fa14d06 (diff)
downloadlibquotient-432e7fd7107d8260e0016a1adcd8d94263dc1044.tar.gz
libquotient-432e7fd7107d8260e0016a1adcd8d94263dc1044.zip
Clean up on clang-tidy/clazy analysis
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index c09de979..5ed72616 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -717,8 +717,8 @@ void Connection::doInDirectChat(User* u,
CreateRoomJob* Connection::createDirectChat(const QString& userId,
const QString& topic, const QString& name)
{
- return createRoom(UnpublishRoom, "", name, topic, {userId},
- "trusted_private_chat", {}, true);
+ return createRoom(UnpublishRoom, {}, name, topic, {userId},
+ QStringLiteral("trusted_private_chat"), {}, true);
}
ForgetRoomJob* Connection::forgetRoom(const QString& id)
@@ -964,7 +964,8 @@ QHash<QString, QVector<Room*>> Connection::tagsToRooms() const
QHash<QString, QVector<Room*>> result;
for (auto* r: qAsConst(d->roomMap))
{
- for (const auto& tagName: r->tagNames())
+ const auto& tagNames = r->tagNames();
+ for (const auto& tagName: tagNames)
result[tagName].push_back(r);
}
for (auto it = result.begin(); it != result.end(); ++it)
@@ -979,9 +980,12 @@ QStringList Connection::tagNames() const
{
QStringList tags ({FavouriteTag});
for (auto* r: qAsConst(d->roomMap))
- for (const auto& tag: r->tagNames())
+ {
+ const auto& tagNames = r->tagNames();
+ for (const auto& tag: tagNames)
if (tag != LowPriorityTag && !tags.contains(tag))
tags.push_back(tag);
+ }
tags.push_back(LowPriorityTag);
return tags;
}
@@ -1264,18 +1268,19 @@ void Connection::saveState() const
{
QJsonObject rooms;
QJsonObject inviteRooms;
- for (const auto* i : roomMap()) // Pass on rooms in Leave state
+ const auto& rs = roomMap(); // Pass on rooms in Leave state
+ for (const auto* i : rs)
(i->joinState() == JoinState::Invite ? inviteRooms : rooms)
.insert(i->id(), QJsonValue::Null);
QJsonObject roomObj;
if (!rooms.isEmpty())
- roomObj.insert("join", rooms);
+ roomObj.insert(QStringLiteral("join"), rooms);
if (!inviteRooms.isEmpty())
- roomObj.insert("invite", inviteRooms);
+ roomObj.insert(QStringLiteral("invite"), inviteRooms);
- rootObj.insert("next_batch", d->data->lastEvent());
- rootObj.insert("rooms", roomObj);
+ rootObj.insert(QStringLiteral("next_batch"), d->data->lastEvent());
+ rootObj.insert(QStringLiteral("rooms"), roomObj);
}
{
QJsonArray accountDataEvents {
@@ -1285,7 +1290,7 @@ void Connection::saveState() const
accountDataEvents.append(
basicEventJson(e.first, e.second->contentJson()));
- rootObj.insert("account_data",
+ rootObj.insert(QStringLiteral("account_data"),
QJsonObject {{ QStringLiteral("events"), accountDataEvents }});
}