summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-11-08 23:26:14 +0100
committerJavier S. Pedro <maemo@javispedro.com>2011-11-08 23:26:14 +0100
commit3733cb7e3c0932ee281fce64c153c7c1fc0f18f9 (patch)
tree0a45326c7c91d584813af419f06f54d20c9b0375 /libsowatch/watchserver.cpp
parentef80351e6fb029f3d22d62ef5a1873616884d882 (diff)
downloadsowatch-3733cb7e3c0932ee281fce64c153c7c1fc0f18f9.tar.gz
sowatch-3733cb7e3c0932ee281fce64c153c7c1fc0f18f9.zip
fix display of mail notifications when there are already unread mails
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r--libsowatch/watchserver.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index 4675809..9d7859d 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -195,6 +195,7 @@ void WatchServer::postNotification(Notification *notification)
{
const Notification::Type type = notification->type();
_notifications[type].append(notification);
+ _notificationCounts[notification] = notification->count();
connect(notification, SIGNAL(changed()), SLOT(notificationChanged()));
connect(notification, SIGNAL(dismissed()), SLOT(notificationDismissed()));
@@ -247,15 +248,13 @@ void WatchServer::notificationChanged()
if (obj) {
Notification* n = static_cast<Notification*>(obj);
const Notification::Type type = n->type();
+ const uint lastCount = _notificationCounts[n];
+ _notificationCounts[n] = n->count();
qDebug() << "notification changed" << n->title() << "(" << n->count() << ")";
_watch->updateNotificationCount(type, getNotificationCount(type));
- if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {
- // This is the notification that is being currently signaled on the watch
- // Therefore, show it again
- nextNotification();
- }
+
if (type == Notification::WeatherNotification) {
WeatherNotification* w = static_cast<WeatherNotification*>(n);
if (!_weather || _weather->dateTime() < w->dateTime()) {
@@ -267,6 +266,21 @@ void WatchServer::notificationChanged()
// Therefore, update the displayed information
_watch->updateWeather(w);
}
+ return; // Do not display it the usual way
+ }
+
+ if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {
+ // This is the notification that is being currently signaled on the watch
+ // Therefore, show it again no matter what.
+ nextNotification();
+ } else if (n->count() > lastCount) {
+ // This notification now contains an additional "item"; redisplay it.
+ if (_pendingNotifications.isEmpty()) {
+ _pendingNotifications.enqueue(n);
+ nextNotification();
+ } else {
+ _pendingNotifications.enqueue(n);
+ }
}
}
}
@@ -278,6 +292,7 @@ void WatchServer::notificationDismissed()
Notification* n = static_cast<Notification*>(obj);
const Notification::Type type = n->type();
_notifications[type].removeOne(n);
+ _notificationCounts.remove(n);
qDebug() << "notification dismissed" << n->title() << "(" << n->count() << ")";