aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile/gpslocation.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-11 11:16:59 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-11 12:38:11 -0800
commite7b2f04bec19c70bff2324b43c337728f2420aca (patch)
tree77e9337b9cc1d0297b861aefc83a4cf0ce14a458 /qt-mobile/gpslocation.cpp
parent9195f247c4b05a0cb849cf998355dc3ec3b65641 (diff)
downloadsubsurface-e7b2f04bec19c70bff2324b43c337728f2420aca.tar.gz
Location service: consistent way to output information
qDebug is nice when testing on the desktop, but it has to go to the message area on an Android device to make things easy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/gpslocation.cpp')
-rw-r--r--qt-mobile/gpslocation.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/qt-mobile/gpslocation.cpp b/qt-mobile/gpslocation.cpp
index 3f47396c1..0108fdc0d 100644
--- a/qt-mobile/gpslocation.cpp
+++ b/qt-mobile/gpslocation.cpp
@@ -1,4 +1,5 @@
#include "qt-mobile/gpslocation.h"
+#include "qt-mobile/qmlmanager.h"
#include <QDebug>
@@ -6,27 +7,34 @@ GpsLocation::GpsLocation(QObject *parent)
{
QGeoPositionInfoSource *gpsSource = QGeoPositionInfoSource::createDefaultSource(parent);
if (gpsSource != 0) {
- qDebug() << "have position source" << gpsSource->sourceName();
+ QString msg = QString("have position source %1").arg(gpsSource->sourceName());
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
lastPos = gpsSource->lastKnownPosition();
- gpsSource->requestUpdate(1000);
+ gpsSource->startUpdates();
QGeoCoordinate lastCoord = lastPos.coordinate();
if (lastCoord.isValid()) {
- qDebug() << lastCoord.toString();
+ status(msg + lastCoord.toString());
} else {
- qDebug() << "invalid last position";
+ status(msg + "invalid last position");
}
} else {
- qDebug() << "don't have GPS source";
+ status("don't have GPS source");
}
}
void GpsLocation::newPosition(QGeoPositionInfo pos)
{
- qDebug() << "received new position" << pos.coordinate().toString();
+ QString msg("received new position %1");
+ status(qPrintable(msg.arg(pos.coordinate().toString())));
}
void GpsLocation::updateTimeout()
{
- qDebug() << "request to get new position timed out";
+ status("request to get new position timed out");
+}
+
+void GpsLocation::status(QString msg)
+{
+ qDebug() << msg;
+ qmlUiShowMessage(qPrintable(msg));
}