aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/accountregistry.h25
-rw-r--r--lib/avatar.cpp8
-rw-r--r--lib/connection.cpp4
-rw-r--r--lib/room.cpp4
4 files changed, 21 insertions, 20 deletions
diff --git a/lib/accountregistry.h b/lib/accountregistry.h
index 38cfe6c6..9560688e 100644
--- a/lib/accountregistry.h
+++ b/lib/accountregistry.h
@@ -31,8 +31,9 @@ class QUOTIENT_API AccountRegistry : public QAbstractListModel,
/// Can be used to inform the user or to show a login screen if size() == 0 and no accounts are loaded
Q_PROPERTY(QStringList accountsLoading READ accountsLoading NOTIFY accountsLoadingChanged)
public:
- using const_iterator = QVector::const_iterator;
- using const_reference = QVector::const_reference;
+ using vector_t = QVector<Connection*>;
+ using const_iterator = vector_t::const_iterator;
+ using const_reference = vector_t::const_reference;
enum EventRoles {
AccountRole = Qt::UserRole + 1,
@@ -42,24 +43,24 @@ public:
[[deprecated("Use Accounts variable instead")]] //
static AccountRegistry& instance();
- // Expose most of QVector's const-API but only provide add() and drop()
+ // Expose most of vector_t's const-API but only provide add() and drop()
// for changing it. In theory other changing operations could be supported
// too; but then boilerplate begin/end*() calls has to be tucked into each
// and this class gives no guarantees on the order of entries, so why care.
- const QVector<Connection*>& accounts() const { return *this; }
+ const vector_t& accounts() const { return *this; }
void add(Connection* a);
void drop(Connection* a);
- const_iterator begin() const { return QVector::begin(); }
- const_iterator end() const { return QVector::end(); }
- const_reference front() const { return QVector::front(); }
- const_reference back() const { return QVector::back(); }
+ const_iterator begin() const { return vector_t::begin(); }
+ const_iterator end() const { return vector_t::end(); }
+ const_reference front() const { return vector_t::front(); }
+ const_reference back() const { return vector_t::back(); }
bool isLoggedIn(const QString& userId) const;
Connection* get(const QString& userId);
- using QVector::isEmpty, QVector::empty;
- using QVector::size, QVector::count, QVector::capacity;
- using QVector::cbegin, QVector::cend, QVector::contains;
+ using vector_t::isEmpty, vector_t::empty;
+ using vector_t::size, vector_t::count, vector_t::capacity;
+ using vector_t::cbegin, vector_t::cend, vector_t::contains;
// QAbstractItemModel interface implementation
@@ -88,4 +89,4 @@ private:
inline QUOTIENT_API AccountRegistry Accounts {};
inline AccountRegistry& AccountRegistry::instance() { return Accounts; }
-}
+} // namespace Quotient
diff --git a/lib/avatar.cpp b/lib/avatar.cpp
index 9304a3de..13de99bf 100644
--- a/lib/avatar.cpp
+++ b/lib/avatar.cpp
@@ -39,7 +39,7 @@ public:
// The below are related to image caching, hence mutable
mutable QImage _originalImage;
- mutable std::vector<QPair<QSize, QImage>> _scaledImages;
+ mutable std::vector<std::pair<QSize, QImage>> _scaledImages;
mutable QSize _requestedSize;
mutable enum { Unknown, Cache, Network, Banned } _imageSource = Unknown;
mutable QPointer<MediaThumbnailJob> _thumbnailRequest = nullptr;
@@ -124,9 +124,9 @@ QImage Avatar::Private::get(Connection* connection, QSize size,
});
}
- for (const auto& p : _scaledImages)
- if (p.first == size)
- return p.second;
+ for (const auto& [scaledSize, scaledImage] : _scaledImages)
+ if (scaledSize == size)
+ return scaledImage;
auto result = _originalImage.isNull()
? QImage()
: _originalImage.scaled(size, Qt::KeepAspectRatio,
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 3e44513b..c390cc05 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -92,7 +92,7 @@ public:
// state is Invited. The spec mandates to keep Invited room state
// separately; specifically, we should keep objects for Invite and
// Leave state of the same room if the two happen to co-exist.
- QHash<QPair<QString, bool>, Room*> roomMap;
+ QHash<std::pair<QString, bool>, Room*> roomMap;
/// Mapping from serverparts to alias/room id mappings,
/// as of the last sync
QHash<QString, QString> roomAliasMap;
@@ -1707,7 +1707,7 @@ Room* Connection::provideRoom(const QString& id, Omittable<JoinState> joinState)
Q_ASSERT_X(!id.isEmpty(), __FUNCTION__, "Empty room id");
// If joinState is empty, all joinState == comparisons below are false.
- const auto roomKey = qMakePair(id, joinState == JoinState::Invite);
+ const std::pair roomKey { id, joinState == JoinState::Invite };
auto* room = d->roomMap.value(roomKey, nullptr);
if (room) {
// Leave is a special case because in transition (5a) (see the .h file)
diff --git a/lib/room.cpp b/lib/room.cpp
index 284d19df..f692c354 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -118,7 +118,7 @@ public:
// A map from evtId to a map of relation type to a vector of event
// pointers. Not using QMultiHash, because we want to quickly return
// a number of relations for a given event without enumerating them.
- QHash<QPair<QString, QString>, RelatedEvents> relations;
+ QHash<std::pair<QString, QString>, RelatedEvents> relations;
QString displayname;
Avatar avatar;
QHash<QString, Notification> notifications;
@@ -2687,7 +2687,7 @@ bool Room::Private::processRedaction(const RedactionEvent& redaction)
}
if (const auto* reaction = eventCast<ReactionEvent>(oldEvent)) {
const auto& targetEvtId = reaction->relation().eventId;
- const QPair lookupKey { targetEvtId, EventRelation::AnnotationType };
+ const std::pair lookupKey { targetEvtId, EventRelation::AnnotationType };
if (relations.contains(lookupKey)) {
relations[lookupKey].removeOne(reaction);
emit q->updatedEvent(targetEvtId);