Pass arguments as const-reference

This commit is contained in:
Aleix Pol 2015-09-12 09:45:59 +02:00
parent 4a8303f846
commit 4730022810
12 changed files with 30 additions and 30 deletions

View file

@ -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();

View file

@ -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<QIODevice> getPayload();

View file

@ -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;
};

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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:

View file

@ -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);

View file

@ -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();

View file

@ -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());

View file

@ -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;
}

View file

@ -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);