From 8777cc9d76d5ec06331da8e992e5d46658268bbb Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Sat, 14 Jun 2014 13:31:02 +0200 Subject: [PATCH] libkdeconnect: Fixed some style issues. Conflicts: libkdeconnect/devicesmodel.cpp libkdeconnect/devicesmodel.h libkdeconnect/notificationsmodel.cpp libkdeconnect/notificationsmodel.h --- libkdeconnect/devicesmodel.cpp | 11 +++---- libkdeconnect/devicesmodel.h | 7 ++--- libkdeconnect/notificationsmodel.cpp | 44 +++++++++++++++++----------- libkdeconnect/notificationsmodel.h | 16 +++++----- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/libkdeconnect/devicesmodel.cpp b/libkdeconnect/devicesmodel.cpp index 4e4ae91bb..c8f83dcc7 100644 --- a/libkdeconnect/devicesmodel.cpp +++ b/libkdeconnect/devicesmodel.cpp @@ -55,7 +55,6 @@ DevicesModel::DevicesModel(QObject *parent) QHash names = roleNames(); names.insert(IdModelRole, "deviceId"); setRoleNames(names); - } DevicesModel::~DevicesModel() @@ -83,6 +82,7 @@ void DevicesModel::deviceStatusChanged(const QString& id) //Q_EMIT dataChanged(index(0),index(rowCount())); refreshDeviceList(); } + DevicesModel::StatusFlags DevicesModel::displayFilter() const { return m_displayFilter; @@ -101,7 +101,6 @@ void DevicesModel::setDisplayFilter(DevicesModel::StatusFlags flags) void DevicesModel::refreshDeviceList() { - if (!m_deviceList.isEmpty()) { beginRemoveRows(QModelIndex(), 0, m_deviceList.size() - 1); m_deviceList.clear(); @@ -130,10 +129,9 @@ void DevicesModel::refreshDeviceList() } Q_EMIT dataChanged(index(0), index(m_deviceList.size())); - } -QVariant DevicesModel::data(const QModelIndex &index, int role) const +QVariant DevicesModel::data(const QModelIndex& index, int role) const { if (!m_dbusInterface->isValid() || !index.isValid() @@ -173,7 +171,7 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const } } -DeviceDbusInterface *DevicesModel::getDevice(const QModelIndex &index) const +DeviceDbusInterface* DevicesModel::getDevice(const QModelIndex& index) const { if (!index.isValid()) { return NULL; @@ -187,7 +185,7 @@ DeviceDbusInterface *DevicesModel::getDevice(const QModelIndex &index) const return m_deviceList[row]; } -int DevicesModel::rowCount(const QModelIndex &parent) const +int DevicesModel::rowCount(const QModelIndex& parent) const { if(parent.isValid()) { //Return size 0 if we are a child because this is not a tree @@ -196,4 +194,3 @@ int DevicesModel::rowCount(const QModelIndex &parent) const return m_deviceList.size(); } - diff --git a/libkdeconnect/devicesmodel.h b/libkdeconnect/devicesmodel.h index 3f02251ac..09bb1a130 100644 --- a/libkdeconnect/devicesmodel.h +++ b/libkdeconnect/devicesmodel.h @@ -21,7 +21,6 @@ #ifndef DEVICESMODEL_H #define DEVICESMODEL_H - #include #include #include @@ -56,10 +55,10 @@ public: void setDisplayFilter(int flags); StatusFlags displayFilter() const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex& index, int role) const; + virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; - DeviceDbusInterface *getDevice(const QModelIndex &index) const; + DeviceDbusInterface* getDevice(const QModelIndex& index) const; public Q_SLOTS: void deviceStatusChanged(const QString& id); diff --git a/libkdeconnect/notificationsmodel.cpp b/libkdeconnect/notificationsmodel.cpp index f67b2fd2a..ea84fd615 100644 --- a/libkdeconnect/notificationsmodel.cpp +++ b/libkdeconnect/notificationsmodel.cpp @@ -29,7 +29,7 @@ #include "modeltest.h" #include "kdebugnamespace.h" -NotificationsModel::NotificationsModel(QObject *parent) +NotificationsModel::NotificationsModel(QObject* parent) : QAbstractListModel(parent) , m_dbusInterface(0) { @@ -41,7 +41,7 @@ NotificationsModel::NotificationsModel(QObject *parent) connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SIGNAL(rowsChanged())); - connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SIGNAL(anyDismissableChanged())); //Role names for QML @@ -66,7 +66,10 @@ void NotificationsModel::setDeviceId(const QString& deviceId) { m_deviceId = deviceId; - if (m_dbusInterface) delete m_dbusInterface; + if (m_dbusInterface) { + delete m_dbusInterface; + } + m_dbusInterface = new DeviceNotificationsDbusInterface(deviceId, this); connect(m_dbusInterface, SIGNAL(notificationPosted(QString)), @@ -95,7 +98,9 @@ void NotificationsModel::notificationRemoved(const QString& id) void NotificationsModel::refreshNotificationList() { - if (!m_dbusInterface) return; + if (!m_dbusInterface) { + return; + } if (!m_notificationList.isEmpty()) { beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1); @@ -104,28 +109,33 @@ void NotificationsModel::refreshNotificationList() endRemoveRows(); } - if (!m_dbusInterface->isValid()) return; + if (!m_dbusInterface->isValid()) { + return; + } QDBusPendingReply pendingNotificationIds = m_dbusInterface->activeNotifications(); pendingNotificationIds.waitForFinished(); - if (pendingNotificationIds.isError()) return; + if (pendingNotificationIds.isError()) { + return; + } const QStringList& notificationIds = pendingNotificationIds.value(); - if (notificationIds.isEmpty()) return; + if (notificationIds.isEmpty()) { + return; + } - beginInsertRows(QModelIndex(), 0, notificationIds.size()-1); - Q_FOREACH(const QString& notificationId, notificationIds) { + 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)); + Q_EMIT dataChanged(index(0), index(notificationIds.size() - 1)); } -QVariant NotificationsModel::data(const QModelIndex &index, int role) const +QVariant NotificationsModel::data(const QModelIndex& index, int role) const { - if (!index.isValid() || index.row() < 0 || index.row() >= m_notificationList.count() @@ -161,7 +171,7 @@ QVariant NotificationsModel::data(const QModelIndex &index, int role) const } } -NotificationDbusInterface *NotificationsModel::getNotification(const QModelIndex &index) const +NotificationDbusInterface* NotificationsModel::getNotification(const QModelIndex& index) const { if (!index.isValid()) { return NULL; @@ -175,9 +185,9 @@ NotificationDbusInterface *NotificationsModel::getNotification(const QModelIndex return m_notificationList[row]; } -int NotificationsModel::rowCount(const QModelIndex &parent) const +int NotificationsModel::rowCount(const QModelIndex& parent) const { - if(parent.isValid()) { + if (parent.isValid()) { //Return size 0 if we are a child because this is not a tree return 0; } @@ -187,7 +197,7 @@ int NotificationsModel::rowCount(const QModelIndex &parent) const bool NotificationsModel::isAnyDimissable() const { - Q_FOREACH(NotificationDbusInterface* notification, m_notificationList) { + Q_FOREACH (NotificationDbusInterface* notification, m_notificationList) { if (notification->dismissable()) { return true; } @@ -198,7 +208,7 @@ bool NotificationsModel::isAnyDimissable() const void NotificationsModel::dismissAll() { - Q_FOREACH(NotificationDbusInterface* notification, m_notificationList) { + Q_FOREACH (NotificationDbusInterface* notification, m_notificationList) { if (notification->dismissable()) { notification->dismiss(); } diff --git a/libkdeconnect/notificationsmodel.h b/libkdeconnect/notificationsmodel.h index 2532df0b5..799908276 100644 --- a/libkdeconnect/notificationsmodel.h +++ b/libkdeconnect/notificationsmodel.h @@ -38,16 +38,16 @@ class KDECONNECT_EXPORT NotificationsModel public: enum ModelRoles { - IconModelRole = Qt::DecorationRole, - NameModelRole = Qt::DisplayRole, - ContentModelRole = Qt::UserRole, - AppNameModelRole = Qt::UserRole+1, - IdModelRole = Qt::UserRole+2, - DismissableModelRole = Qt::UserRole+3, - DbusInterfaceRole = Qt::UserRole+4, + IconModelRole = Qt::DecorationRole, + NameModelRole = Qt::DisplayRole, + ContentModelRole = Qt::UserRole, + AppNameModelRole = Qt::UserRole + 1, + IdModelRole = Qt::UserRole + 2, + DismissableModelRole = Qt::UserRole + 3, + DbusInterfaceRole = Qt::UserRole + 4 }; - NotificationsModel(QObject *parent = 0); + NotificationsModel(QObject* parent = 0); virtual ~NotificationsModel(); QString deviceId() const;