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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:26:50 UTC 2016


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

The following commit has been merged in the master branch:
commit 802bb26a2c7023cc4231039a78fdeff6837a9eb2
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Wed Aug 28 19:33:46 2013 +0200

    Fixed Q_ASSERT in model.
    
    + small change to the dimsiss buttons of the plasmoid
---
 libkdeconnect/devicesmodel.cpp                  | 26 ++++++++--------
 libkdeconnect/notificationsmodel.cpp            | 41 ++++++++++++++++++-------
 libkdeconnect/notificationsmodel.h              |  6 +++-
 plasmoid/package/contents/ui/DeviceDelegate.qml |  8 +++--
 4 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/libkdeconnect/devicesmodel.cpp b/libkdeconnect/devicesmodel.cpp
index c978695..1fc81ec 100644
--- a/libkdeconnect/devicesmodel.cpp
+++ b/libkdeconnect/devicesmodel.cpp
@@ -28,8 +28,6 @@
 #include <KConfigGroup>
 #include <KIcon>
 
-bool fetchNotifications = true;
-
 DevicesModel::DevicesModel(QObject *parent)
     : QAbstractListModel(parent)
     , m_dbusInterface(new DaemonDbusInterface(this))
@@ -103,7 +101,7 @@ void DevicesModel::setDisplayFilter(DevicesModel::StatusFlags flags)
 void DevicesModel::refreshDeviceList()
 {
 
-    if (m_deviceList.count() > 0) {
+    if (!m_deviceList.isEmpty()) {
         beginRemoveRows(QModelIndex(), 0, m_deviceList.size() - 1);
         m_deviceList.clear();
         endRemoveRows();
@@ -113,11 +111,12 @@ void DevicesModel::refreshDeviceList()
         return;
     }
 
-    QDBusPendingReply<QStringList> deviceIds = m_dbusInterface->devices();
-    deviceIds.waitForFinished();
-    if (deviceIds.isError()) return;
+    QDBusPendingReply<QStringList> pendingDeviceIds = m_dbusInterface->devices();
+    pendingDeviceIds.waitForFinished();
+    if (pendingDeviceIds.isError()) return;
+    const QStringList& deviceIds = pendingDeviceIds.value();
 
-    Q_FOREACH(const QString& id, deviceIds.value()) {
+    Q_FOREACH(const QString& id, deviceIds) {
 
         DeviceDbusInterface* deviceDbusInterface = new DeviceDbusInterface(id,this);
 
@@ -126,15 +125,16 @@ void DevicesModel::refreshDeviceList()
         bool onlyReachable = (m_displayFilter & StatusReachable);
         if (onlyReachable && !deviceDbusInterface->reachable()) continue;
 
-        beginInsertRows(QModelIndex(), rowCount(), rowCount());
+        int firstRow = m_deviceList.size();
+        int lastRow = firstRow;
+
+        beginInsertRows(QModelIndex(), firstRow, lastRow);
         m_deviceList.append(deviceDbusInterface);
         endInsertRows();
 
     }
 
-
-
-    Q_EMIT dataChanged(index(0), index(deviceIds.count()));
+    Q_EMIT dataChanged(index(0), index(m_deviceList.size()));
 
 }
 
@@ -143,7 +143,7 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
     if (!m_dbusInterface->isValid()
         || !index.isValid()
         || index.row() < 0
-        || index.row() >= m_deviceList.count()
+        || index.row() >= m_deviceList.size()
         || !m_deviceList[index.row()]->isValid())
     {
         return QVariant();
@@ -199,6 +199,6 @@ int DevicesModel::rowCount(const QModelIndex &parent) const
         return 0;
     }
 
-    return m_deviceList.count();
+    return m_deviceList.size();
 }
 
diff --git a/libkdeconnect/notificationsmodel.cpp b/libkdeconnect/notificationsmodel.cpp
index 03b8b8d..c006029 100644
--- a/libkdeconnect/notificationsmodel.cpp
+++ b/libkdeconnect/notificationsmodel.cpp
@@ -35,10 +35,13 @@ NotificationsModel::NotificationsModel(QObject *parent)
 
     //new ModelTest(this, this);
 
-    connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)),
-            this, SIGNAL(rowsChanged()));
     connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)),
             this, SIGNAL(rowsChanged()));
+    connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)),
+            this, SIGNAL(rowsChanged()));
+
+    connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+            this, SIGNAL(anyDismissableChanged()));
 
     //Role names for QML
     QHash<int, QByteArray> names = roleNames();
@@ -102,16 +105,21 @@ void NotificationsModel::refreshNotificationList()
 
     if (!m_dbusInterface->isValid()) return;
 
