[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:29:03 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=95f01c4

The following commit has been merged in the master branch:
commit 95f01c4beac836697d602902a6c446ade48d79ff
Author: Aleix Pol <aleixpol at kde.org>
Date:   Fri Sep 11 12:34:52 2015 +0200

    Use C++ for setting the default argument
---
 core/default_args.h               | 61 ---------------------------------------
 core/device.cpp                   |  4 +--
 core/kdeconnectpluginconfig.h     |  3 +-
 core/networkpackage.h             |  3 +-
 plugins/battery/batteryplugin.cpp |  4 +--
 tests/networkpackagetests.cpp     |  2 +-
 6 files changed, 7 insertions(+), 70 deletions(-)

diff --git a/core/default_args.h b/core/default_args.h
deleted file mode 100644
index d198c6f..0000000
--- a/core/default_args.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License or (at your option) version 3 or any later version
- * accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
- * defined in Section 14 of version 3 of the license.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DEFAULTARG_H
-#define DEFAULTARG_H
-
-#include <QString>
-
-template<class T>
-struct default_arg {
-    static T get(); //Not defined for any other value
-};
-
-//bool -> false
-template<>
-struct default_arg<bool> {
-    static bool get() { return false; }
-};
-
-//int -> -1
-template<>
-struct default_arg<int> {
-    static int get() { return -1; }
-};
-
-//QByteArray-> empty qbytearray
-template<>
-struct default_arg<QByteArray> {
-    static QByteArray get() { return QByteArray(); }
-};
-
-//QStrings -> empty string
-template<>
-struct default_arg<QString> {
-    static QString get() { return QString(); }
-};
-
-template<class T>
-struct default_arg<T*> {
-    static T* get() { return NULL;}
-};
-
-
-#endif // DEFAULTARG_H
diff --git a/core/device.cpp b/core/device.cpp
index 4a222e1..a820696 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -73,7 +73,7 @@ Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLin
     , m_deviceName(identityPackage.get<QString>("deviceName"))
     , m_deviceType(str2type(identityPackage.get<QString>("deviceType")))
     , m_pairStatus(Device::NotPaired)
-    , m_protocolVersion(identityPackage.get<int>("protocolVersion"))
+    , m_protocolVersion(identityPackage.get<int>("protocolVersion", -1))
 {
     addLink(identityPackage, dl);
 
@@ -272,7 +272,7 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
 {
     //qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider();
 
-    m_protocolVersion = identityPackage.get<int>("protocolVersion");
+    m_protocolVersion = identityPackage.get<int>("protocolVersion", -1);
     if (m_protocolVersion != NetworkPackage::ProtocolVersion) {
         qCWarning(KDECONNECT_CORE) << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPackage::ProtocolVersion;
     }
diff --git a/core/kdeconnectpluginconfig.h b/core/kdeconnectpluginconfig.h
index 96195e4..8e047d0 100644
--- a/core/kdeconnectpluginconfig.h
+++ b/core/kdeconnectpluginconfig.h
@@ -26,7 +26,6 @@
 #include <QStringList>
 #include <QVariant>
 
-#include "default_args.h"
 #include "kdeconnectcore_export.h"
 
 struct KdeConnectPluginConfigPrivate;
@@ -56,7 +55,7 @@ public:
     /**
      * Convenience method that will convert the QVariant to whatever type for you
      */
-    template<typename T> T get(const QString& key, const T& defaultValue = default_arg<T>::get()) {
+    template<typename T> T get(const QString& key, const T& defaultValue = {}) {
         return get(key, QVariant(defaultValue)).template value<T>(); //Important note: Awesome template syntax is awesome
     }
 
diff --git a/core/networkpackage.h b/core/networkpackage.h
index 29549e5..49dfeb6 100644
--- a/core/networkpackage.h
+++ b/core/networkpackage.h
@@ -33,7 +33,6 @@
 #include <QUrl>
 
 #include "kdeconnectcore_export.h"
-#include "default_args.h"
 
 class FileTransferJob;
 
@@ -69,7 +68,7 @@ public:
     const QVariantMap& body() const { return mBody; }
 
     //Get and set info from body. Note that id and type can not be accessed through these.
-    template<typename T> T get(const QString& key, const T& defaultValue = default_arg<T>::get()) const {
+    template<typename T> T get(const QString& key, const T& defaultValue = {}) const {
         return mBody.value(key,defaultValue).template value<T>(); //Important note: Awesome template syntax is awesome
     }
     template<typename T> void set(const QString& key, const T& value) { mBody[key] = QVariant(value); }
diff --git a/plugins/battery/batteryplugin.cpp b/plugins/battery/batteryplugin.cpp
index 700f25d..32cf089 100644
--- a/plugins/battery/batteryplugin.cpp
+++ b/plugins/battery/batteryplugin.cpp
@@ -61,8 +61,8 @@ BatteryPlugin::~BatteryPlugin()
 
 bool BatteryPlugin::receivePackage(const NetworkPackage& np)
 {
-    bool isCharging = np.get<bool>("isCharging");
-    int currentCharge = np.get<int>("currentCharge");
+    bool isCharging = np.get<bool>("isCharging", false);
+    int currentCharge = np.get<int>("currentCharge", -1);
     int thresholdEvent = np.get<int>("thresholdEvent", (int)ThresholdNone);
 
     if (batteryDbusInterface->charge() != currentCharge
diff --git a/tests/networkpackagetests.cpp b/tests/networkpackagetests.cpp
index d7079b4..cb40506 100644
--- a/tests/networkpackagetests.cpp
+++ b/tests/networkpackagetests.cpp
@@ -84,7 +84,7 @@ void NetworkPackageTests::networkPackageIdentityTest()
     NetworkPackage np("");
     NetworkPackage::createIdentityPackage(&np);
 
-    QCOMPARE( np.get<int>("protocolVersion") , NetworkPackage::ProtocolVersion );
+    QCOMPARE( np.get<int>("protocolVersion", -1) , NetworkPackage::ProtocolVersion );
     QCOMPARE( np.type() , PACKAGE_TYPE_IDENTITY );
 
 }

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list