Changeset View
Changeset View
Standalone View
Standalone View
interfaces/notificationsmodel.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 83 | { | |||
---|---|---|---|---|---|
90 | m_dbusInterface = new DeviceNotificationsDbusInterface(deviceId, this); | 90 | m_dbusInterface = new DeviceNotificationsDbusInterface(deviceId, this); | ||
91 | 91 | | |||
92 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::notificationPosted, | 92 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::notificationPosted, | ||
93 | this, &NotificationsModel::notificationAdded); | 93 | this, &NotificationsModel::notificationAdded); | ||
94 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::notificationRemoved, | 94 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::notificationRemoved, | ||
95 | this, &NotificationsModel::notificationRemoved); | 95 | this, &NotificationsModel::notificationRemoved); | ||
96 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::allNotificationsRemoved, | 96 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::allNotificationsRemoved, | ||
97 | this, &NotificationsModel::clearNotifications); | 97 | this, &NotificationsModel::clearNotifications); | ||
98 | connect(m_dbusInterface, &OrgKdeKdeconnectDeviceNotificationsInterface::notificationUpdated, | | |||
99 | this, &NotificationsModel::notificationUpdated); | | |||
100 | 98 | | |||
101 | refreshNotificationList(); | 99 | refreshNotificationList(); | ||
102 | 100 | | |||
103 | Q_EMIT deviceIdChanged(deviceId); | 101 | Q_EMIT deviceIdChanged(deviceId); | ||
104 | } | 102 | } | ||
105 | 103 | | |||
106 | void NotificationsModel::notificationAdded(const QString& id) | 104 | void NotificationsModel::notificationAdded(const QString& id) | ||
107 | { | 105 | { | ||
108 | beginInsertRows(QModelIndex(), 0, 0); | 106 | beginInsertRows(QModelIndex(), 0, 0); | ||
109 | NotificationDbusInterface* dbusInterface = new NotificationDbusInterface(m_deviceId, id, this); | 107 | NotificationDbusInterface* dbusInterface = new NotificationDbusInterface(m_deviceId, id, this); | ||
108 | connect(dbusInterface, &NotificationDbusInterface::ready, this, &NotificationsModel::notificationUpdated); | ||||
110 | m_notificationList.prepend(dbusInterface); | 109 | m_notificationList.prepend(dbusInterface); | ||
111 | endInsertRows(); | 110 | endInsertRows(); | ||
112 | } | 111 | } | ||
113 | 112 | | |||
114 | void NotificationsModel::notificationRemoved(const QString& id) | 113 | void NotificationsModel::notificationRemoved(const QString& id) | ||
115 | { | 114 | { | ||
116 | for (int i = 0; i < m_notificationList.size(); ++i) { | 115 | for (int i = 0; i < m_notificationList.size(); ++i) { | ||
117 | if (m_notificationList[i]->notificationId() == id) { | 116 | if (m_notificationList[i]->notificationId() == id) { | ||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 259 | { | |||
261 | if (!m_notificationList.isEmpty()) { | 260 | if (!m_notificationList.isEmpty()) { | ||
262 | beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1); | 261 | beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1); | ||
263 | qDeleteAll(m_notificationList); | 262 | qDeleteAll(m_notificationList); | ||
264 | m_notificationList.clear(); | 263 | m_notificationList.clear(); | ||
265 | endRemoveRows(); | 264 | endRemoveRows(); | ||
266 | } | 265 | } | ||
267 | } | 266 | } | ||
268 | 267 | | |||
269 | void NotificationsModel::notificationUpdated(const QString& id) | 268 | void NotificationsModel::notificationUpdated() | ||
270 | { | 269 | { | ||
271 | //TODO only emit the affected indices | | |||
272 | Q_UNUSED(id); | | |||
albertvaka: I would keep the parameter and the TODO, or fix the dataChanged emit so it doesn't contain… | |||||
273 | Q_EMIT dataChanged(index(0,0), index(m_notificationList.size() - 1, 0)); | 270 | Q_EMIT dataChanged(index(0,0), index(m_notificationList.size() - 1, 0)); | ||
274 | } | 271 | } |
I would keep the parameter and the TODO, or fix the dataChanged emit so it doesn't contain every row.