-    QDBusPendingReply<QStringList> notificationIds = m_dbusInterface->activeNotifications();
-    notificationIds.waitForFinished();
-    if (notificationIds.isError()) return;
+    QDBusPendingReply<QStringList> pendingNotificationIds = m_dbusInterface->activeNotifications();
+    pendingNotificationIds.waitForFinished();
+    if (pendingNotificationIds.isError()) return;
+    const QStringList& notificationIds = pendingNotificationIds.value();
+
+    if (notificationIds.isEmpty()) return;
 
-    beginInsertRows(QModelIndex(), 0, notificationIds.value().size()-1);
-    Q_FOREACH(const QString& notificationId, notificationIds.value()) {
+    beginInsertRows(QModelIndex(), 0, notificationIds.size()-1);
+    Q_FOREACH(const QString& notificationId, notificationIds) {
         NotificationDbusInterface* dbusInterface = new NotificationDbusInterface(m_deviceId, notificationId, this);
         m_notificationList.append(dbusInterface);
     }
     endInsertRows();
+
+    Q_EMIT dataChanged(index(0), index(notificationIds.size()-1));
 }
 
 QVariant NotificationsModel::data(const QModelIndex &index, int role) const
@@ -139,10 +147,8 @@ QVariant NotificationsModel::data(const QModelIndex &index, int role) const
             return QString(notification->internalId());
         case NameModelRole:
             return QString(notification->ticker());
-        case Qt::ToolTipRole:
-            return QVariant(); //To implement
         case ContentModelRole:
-            return QString("AAAAAA"); //To implement
+            return QString(); //To implement in the Android side
         case AppNameModelRole:
             return QString(notification->appName());
         case DbusInterfaceRole:
@@ -178,7 +184,20 @@ int NotificationsModel::rowCount(const QModelIndex &parent) const
     return m_notificationList.count();
 }
 
-void NotificationsModel::clear()
+bool NotificationsModel::isAnyDimissable()
+{
+    Q_FOREACH(NotificationDbusInterface* notification, m_notificationList) {
+        if (notification->dismissable()) {
+            qDebug() << "Dismisable true";
+            return true;
+        }
+    }
+    qDebug() << "Dismisable false";
+    return false;
+}
+
+
+void NotificationsModel::dismissAll()
 {
     Q_FOREACH(NotificationDbusInterface* notification, m_notificationList) {
         if (notification->dismissable()) {
diff --git a/libkdeconnect/notificationsmodel.h b/libkdeconnect/notificationsmodel.h
index 324a51f..a79c063 100644
--- a/libkdeconnect/notificationsmodel.h
+++ b/libkdeconnect/notificationsmodel.h
@@ -34,6 +34,8 @@ class KDECONNECT_EXPORT NotificationsModel
     Q_OBJECT
     Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
     Q_PROPERTY(int count READ rowCount NOTIFY rowsChanged)
+    Q_PROPERTY(bool isAnyDimissable READ isAnyDimissable NOTIFY anyDismissableChanged)
+
 public:
     enum ModelRoles {
         IconModelRole = Qt::DecorationRole,
@@ -57,7 +59,8 @@ public:
     NotificationDbusInterface* getNotification(const QModelIndex&);
 
 public Q_SLOTS:
-    void clear();
+    void dismissAll();
+    bool isAnyDimissable();
 
 private Q_SLOTS:
     void notificationAdded(const QString& id);
@@ -66,6 +69,7 @@ private Q_SLOTS:
 
 Q_SIGNALS:
     void deviceIdChanged(const QString& value);
+    void anyDismissableChanged();
     void rowsChanged();
 
 private:
diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml
index b31baa8..cd47849 100644
--- a/plasmoid/package/contents/ui/DeviceDelegate.qml
+++ b/plasmoid/package/contents/ui/DeviceDelegate.qml
@@ -40,12 +40,15 @@ PlasmaComponents.ListItem
         //Notifications
         PlasmaComponents.ListItem {
             visible: notificationsModel.count>0
+            enabled: true
             sectionDelegate: true
             PlasmaComponents.Label { text: i18n("Notifications") }
             PlasmaComponents.ToolButton {
+                enabled: true
+                visible: notificationsModel.isAnyDimissable;
                 anchors.right: parent.right
                 iconSource: "window-close"
-                onClicked: notificationsModel.clear();
+                onClicked: notificationsModel.dismissAll();
             }
         }
         Repeater {
@@ -59,7 +62,8 @@ PlasmaComponents.ListItem
                     text: appName + ": " + display
                 }
                 PlasmaComponents.ToolButton {
-                    visible: dismissable
+                    visible: notificationsModel.isAnyDimissable;
+                    enabled: dismissable
                     anchors.right: parent.right
                     iconSource: "window-close"
                     onClicked: dbusInterface.dismiss();

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list