summaryrefslogtreecommitdiff
path: root/qmapwatchlet/compassview.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-25 21:56:47 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-25 21:56:47 +0200
commit3e5440a3e1d4f23180b8e6795ae1c29f9964379d (patch)
treef77d23238d25b4b9fda4b2e65d4777e964150d9d /qmapwatchlet/compassview.cpp
parentd6d10c69ba454a6e555733815680acdfc0ee5402 (diff)
downloadsowatch_0_4_2.tar.gz
sowatch_0_4_2.zip
bumping to 0.4.2sowatch_0_4_2
Diffstat (limited to 'qmapwatchlet/compassview.cpp')
-rw-r--r--qmapwatchlet/compassview.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/qmapwatchlet/compassview.cpp b/qmapwatchlet/compassview.cpp
index 5de44a5..7ee2853 100644
--- a/qmapwatchlet/compassview.cpp
+++ b/qmapwatchlet/compassview.cpp
@@ -1,3 +1,5 @@
+#include <math.h>
+
#include "qmapwatchletplugin.h"
#include "compassview.h"
@@ -9,7 +11,7 @@ CompassView::CompassView(QDeclarativeItem *parent) :
_enabled(false),
_image(SOWATCH_QML_DIR "/qmapwatchlet/compass.png"),
_posSource(QGeoPositionInfoSource::createDefaultSource(this)),
- _direction(-1.0), _speed(-1.0), _altitude(-1.0)
+ _direction(-1.0), _speed(NAN), _altitude(NAN)
{
if (_posSource) {
connect(_posSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
@@ -106,7 +108,7 @@ void CompassView::handlePositionUpdate(const QGeoPositionInfo &info)
update();
}
- qreal newSpeed = -1.0;
+ qreal newSpeed = NAN;
if (info.hasAttribute(QGeoPositionInfo::GroundSpeed)) {
newSpeed = info.attribute(QGeoPositionInfo::GroundSpeed);
}
@@ -115,4 +117,14 @@ void CompassView::handlePositionUpdate(const QGeoPositionInfo &info)
_speed = newSpeed;
emit currentSpeedChanged();
}
+
+ qreal newAlt = NAN;
+ if (info.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) {
+ newAlt = info.coordinate().altitude();
+ }
+ qDebug() << "New altitude" << newAlt;
+ if (newAlt != _altitude) {
+ _altitude = newAlt;
+ emit currentAltitudeChanged();
+ }
}