[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:29:39 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=3103bd0
The following commit has been merged in the master branch:
commit 3103bd0c5a5905922fcc5c32d87fe9949809087a
Author: David Kahles <david.kahles96 at gmail.com>
Date: Fri Apr 1 15:01:42 2016 +0200
Improve filtering of devices in the DevicesModel
We need to remove devices from the model if the filter doesn't match, to
prevent listing disconnected devices in the plasmoid.
REVIEW: 127610
---
interfaces/devicesmodel.cpp | 37 +++++++++++++++++++++++++------------
interfaces/devicesmodel.h | 8 ++++++--
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp
index af192c8..0bf7815 100644
--- a/interfaces/devicesmodel.cpp
+++ b/interfaces/devicesmodel.cpp
@@ -102,10 +102,7 @@ void DevicesModel::deviceAdded(const QString& id)
DeviceDbusInterface* dev = new DeviceDbusInterface(id, this);
Q_ASSERT(dev->isValid());
- bool onlyPaired = (m_displayFilter & StatusFilterFlag::Paired);
- bool onlyReachable = (m_displayFilter & StatusFilterFlag::Reachable);
-
- if ((onlyReachable && !dev->isReachable()) || (onlyPaired && !dev->isPaired())) {
+ if (! passesFilter(dev)) {
delete dev;
return;
}
@@ -127,21 +124,29 @@ void DevicesModel::deviceRemoved(const QString& id)
void DevicesModel::deviceUpdated(const QString& id, bool isVisible)
{
+ Q_UNUSED(isVisible);
int row = rowForDevice(id);
- if (row < 0 && isVisible) {
+ if (row < 0) {
// FIXME: when m_dbusInterface is not valid refreshDeviceList() does
// nothing and we can miss some devices.
// Someone can reproduce this problem by restarting kdeconnectd while
// kdeconnect's plasmoid is still running.
- qCDebug(KDECONNECT_INTERFACES) << "Adding missing device" << id;
+ // Another reason for this branch is that we removed the device previously
+ // because of the filter settings.
+ qCDebug(KDECONNECT_INTERFACES) << "Adding missing or previously removed device" << id;
deviceAdded(id);
- row = rowForDevice(id);
- }
-
- if (row >= 0) {
- const QModelIndex idx = index(row);
- Q_EMIT dataChanged(idx, idx);
+ } else {
+ DeviceDbusInterface *dev = getDevice(row);
+ if (! passesFilter(dev)) {
+ beginRemoveRows(QModelIndex(), row, row);
+ delete m_deviceList.takeAt(row);
+ endRemoveRows();
+ qCDebug(KDECONNECT_INTERFACES) << "Removed changed device " << id;
+ } else {
+ const QModelIndex idx = index(row);
+ Q_EMIT dataChanged(idx, idx);
+ }
}
}
@@ -295,3 +300,11 @@ int DevicesModel::rowCount(const QModelIndex& parent) const
return m_deviceList.size();
}
+
+bool DevicesModel::passesFilter(DeviceDbusInterface* dev) const
+{
+ bool onlyPaired = (m_displayFilter & StatusFilterFlag::Paired);
+ bool onlyReachable = (m_displayFilter & StatusFilterFlag::Reachable);
+
+ return !((onlyReachable && !dev->isReachable()) || (onlyPaired && !dev->isPaired()));
+}
diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h
index 283a41d..fce91f8 100644
--- a/interfaces/devicesmodel.h
+++ b/interfaces/devicesmodel.h
@@ -48,10 +48,13 @@ public:
DeviceRole
};
Q_ENUMS(ModelRoles);
+
+ // A device is always paired or reachable or both
+ // You can combine the Paired and Reachable flags
enum StatusFilterFlag {
NoFilter = 0x00,
- Paired = 0x01,
- Reachable = 0x02
+ Paired = 0x01, // show device only if it's paired
+ Reachable = 0x02 // show device only if it's reachable
};
Q_DECLARE_FLAGS(StatusFilterFlags, StatusFilterFlag)
Q_FLAGS(StatusFilterFlags)
@@ -84,6 +87,7 @@ private:
int rowForDevice(const QString& id) const;
void clearDevices();
void appendDevice(DeviceDbusInterface* dev);
+ bool passesFilter(DeviceDbusInterface *dev) const;
DaemonDbusInterface* m_dbusInterface;
QVector<DeviceDbusInterface*> m_deviceList;
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list