From 3e5440a3e1d4f23180b8e6795ae1c29f9964379d Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sat, 25 Aug 2012 21:56:47 +0200 Subject: bumping to 0.4.2 --- qmapwatchlet/compassview.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'qmapwatchlet/compassview.cpp') 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 + #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(); + } } -- cgit v1.2.3