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

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


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

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

    Make the NotificationsModel also async
    
    The code was almost identical to the one in DevicesModel, so I did the same
---
 interfaces/notificationsmodel.cpp | 39 +++++++++++++++++++++++++++------------
 interfaces/notificationsmodel.h   |  3 +++
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp
index caa4dad..c17a816 100644
--- a/interfaces/notificationsmodel.cpp
+++ b/interfaces/notificationsmodel.cpp
@@ -106,26 +106,33 @@ void NotificationsModel::refreshNotificationList()
         return;
     }
 
-    if (!m_notificationList.isEmpty()) {
-        beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1);
-        qDeleteAll(m_notificationList);
-        m_notificationList.clear();
-        endRemoveRows();
-    }
+    clearNotifications();
 
     if (!m_dbusInterface->isValid()) {
-        qCDebug(KDECONNECT_INTERFACES) << "dbus interface not valid";
+        qCWarning(KDECONNECT_INTERFACES) << "dbus interface not valid";
         return;
     }
 
     QDBusPendingReply<QStringList> pendingNotificationIds = m_dbusInterface->activeNotifications();
-    pendingNotificationIds.waitForFinished();
+    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingNotificationIds, this);
+
+    QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+                     this, SLOT(receivedNotifications(QDBusPendingCallWatcher*)));
+}
+
+void NotificationsModel::receivedNotifications(QDBusPendingCallWatcher* watcher)
+{
+    watcher->deleteLater();
+    clearNotifications();
+    QDBusPendingReply<QStringList> pendingNotificationIds = *watcher;
+
+    clearNotifications();
     if (pendingNotificationIds.isError()) {
-        qCDebug(KDECONNECT_INTERFACES) << pendingNotificationIds.error();
+        qCWarning(KDECONNECT_INTERFACES) << pendingNotificationIds.error();
         return;
     }
-    const QStringList& notificationIds = pendingNotificationIds.value();
 
+    const QStringList notificationIds = pendingNotificationIds.value();
     if (notificationIds.isEmpty()) {
         return;
     }
@@ -136,8 +143,6 @@ void NotificationsModel::refreshNotificationList()
         m_notificationList.append(dbusInterface);
     }
     endInsertRows();
-
-    Q_EMIT dataChanged(index(0), index(notificationIds.size() - 1));
 }
 
 QVariant NotificationsModel::data(const QModelIndex& index, int role) const
@@ -219,3 +224,13 @@ void NotificationsModel::dismissAll()
         }
     }
 }
+
+void NotificationsModel::clearNotifications()
+{
+    if (!m_notificationList.isEmpty()) {
+        beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1);
+        qDeleteAll(m_notificationList);
+        m_notificationList.clear();
+        endRemoveRows();
+    }
+}
diff --git a/interfaces/notificationsmodel.h b/interfaces/notificationsmodel.h
index 4dba754..c54ef65 100644
--- a/interfaces/notificationsmodel.h
+++ b/interfaces/notificationsmodel.h
@@ -68,6 +68,7 @@ private Q_SLOTS:
     void notificationAdded(const QString& id);
     void notificationRemoved(const QString& id);
     void refreshNotificationList();
+    void receivedNotifications(QDBusPendingCallWatcher* watcher);
 
 Q_SIGNALS:
     void deviceIdChanged(const QString& value);
@@ -75,6 +76,8 @@ Q_SIGNALS:
     void rowsChanged();
 
 private:
+    void clearNotifications();
+
     DeviceNotificationsDbusInterface* m_dbusInterface;
     QList<NotificationDbusInterface*> m_notificationList;
     QString m_deviceId;

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list