From 4730022810f687816b7e1be48262dd07d7ea4341 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sat, 12 Sep 2015 09:45:59 +0200 Subject: [PATCH] Pass arguments as const-reference --- core/backends/lan/downloadjob.cpp | 2 +- core/backends/lan/downloadjob.h | 2 +- core/backends/lan/netaddress.h | 2 +- core/daemon.cpp | 2 +- core/daemon.h | 2 +- core/device.cpp | 2 +- core/device.h | 2 +- core/kdeconnectconfig.cpp | 10 +++++----- core/kdeconnectconfig.h | 10 +++++----- .../kdeconnectdeclarativeplugin.cpp | 14 +++++++------- plasmoid/declarativeplugin/objectfactory.h | 8 ++++---- plasmoid/declarativeplugin/responsewaiter.h | 4 ++-- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/core/backends/lan/downloadjob.cpp b/core/backends/lan/downloadjob.cpp index bba2e988b..ad7765c71 100644 --- a/core/backends/lan/downloadjob.cpp +++ b/core/backends/lan/downloadjob.cpp @@ -20,7 +20,7 @@ #include "downloadjob.h" -DownloadJob::DownloadJob(QHostAddress address, QVariantMap transferInfo): KJob() +DownloadJob::DownloadJob(const QHostAddress &address, const QVariantMap &transferInfo): KJob() { mAddress = address; mPort = transferInfo["port"].toInt(); diff --git a/core/backends/lan/downloadjob.h b/core/backends/lan/downloadjob.h index 544e33cd4..f5e0d08e1 100644 --- a/core/backends/lan/downloadjob.h +++ b/core/backends/lan/downloadjob.h @@ -34,7 +34,7 @@ class DownloadJob { Q_OBJECT public: - DownloadJob(QHostAddress address, QVariantMap transferInfo); + DownloadJob(const QHostAddress &address, const QVariantMap &transferInfo); virtual void start() override; QSharedPointer getPayload(); diff --git a/core/backends/lan/netaddress.h b/core/backends/lan/netaddress.h index f264ba1b4..6704dbc5d 100644 --- a/core/backends/lan/netaddress.h +++ b/core/backends/lan/netaddress.h @@ -25,7 +25,7 @@ struct NetAddress { NetAddress() { } - NetAddress(QHostAddress _ip, quint16 _port) : ip(_ip), port(_port) { } + NetAddress(const QHostAddress &_ip, quint16 _port) : ip(_ip), port(_port) { } QHostAddress ip; quint16 port; }; diff --git a/core/daemon.cpp b/core/daemon.cpp index 05a5641f3..04218be1b 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -195,7 +195,7 @@ void Daemon::onDeviceStatusChanged() } -void Daemon::setAnnouncedName(QString name) +void Daemon::setAnnouncedName(const QString &name) { qCDebug(KDECONNECT_CORE()) << "Announcing name"; KdeConnectConfig::instance()->setName(name); diff --git a/core/daemon.h b/core/daemon.h index dca3e07d6..e01d3ba41 100644 --- a/core/daemon.h +++ b/core/daemon.h @@ -64,7 +64,7 @@ public Q_SLOTS: ///don't try to turn into Q_PROPERTY, it doesn't work Q_SCRIPTABLE QString announcedName(); - Q_SCRIPTABLE void setAnnouncedName(QString name); + Q_SCRIPTABLE void setAnnouncedName(const QString &name); //Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyPaired = false) const; diff --git a/core/device.cpp b/core/device.cpp index 71c4d0cff..6bcaf4441 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -495,7 +495,7 @@ QStringList Device::availableLinks() const return sl; } -Device::DeviceType Device::str2type(QString deviceType) { +Device::DeviceType Device::str2type(const QString &deviceType) { if (deviceType == "desktop") return Desktop; if (deviceType == "laptop") return Laptop; if (deviceType == "smartphone" || deviceType == "phone") return Phone; diff --git a/core/device.h b/core/device.h index 1291eaeda..f0c9e5141 100644 --- a/core/device.h +++ b/core/device.h @@ -61,7 +61,7 @@ class KDECONNECTCORE_EXPORT Device Phone, Tablet, }; - static DeviceType str2type(QString deviceType); + static DeviceType str2type(const QString &deviceType); static QString type2str(DeviceType deviceType); public: diff --git a/core/kdeconnectconfig.cpp b/core/kdeconnectconfig.cpp index 37f33d599..7ad040d92 100644 --- a/core/kdeconnectconfig.cpp +++ b/core/kdeconnectconfig.cpp @@ -171,7 +171,7 @@ QStringList KdeConnectConfig::trustedDevices() return list; } -void KdeConnectConfig::addTrustedDevice(QString id, QString name, QString type, QString publicKey) +void KdeConnectConfig::addTrustedDevice(const QString &id, const QString &name, const QString &type, const QString &publicKey) { d->config->beginGroup("trustedDevices"); d->config->beginGroup(id); @@ -185,7 +185,7 @@ void KdeConnectConfig::addTrustedDevice(QString id, QString name, QString type, QDir().mkpath(deviceConfigDir(id).path()); } -KdeConnectConfig::DeviceInfo KdeConnectConfig::getTrustedDevice(QString id) +KdeConnectConfig::DeviceInfo KdeConnectConfig::getTrustedDevice(const QString &id) { d->config->beginGroup("trustedDevices"); d->config->beginGroup(id); @@ -200,7 +200,7 @@ KdeConnectConfig::DeviceInfo KdeConnectConfig::getTrustedDevice(QString id) return info; } -void KdeConnectConfig::removeTrustedDevice(QString deviceId) +void KdeConnectConfig::removeTrustedDevice(const QString &deviceId) { d->config->beginGroup("trustedDevices"); d->config->beginGroup(deviceId); @@ -211,13 +211,13 @@ void KdeConnectConfig::removeTrustedDevice(QString deviceId) //We do not remove the config files. } -QDir KdeConnectConfig::deviceConfigDir(QString deviceId) +QDir KdeConnectConfig::deviceConfigDir(const QString &deviceId) { QString deviceConfigPath = baseConfigDir().absoluteFilePath(deviceId); return QDir(deviceConfigPath); } -QDir KdeConnectConfig::pluginConfigDir(QString deviceId, QString pluginName) +QDir KdeConnectConfig::pluginConfigDir(const QString &deviceId, const QString &pluginName) { QString deviceConfigPath = baseConfigDir().absoluteFilePath(deviceId); QString pluginConfigDir = QDir(deviceConfigPath).absoluteFilePath(pluginName); diff --git a/core/kdeconnectconfig.h b/core/kdeconnectconfig.h index af6c6dfcd..76e25a41f 100644 --- a/core/kdeconnectconfig.h +++ b/core/kdeconnectconfig.h @@ -56,16 +56,16 @@ public: */ QStringList trustedDevices(); //list of ids - void removeTrustedDevice(QString id); - void addTrustedDevice(QString id, QString name, QString type, QString publicKey); - KdeConnectConfig::DeviceInfo getTrustedDevice(QString id); + void removeTrustedDevice(const QString &id); + void addTrustedDevice(const QString &id, const QString &name, const QString &type, const QString &publicKey); + KdeConnectConfig::DeviceInfo getTrustedDevice(const QString &id); /* * Paths for config files, there is no guarantee the directories already exist */ QDir baseConfigDir(); - QDir deviceConfigDir(QString deviceId); - QDir pluginConfigDir(QString deviceId, QString pluginName); //Used by KdeConnectPluginConfig + QDir deviceConfigDir(const QString &deviceId); + QDir pluginConfigDir(const QString &deviceId, const QString &pluginName); //Used by KdeConnectPluginConfig private: KdeConnectConfig(); diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp index d64239f23..aec6be43a 100644 --- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp +++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp @@ -34,37 +34,37 @@ #include "interfaces/devicesmodel.h" #include "interfaces/notificationsmodel.h" -QObject* createDeviceDbusInterface(QVariant deviceId) +QObject* createDeviceDbusInterface(const QVariant &deviceId) { return new DeviceDbusInterface(deviceId.toString()); } -QObject* createDeviceBatteryDbusInterface(QVariant deviceId) +QObject* createDeviceBatteryDbusInterface(const QVariant &deviceId) { return new DeviceBatteryDbusInterface(deviceId.toString()); } -QObject* createFindMyPhoneInterface(QVariant deviceId) +QObject* createFindMyPhoneInterface(const QVariant &deviceId) { return new FindMyPhoneDeviceDbusInterface(deviceId.toString()); } -QObject* createSftpInterface(QVariant deviceId) +QObject* createSftpInterface(const QVariant &deviceId) { return new SftpDbusInterface(deviceId.toString()); } -QObject* createRemoteControlInterface(QVariant deviceId) +QObject* createRemoteControlInterface(const QVariant &deviceId) { return new RemoteControlDbusInterface(deviceId.toString()); } -QObject* createMprisInterface(QVariant deviceId) +QObject* createMprisInterface(const QVariant &deviceId) { return new MprisDbusInterface(deviceId.toString()); } -QObject* createDeviceLockInterface(QVariant deviceId) +QObject* createDeviceLockInterface(const QVariant &deviceId) { Q_ASSERT(!deviceId.toString().isEmpty()); return new LockDeviceDbusInterface(deviceId.toString()); diff --git a/plasmoid/declarativeplugin/objectfactory.h b/plasmoid/declarativeplugin/objectfactory.h index f64504729..075f08b34 100644 --- a/plasmoid/declarativeplugin/objectfactory.h +++ b/plasmoid/declarativeplugin/objectfactory.h @@ -11,8 +11,8 @@ class ObjectFactory : public QObject Q_OBJECT typedef QObject* (*Func0)(); - typedef QObject* (*Func1)(QVariant); - typedef QObject* (*Func2)(QVariant, QVariant); + typedef QObject* (*Func1)(const QVariant&); + typedef QObject* (*Func2)(const QVariant&, const QVariant&); public: ObjectFactory(QObject* parent, Func0 f0) : QObject(parent), m_f0(f0), m_f1(nullptr), m_f2(nullptr) {} @@ -26,12 +26,12 @@ public: if (m_f0) return m_f0(); return nullptr; } - Q_INVOKABLE QObject* create(QVariant arg1) { + Q_INVOKABLE QObject* create(const QVariant &arg1) { if (m_f1) return m_f1(arg1); return nullptr; } - Q_INVOKABLE QObject* create(QVariant arg1, QVariant arg2) { + Q_INVOKABLE QObject* create(const QVariant &arg1, const QVariant &arg2) { if (m_f2) return m_f2(arg1, arg2); return nullptr; } diff --git a/plasmoid/declarativeplugin/responsewaiter.h b/plasmoid/declarativeplugin/responsewaiter.h index e85b41855..8b0ddf180 100644 --- a/plasmoid/declarativeplugin/responsewaiter.h +++ b/plasmoid/declarativeplugin/responsewaiter.h @@ -45,8 +45,8 @@ public: bool autodelete() const {return m_autodelete;} Q_SIGNALS: - void success(QVariant result); - void error(QString message); + void success(const QVariant &result); + void error(const QString &message); private Q_SLOTS: void onCallFinished(QDBusPendingCallWatcher* watcher);