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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:28:20 UTC 2016


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

The following commit has been merged in the master branch:
commit 6fe7a9b15890947a104378c88c142bc47485ddc0
Author: Aleix Pol <aleixpol at kde.org>
Date:   Sat Mar 14 04:28:54 2015 +0100

    Make it possible for the DevicesModel to react to device name changes
---
 core/device.cpp             | 10 +++++++++-
 core/device.h               |  5 ++++-
 interfaces/devicesmodel.cpp | 19 +++++++++++++++++--
 interfaces/devicesmodel.h   |  2 ++
 4 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/core/device.cpp b/core/device.cpp
index 780d9e0..85d4134 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -255,7 +255,7 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
     m_deviceLinks.append(link);
 
     //re-read the device name from the identityPackage because it could have changed
-    m_deviceName = identityPackage.get<QString>("deviceName");
+    setName(identityPackage.get<QString>("deviceName"));
     m_deviceType = str2type(identityPackage.get<QString>("deviceType"));
 
     //Theoretically we will never add two links from the same provider (the provider should destroy
@@ -497,3 +497,11 @@ QString Device::iconName() const
     }
     return QString();
 }
+
+void Device::setName(const QString &name)
+{
+    if (m_deviceName != name) {
+        m_deviceName = name;
+        Q_EMIT nameChanged(name);
+    }
+}
diff --git a/core/device.h b/core/device.h
index 367c198..a0c9729 100644
--- a/core/device.h
+++ b/core/device.h
@@ -41,7 +41,7 @@ class KDECONNECTCORE_EXPORT Device
     Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device")
     Q_PROPERTY(QString id READ id CONSTANT)
     Q_PROPERTY(QString iconName READ iconName CONSTANT)
-    Q_PROPERTY(QString name READ name)
+    Q_PROPERTY(QString name READ name NOTIFY nameChanged)
     Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableStatusChanged)
 
     enum PairStatus {
@@ -121,8 +121,11 @@ Q_SIGNALS:
     Q_SCRIPTABLE void pairingSuccesful();
     Q_SCRIPTABLE void pairingFailed(const QString& error);
     Q_SCRIPTABLE void unpaired();
+    Q_SCRIPTABLE void nameChanged(const QString& name);
 
 private:
+    void setName(const QString &name);
+
     const QString m_deviceId;
     QString m_deviceName;
     DeviceType m_deviceType;
diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp
index 9401774..028497e 100644
--- a/interfaces/devicesmodel.cpp
+++ b/interfaces/devicesmodel.cpp
@@ -85,7 +85,7 @@ void DevicesModel::deviceAdded(const QString& id)
         Q_EMIT dataChanged(idx, idx);
     } else {
         beginInsertRows(QModelIndex(), m_deviceList.count(), m_deviceList.count());
-        m_deviceList.append(new DeviceDbusInterface(id, this));
+        appendDevice(id);
         endInsertRows();
     }
 }
@@ -152,11 +152,26 @@ void DevicesModel::receivedDeviceList(QDBusPendingCallWatcher* watcher)
 
     beginInsertRows(QModelIndex(), 0, deviceIds.count()-1);
     Q_FOREACH(const QString& id, deviceIds) {
-        m_deviceList.append(new DeviceDbusInterface(id, this));
+        appendDevice(id);
     }
     endInsertRows();
 }
 
+void DevicesModel::appendDevice(const QString& id)
+{
+    DeviceDbusInterface* dev = new DeviceDbusInterface(id, this);
+    m_deviceList.append(dev);
+    connect(dev, SIGNAL(nameChanged(QString)), SLOT(nameChanged(QString)));
+}
+
+void DevicesModel::nameChanged(const QString& newName)
+{
+    int row = m_deviceList.indexOf(static_cast<DeviceDbusInterface*>(sender()));
+    Q_ASSERT(row>=0);
+    const QModelIndex idx = index(row, 0);
+    Q_EMIT dataChanged(idx, idx);
+}
+
 void DevicesModel::clearDevices()
 {
     if (!m_deviceList.isEmpty()) {
diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h
index 001bb4d..0923cf3 100644
--- a/interfaces/devicesmodel.h
+++ b/interfaces/devicesmodel.h
@@ -75,6 +75,7 @@ private Q_SLOTS:
     void deviceRemoved(const QString& id);
     void refreshDeviceList();
     void receivedDeviceList(QDBusPendingCallWatcher* watcher);
+    void nameChanged(const QString& newName);
 
 Q_SIGNALS:
     void rowsChanged();
@@ -82,6 +83,7 @@ Q_SIGNALS:
 private:
     void clearDevices();
     int rowForDeviceId(const QString& id) const;
+    void appendDevice(const QString& id);
 
     DaemonDbusInterface* m_dbusInterface;
     QVector<DeviceDbusInterface*> m_deviceList;

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list