mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
136b87e7c0
commit
12a6a8f2b3
3 changed files with 41 additions and 4 deletions
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
#ifndef GPSLOCATION_H
|
||||
#define GPSLOCATION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QGeoCoordinate>
|
||||
#include <QGeoPositionInfoSource>
|
||||
#include <QGeoPositionInfo>
|
||||
|
||||
class GpsLocation
|
||||
class GpsLocation : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GpsLocation();
|
||||
GpsLocation(QObject *parent);
|
||||
|
||||
private:
|
||||
QGeoPositionInfo lastPos;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void newPosition(QGeoPositionInfo pos);
|
||||
void updateTimeout();
|
||||
};
|
||||
|
||||
#endif // GPSLOCATION_H
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "qt-mobile/qmlmanager.h"
|
||||
#include "qt-models/divelistmodel.h"
|
||||
#include "qt-mobile/qmlprofile.h"
|
||||
#include "gpslocation.h"
|
||||
GpsLocation *locationProvider;
|
||||
|
||||
QObject *qqWindowObject = NULL;
|
||||
|
||||
|
@ -52,6 +54,7 @@ void run_ui()
|
|||
qml_window->setHeight(1200);
|
||||
qml_window->setWidth(800);
|
||||
#endif
|
||||
locationProvider = new GpsLocation(qml_window);
|
||||
qml_window->show();
|
||||
qApp->exec();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue