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-04 21:27:38 +0900
commit1c5696e8f5a9ef87a065e2496eecf178e41e75a7 (patch)
tree8b41686c2e599054666868479589ef0df3a375a2 /lib/connection.cpp
parent7508887564935f70b086ed6fe79bd86757d1fc38 (diff)
downloadlibquotient-1c5696e8f5a9ef87a065e2496eecf178e41e75a7.tar.gz
libquotient-1c5696e8f5a9ef87a065e2496eecf178e41e75a7.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 }});
}