Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/notificationsmodel.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
78 | NotificationsModel::Private::~Private() | 78 | NotificationsModel::Private::~Private() | ||
79 | { | 79 | { | ||
80 | qDeleteAll(notificationTimeouts); | 80 | qDeleteAll(notificationTimeouts); | ||
81 | notificationTimeouts.clear(); | 81 | notificationTimeouts.clear(); | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | void NotificationsModel::Private::onNotificationAdded(const Notification ¬ification) | 84 | void NotificationsModel::Private::onNotificationAdded(const Notification ¬ification) | ||
85 | { | 85 | { | ||
86 | // If we get the same notification in succession, just compress them into one | | |||
87 | if (!notifications.isEmpty()) { | | |||
88 | const Notification &lastNotification = notifications.constLast(); | | |||
89 | if (lastNotification.applicationName() == notification.applicationName() | | |||
90 | && lastNotification.summary() == notification.summary() | | |||
91 | && lastNotification.body() == notification.body() | | |||
92 | && lastNotification.desktopEntry() == notification.desktopEntry() | | |||
93 | && lastNotification.applicationName() == notification.applicationName()) { | | |||
94 | onNotificationReplaced(lastNotification.id(), notification); | | |||
95 | return; | | |||
96 | } | | |||
97 | } | | |||
98 | | ||||
99 | // Once we reach a certain insane number of notifications discard some old ones | 86 | // Once we reach a certain insane number of notifications discard some old ones | ||
100 | // as we keep pixmaps around etc | 87 | // as we keep pixmaps around etc | ||
101 | if (notifications.count() >= s_notificationsLimit) { | 88 | if (notifications.count() >= s_notificationsLimit) { | ||
102 | const int cleanupCount = s_notificationsLimit / 2; | 89 | const int cleanupCount = s_notificationsLimit / 2; | ||
103 | qCDebug(NOTIFICATIONMANAGER) << "Reached the notification limit of" << s_notificationsLimit << ", discarding the oldest" << cleanupCount << "notifications"; | 90 | qCDebug(NOTIFICATIONMANAGER) << "Reached the notification limit of" << s_notificationsLimit << ", discarding the oldest" << cleanupCount << "notifications"; | ||
104 | q->beginRemoveRows(QModelIndex(), 0, cleanupCount - 1); | 91 | q->beginRemoveRows(QModelIndex(), 0, cleanupCount - 1); | ||
105 | for (int i = 0 ; i < cleanupCount; ++i) { | 92 | for (int i = 0 ; i < cleanupCount; ++i) { | ||
106 | notifications.removeAt(0); | 93 | notifications.removeAt(0); | ||
▲ Show 20 Lines • Show All 382 Lines • Show Last 20 Lines |