diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2011-10-16 04:42:30 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2011-10-16 04:42:30 +0200 |
commit | 4da9bced6a27b92d49b9fc9392946510b8519d82 (patch) | |
tree | 7a2417a932a6463e3e6f6ec4d3799e24de917306 /libsowatch/watchserver.cpp | |
parent | bde4bde8ec9d6d09874d5ae9e0ba6dc9431859b6 (diff) | |
download | sowatch-4da9bced6a27b92d49b9fc9392946510b8519d82.tar.gz sowatch-4da9bced6a27b92d49b9fc9392946510b8519d82.zip |
Initial implementation of weather
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r-- | libsowatch/watchserver.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 60c410d..4675809 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -5,7 +5,6 @@ #include "watchlet.h" #include "watchserver.h" - using namespace sowatch; WatchServer::WatchServer(Watch* watch, QObject* parent) : @@ -204,6 +203,14 @@ void WatchServer::postNotification(Notification *notification) _watch->updateNotificationCount(type, getNotificationCount(type)); + if (type == Notification::WeatherNotification) { + // Weather notifications, we handle differently. + WeatherNotification* weather = static_cast<WeatherNotification*>(notification); + _weather = weather; + _watch->updateWeather(weather); + return; // And do not display it the usual way + } + QDateTime oldThreshold = QDateTime::currentDateTime().addSecs(-_oldNotificationThreshold); if (notification->dateTime() < oldThreshold) { return; // Do not care about notifications that old... @@ -245,8 +252,22 @@ void WatchServer::notificationChanged() _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()) { + // Prefer showing the most recent data + _weather = w; + } + if (_weather == w) { + // This is the weather notification we are currently displaying on the watch + // Therefore, update the displayed information + _watch->updateWeather(w); + } + } } } @@ -269,5 +290,11 @@ void WatchServer::notificationDismissed() } else { _pendingNotifications.removeAll(n); } + if (type == Notification::WeatherNotification) { + WeatherNotification* w = static_cast<WeatherNotification*>(n); + if (_weather == w) { + _weather = 0; + } + } } } |