From 3e0ca5db7698d59c6f2e9e7ae3a3a1654641eb4e Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sun, 26 Dec 2021 10:38:49 +0100 Subject: EventItem::setUserData: use std::move Fixes a clang-tidy warning. --- lib/eventitem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/eventitem.h b/lib/eventitem.h index 0ab1a01d..b411a90c 100644 --- a/lib/eventitem.h +++ b/lib/eventitem.h @@ -57,7 +57,7 @@ public: } /// Store arbitrary data with the event item - void setUserData(std::any userData) { data = userData; } + void setUserData(std::any userData) { data = std::move(userData); } /// Obtain custom data previously stored with the event item const std::any& userdata() const { return data; } std::any& userData() { return data; } -- cgit v1.2.3 From 5f4d9ef6df492bfd91fa7c48fb4d5f8c2afc40b2 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 27 Dec 2021 20:14:07 +0100 Subject: EventFactory: remove default constructor This is a leftover from deferred `name` initialisation that wasn't needed in the end. --- lib/events/event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/events/event.h b/lib/events/event.h index 8f62872d..8347bb4f 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -146,7 +146,7 @@ namespace _impl { // Actual makeIfMatches specialisations will differ in the first // template parameter but that doesn't affect the function type public: - explicit EventFactory(const char* name = "") + explicit EventFactory(const char* name) : name(name) { static auto yetToBeConstructed = true; -- cgit v1.2.3 From 7bb59b7a4a8b8804fa1eb5e631463da6a6cfdf84 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 28 Dec 2021 08:33:56 +0100 Subject: Convert struct LoginFlows to namespace Because that's what it really is. --- lib/connection.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/connection.h b/lib/connection.h index 0713af16..45abb8ed 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -51,11 +51,11 @@ class LeaveRoomJob; using LoginFlow = GetLoginFlowsJob::LoginFlow; /// Predefined login flows -struct LoginFlows { - static inline const LoginFlow Password { "m.login.password" }; - static inline const LoginFlow SSO { "m.login.sso" }; - static inline const LoginFlow Token { "m.login.token" }; -}; +namespace LoginFlows { + inline const LoginFlow Password { "m.login.password" }; + inline const LoginFlow SSO { "m.login.sso" }; + inline const LoginFlow Token { "m.login.token" }; +} // To simplify comparisons of LoginFlows -- cgit v1.2.3 From 0d9428bfbd997ac2073a470e59749cda81e0b213 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 28 Dec 2021 09:01:37 +0100 Subject: Settings classes: unify on QUO_ macro prefix At some point macros were prepended with QTNT (pronounced "cute-n't", "Quotient" with vowels dropped) but that didn't go very far. Having forgotten about this, I introduced QUO prefix in a few places. Being initial letters of "Quotient", QUO feels more understandable (and coincidentally is a well-known Latin word); so let's unify on this. --- lib/networksettings.cpp | 6 +++--- lib/networksettings.h | 6 +++--- lib/settings.cpp | 6 +++--- lib/settings.h | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/networksettings.cpp b/lib/networksettings.cpp index ce46ce5f..06b1fdf9 100644 --- a/lib/networksettings.cpp +++ b/lib/networksettings.cpp @@ -11,9 +11,9 @@ void NetworkSettings::setupApplicationProxy() const { proxyType(), proxyHostName(), proxyPort() }); } -QTNT_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType, +QUO_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType, "proxy_type", QNetworkProxy::DefaultProxy, setProxyType) -QTNT_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname", +QUO_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname", {}, setProxyHostName) -QTNT_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1, +QUO_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1, setProxyPort) diff --git a/lib/networksettings.h b/lib/networksettings.h index df11a9c8..b83a0e15 100644 --- a/lib/networksettings.h +++ b/lib/networksettings.h @@ -12,9 +12,9 @@ Q_DECLARE_METATYPE(QNetworkProxy::ProxyType) namespace Quotient { class NetworkSettings : public SettingsGroup { Q_OBJECT - QTNT_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType) - QTNT_DECLARE_SETTING(QString, proxyHostName, setProxyHostName) - QTNT_DECLARE_SETTING(quint16, proxyPort, setProxyPort) + QUO_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType) + QUO_DECLARE_SETTING(QString, proxyHostName, setProxyHostName) + QUO_DECLARE_SETTING(quint16, proxyPort, setProxyPort) Q_PROPERTY(QString proxyHost READ proxyHostName WRITE setProxyHostName) public: template diff --git a/lib/settings.cpp b/lib/settings.cpp index ed9082b0..5549e4de 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -102,11 +102,11 @@ void SettingsGroup::remove(const QString& key) Settings::remove(fullKey); } -QTNT_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {}, +QUO_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {}, setDeviceId) -QTNT_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {}, +QUO_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {}, setDeviceName) -QTNT_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false, +QUO_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false, setKeepLoggedIn) static const auto HomeserverKey = QStringLiteral("homeserver"); diff --git a/lib/settings.h b/lib/settings.h index efd0d714..3cab8958 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -104,7 +104,7 @@ private: QString groupPath; }; -#define QTNT_DECLARE_SETTING(type, propname, setter) \ +#define QUO_DECLARE_SETTING(type, propname, setter) \ Q_PROPERTY(type propname READ propname WRITE setter) \ public: \ type propname() const; \ @@ -112,7 +112,7 @@ public: \ \ private: -#define QTNT_DEFINE_SETTING(classname, type, propname, qsettingname, \ +#define QUO_DEFINE_SETTING(classname, type, propname, qsettingname, \ defaultValue, setter) \ type classname::propname() const \ { \ @@ -127,9 +127,9 @@ private: class AccountSettings : public SettingsGroup { Q_OBJECT Q_PROPERTY(QString userId READ userId CONSTANT) - QTNT_DECLARE_SETTING(QString, deviceId, setDeviceId) - QTNT_DECLARE_SETTING(QString, deviceName, setDeviceName) - QTNT_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn) + QUO_DECLARE_SETTING(QString, deviceId, setDeviceId) + QUO_DECLARE_SETTING(QString, deviceName, setDeviceName) + QUO_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn) Q_PROPERTY(QByteArray encryptionAccountPickle READ encryptionAccountPickle WRITE setEncryptionAccountPickle) public: -- cgit v1.2.3 From 418b85c285fa0a0c196a26eef5cc0c9c3dbe20fe Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 28 Dec 2021 09:07:37 +0100 Subject: EventContent::FileInfo: default payloadSize to 0 Fixes a clang-tidy warning. --- lib/events/eventcontent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index f609a603..f6dbd4bf 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -105,7 +105,7 @@ namespace EventContent { QJsonObject originalInfoJson; QMimeType mimeType; QUrl url; - qint64 payloadSize; + qint64 payloadSize = 0; QString originalName; Omittable file = none; }; -- cgit v1.2.3