summaryrefslogtreecommitdiff
path: root/harmaccuweather
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-01-04 04:18:37 +0100
committerJavier S. Pedro <maemo@javispedro.com>2012-01-04 04:18:37 +0100
commit105e48fcb2e8498a383447ac60f31677d2bb1b7d (patch)
treedbb06597fe52f12e1a0ceae380951d8991d26acd /harmaccuweather
parent1b0c6d90209460dd81628f4d9c028f91f596e46c (diff)
downloadsowatch-105e48fcb2e8498a383447ac60f31677d2bb1b7d.tar.gz
sowatch-105e48fcb2e8498a383447ac60f31677d2bb1b7d.zip
only update watch if weather info actually changed
Diffstat (limited to 'harmaccuweather')
-rw-r--r--harmaccuweather/harmaccuweather.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/harmaccuweather/harmaccuweather.cpp b/harmaccuweather/harmaccuweather.cpp
index 99cc31b..38fc9bc 100644
--- a/harmaccuweather/harmaccuweather.cpp
+++ b/harmaccuweather/harmaccuweather.cpp
@@ -232,12 +232,38 @@ void HarmAccuWeather::update()
QDateTime lastUpdate = s->value("LastUpdate").toDateTime();
if (lastUpdate > _lastUpdate) {
_lastUpdate = lastUpdate;
- _metric = s->value("useMetric").toBool();
- _lastTemp = s->value("LastTemp").toInt();
- _lastLocation = s->value("LastLocation").toString();
- _lastWxCode = s->value("LastWxCode").toInt();
- qDebug() << "updated weather info" << _lastUpdate << _lastWxCode;
- emit changed();
+ bool anythingChanged = false;
+
+ qDebug() << "reading weather info at" << _lastUpdate;
+
+ bool useMetric = s->value("useMetric").toBool();
+ if (useMetric != _metric) {
+ _metric = useMetric;
+ anythingChanged = true;
+ }
+
+ int temp = s->value("LastTemp").toInt();
+ if (_lastTemp != temp) {
+ _lastTemp = temp;
+ anythingChanged = true;
+ }
+
+ QString location = s->value("LastLocation").toString();
+ if (_lastLocation != location) {
+ _lastLocation = location;
+ anythingChanged = true;
+ }
+
+ int wxCode = s->value("LastWxCode").toInt();
+ if (_lastWxCode != wxCode) {
+ _lastWxCode = wxCode;
+ anythingChanged = true;
+ }
+
+ if (anythingChanged) {
+ qDebug() << "weather info changed wxcode=" << wxCode;
+ emit changed();
+ }
}
delete s;