aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/avatar.cpp4
-rw-r--r--lib/connection.cpp7
-rw-r--r--lib/connection.h2
-rw-r--r--lib/room.cpp15
-rw-r--r--lib/settings.cpp11
5 files changed, 22 insertions, 17 deletions
diff --git a/lib/avatar.cpp b/lib/avatar.cpp
index cb734984..c65aa25c 100644
--- a/lib/avatar.cpp
+++ b/lib/avatar.cpp
@@ -45,7 +45,7 @@ public:
QImage get(Connection* connection, QSize size,
get_callback_t callback) const;
- bool upload(UploadContentJob* job, upload_callback_t callback);
+ bool upload(UploadContentJob* job, upload_callback_t&& callback);
bool checkUrl(const QUrl& url) const;
QString localFile() const;
@@ -154,7 +154,7 @@ QImage Avatar::Private::get(Connection* connection, QSize size,
return result;
}
-bool Avatar::Private::upload(UploadContentJob* job, upload_callback_t callback)
+bool Avatar::Private::upload(UploadContentJob* job, upload_callback_t &&callback)
{
_uploadRequest = job;
if (!isJobRunning(_uploadRequest))
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 97805fe7..d3324d47 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -931,7 +931,7 @@ void Connection::doInDirectChat(User* u,
// There can be more than one DC; find the first valid (existing and
// not left), and delete inexistent (forgotten?) ones along the way.
DirectChatsMap removals;
- for (auto it = d->directChats.find(u);
+ for (auto it = std::as_const(d->directChats).find(u);
it != d->directChats.end() && it.key() == u; ++it) {
const auto& roomId = *it;
if (auto r = room(roomId, JoinState::Join)) {
@@ -1232,7 +1232,7 @@ int Connection::roomsCount(JoinStates joinStates) const
{
// Using int to maintain compatibility with QML
// (consider also that QHash<>::size() returns int anyway).
- return int(std::count_if(d->roomMap.begin(), d->roomMap.end(),
+ return int(std::count_if(d->roomMap.cbegin(), d->roomMap.cend(),
[joinStates](Room* r) {
return joinStates.testFlag(r->joinState());
}));
@@ -1297,7 +1297,8 @@ QStringList Connection::tagNames() const
QVector<Room*> Connection::roomsWithTag(const QString& tagName) const
{
QVector<Room*> rooms;
- std::copy_if(d->roomMap.begin(), d->roomMap.end(), std::back_inserter(rooms),
+ std::copy_if(d->roomMap.cbegin(), d->roomMap.cend(),
+ std::back_inserter(rooms),
[&tagName](Room* r) { return r->tags().contains(tagName); });
return rooms;
}
diff --git a/lib/connection.h b/lib/connection.h
index 258280a8..6517b909 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -326,7 +326,7 @@ public:
const QStringList& previousRoomAliases,
const QStringList& roomAliases);
Q_INVOKABLE Quotient::Room* invitation(const QString& roomId) const;
- Q_INVOKABLE Quotient::User* user(const QString& userId);
+ Q_INVOKABLE Quotient::User* user(const QString& uId);
const User* user() const;
User* user();
QString userId() const;
diff --git a/lib/room.cpp b/lib/room.cpp
index 7f76d8df..eff3d144 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -296,8 +296,8 @@ public:
void dropDuplicateEvents(RoomEvents& events) const;
Changes setLastReadEvent(User* u, QString eventId);
- void updateUnreadCount(rev_iter_t from, rev_iter_t to);
- Changes promoteReadMarker(User* u, rev_iter_t newMarker, bool force = false);
+ void updateUnreadCount(const rev_iter_t& from, const rev_iter_t& to);
+ Changes promoteReadMarker(User* u, const rev_iter_t& newMarker, bool force = false);
Changes markMessagesAsRead(rev_iter_t upToMarker);
@@ -553,7 +553,7 @@ QStringList Room::localAliases() const
QStringList Room::remoteAliases() const
{
QStringList result;
- for (const auto& s : d->aliasServers)
+ for (const auto& s : std::as_const(d->aliasServers))
result += d->getCurrentState<RoomAliasesEvent>(s)->aliases();
return result;
}
@@ -640,7 +640,8 @@ Room::Changes Room::Private::setLastReadEvent(User* u, QString eventId)
return Change::NoChange;
}
-void Room::Private::updateUnreadCount(rev_iter_t from, rev_iter_t to)
+void Room::Private::updateUnreadCount(const rev_iter_t& from,
+ const rev_iter_t& to)
{
Q_ASSERT(from >= timeline.crbegin() && from <= timeline.crend());
Q_ASSERT(to >= from && to <= timeline.crend());
@@ -682,7 +683,8 @@ void Room::Private::updateUnreadCount(rev_iter_t from, rev_iter_t to)
}
}
-Room::Changes Room::Private::promoteReadMarker(User* u, rev_iter_t newMarker,
+Room::Changes Room::Private::promoteReadMarker(User* u,
+ const rev_iter_t& newMarker,
bool force)
{
Q_ASSERT_X(u, __FUNCTION__, "User* should not be nullptr");
@@ -1242,6 +1244,7 @@ QList<User*> Room::users() const { return d->membersMap.values(); }
QStringList Room::memberNames() const
{
QStringList res;
+ res.reserve(d->membersMap.size());
for (auto u : qAsConst(d->membersMap))
res.append(roomMembername(u));
@@ -1686,7 +1689,7 @@ QString Room::postFile(const QString& plainText, const QUrl& localPath,
uploadFile(txnId, localPath);
// Below, the upload job is used as a context object to clean up connections
connect(this, &Room::fileTransferCompleted, d->fileTransfers[txnId].job,
- [this, txnId](const QString& id, QUrl, const QUrl& mxcUri) {
+ [this, txnId](const QString& id, const QUrl&, const QUrl& mxcUri) {
if (id == txnId) {
auto it = findPendingEvent(txnId);
if (it != d->unsyncedEvents.end()) {
diff --git a/lib/settings.cpp b/lib/settings.cpp
index 5413693d..dd086d9c 100644
--- a/lib/settings.cpp
+++ b/lib/settings.cpp
@@ -53,11 +53,12 @@ bool Settings::contains(const QString& key) const
QStringList Settings::childGroups() const
{
- auto l = QSettings::childGroups();
- for (const auto& g: legacySettings.childGroups())
- if (!l.contains(g))
- l.push_back(g);
- return l;
+ auto groups = QSettings::childGroups();
+ const auto& legacyGroups = legacySettings.childGroups();
+ for (const auto& g: legacyGroups)
+ if (!groups.contains(g))
+ groups.push_back(g);
+ return groups;
}
void SettingsGroup::setValue(const QString& key, const QVariant& value)