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.cpp13
4 files changed, 15 insertions, 11 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 4530d95a..d32c7472 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -930,7 +930,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)) {
@@ -1231,7 +1231,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());
}));
@@ -1296,7 +1296,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 b925918e..3618f284 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 6b2b7b23..90dca127 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);
@@ -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()) {