[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=b99cba1
The following commit has been merged in the master branch:
commit b99cba1949ca45f1760dd5c074c57a4fdaecfbe8
Author: Aleix Pol <aleixpol at kde.org>
Date: Sat Mar 14 03:40:01 2015 +0100
Make the DevicesModel::deviceAdded code more robust
If deviceAdded is reported even though it's already in the model, don't
add it twice.
---
interfaces/devicesmodel.cpp | 24 +++++++++++++++++++++---
interfaces/devicesmodel.h | 1 +
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp
index 228e82e..bb2d947 100644
--- a/interfaces/devicesmodel.cpp
+++ b/interfaces/devicesmodel.cpp
@@ -65,11 +65,29 @@ DevicesModel::~DevicesModel()
{
}
+int DevicesModel::rowForDeviceId(const QString& id) const
+{
+ QVector<DeviceDbusInterface*>::const_iterator it = m_deviceList.constBegin(), itEnd = m_deviceList.constEnd();
+ for (int i = 0; it!=itEnd; ++it, ++i) {
+ if ((*it)->id() == id) {
+ return i;
+ }
+ }
+ return -1;
+}
+
void DevicesModel::deviceAdded(const QString& id)
{
- beginInsertRows(QModelIndex(), m_deviceList.count(), m_deviceList.count());
- m_deviceList.append(new DeviceDbusInterface(id, this));
- endInsertRows();
+ //Find whether the device already exists. if so, just report it as modified
+ int row = rowForDeviceId(id);
+ if (row>=0) {
+ const QModelIndex idx = index(row, 0);
+ Q_EMIT dataChanged(idx, idx);
+ } else {
+ beginInsertRows(QModelIndex(), m_deviceList.count(), m_deviceList.count());
+ m_deviceList.append(new DeviceDbusInterface(id, this));
+ endInsertRows();
+ }
}
void DevicesModel::deviceRemoved(const QString& id)
diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h
index 009f5b1..001bb4d 100644
--- a/interfaces/devicesmodel.h
+++ b/interfaces/devicesmodel.h
@@ -81,6 +81,7 @@ Q_SIGNALS:
private:
void clearDevices();
+ int rowForDeviceId(const QString& id) const;
DaemonDbusInterface* m_dbusInterface;
QVector<DeviceDbusInterface*> m_deviceList;
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list