From 9195f247c4b05a0cb849cf998355dc3ec3b65641 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Nov 2015 10:54:36 -0800 Subject: Location service: move files around to fit new directory layout Signed-off-by: Dirk Hohndel --- qt-mobile/gpslocation.cpp | 32 ++++++++++++++++++++++++++++++++ qt-mobile/gpslocation.h | 25 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 qt-mobile/gpslocation.cpp create mode 100644 qt-mobile/gpslocation.h (limited to 'qt-mobile') diff --git a/qt-mobile/gpslocation.cpp b/qt-mobile/gpslocation.cpp new file mode 100644 index 000000000..3f47396c1 --- /dev/null +++ b/qt-mobile/gpslocation.cpp @@ -0,0 +1,32 @@ +#include "qt-mobile/gpslocation.h" +#include + + +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"; +} diff --git a/qt-mobile/gpslocation.h b/qt-mobile/gpslocation.h new file mode 100644 index 000000000..8e26fd25e --- /dev/null +++ b/qt-mobile/gpslocation.h @@ -0,0 +1,25 @@ +#ifndef GPSLOCATION_H +#define GPSLOCATION_H + +#include +#include +#include +#include + +class GpsLocation : QObject +{ + Q_OBJECT +public: + GpsLocation(QObject *parent); + +private: + QGeoPositionInfo lastPos; + +signals: + +public slots: + void newPosition(QGeoPositionInfo pos); + void updateTimeout(); +}; + +#endif // GPSLOCATION_H -- cgit v1.2.3-70-g09d2