summaryrefslogtreecommitdiffstats
path: root/gpslocation.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-11 10:52:52 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-11 12:37:40 -0800
commit12a6a8f2b3afe4c6376b874f609be933ed5dbe5c (patch)
tree806621df5324f625a078b0f35e7105ee274f6220 /gpslocation.cpp
parent136b87e7c00b79ba8ee316ecf66dbc326e78c823 (diff)
downloadsubsurface-12a6a8f2b3afe4c6376b874f609be933ed5dbe5c.tar.gz
Location service: request position update
Mostly still just experimental code - now it tries to get an actual position. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gpslocation.cpp')
-rw-r--r--gpslocation.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/gpslocation.cpp b/gpslocation.cpp
index 6725abfb9..da4734897 100644
--- a/gpslocation.cpp
+++ b/gpslocation.cpp
@@ -1,7 +1,32 @@
#include "gpslocation.h"
+#include <QDebug>
-GpsLocation::GpsLocation()
-{
+GpsLocation::GpsLocation(QObject *parent)
+{
+ QGeoPositionInfoSource *gpsSource = QGeoPositionInfoSource::createDefaultSource(parent);
+ if (gpsSource != 0) {
+ qDebug() << "have position source" << gpsSource->sourceName();
+ connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
+ connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
+ lastPos = gpsSource->lastKnownPosition();
+ gpsSource->requestUpdate(1000);
+ QGeoCoordinate lastCoord = lastPos.coordinate();
+ if (lastCoord.isValid()) {
+ qDebug() << lastCoord.toString();
+ } else {
+ qDebug() << "invalid last position";
+ }
+ } else {
+ qDebug() << "don't have GPS source";
+ }
+}
+void GpsLocation::newPosition(QGeoPositionInfo pos)
+{
+ qDebug() << "received new position" << pos.coordinate().toString();
}
+void GpsLocation::updateTimeout()
+{
+ qDebug() << "request to get new position timed out";
+}