diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2011-11-08 23:26:14 +0100 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2011-11-08 23:26:14 +0100 |
commit | 3733cb7e3c0932ee281fce64c153c7c1fc0f18f9 (patch) | |
tree | 0a45326c7c91d584813af419f06f54d20c9b0375 | |
parent | ef80351e6fb029f3d22d62ef5a1873616884d882 (diff) | |
download | sowatch-3733cb7e3c0932ee281fce64c153c7c1fc0f18f9.tar.gz sowatch-3733cb7e3c0932ee281fce64c153c7c1fc0f18f9.zip |
fix display of mail notifications when there are already unread mails
-rw-r--r-- | libsowatch/watchserver.cpp | 25 | ||||
-rw-r--r-- | libsowatch/watchserver.h | 2 |
2 files changed, 22 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() << ")"; diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h index 53c1a70..f86d224 100644 --- a/libsowatch/watchserver.h +++ b/libsowatch/watchserver.h @@ -64,6 +64,8 @@ private: QList<Notification*> _notifications[Notification::TypeCount]; /** A list of notifications that are yet to be shown to the user. */ QQueue<Notification*> _pendingNotifications; + /** Stores the count of notifications hidden between each notification object. */ + QMap<Notification*, uint> _notificationCounts; /** We store a currently live weather forecast. */ WeatherNotification* _weather; |