mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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 "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
|
#ifndef GPSLOCATION_H
|
||||||
#define GPSLOCATION_H
|
#define GPSLOCATION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QGeoCoordinate>
|
#include <QGeoCoordinate>
|
||||||
|
#include <QGeoPositionInfoSource>
|
||||||
|
#include <QGeoPositionInfo>
|
||||||
|
|
||||||
class GpsLocation
|
class GpsLocation : QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GpsLocation();
|
GpsLocation(QObject *parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGeoPositionInfo lastPos;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void newPosition(QGeoPositionInfo pos);
|
||||||
|
void updateTimeout();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPSLOCATION_H
|
#endif // GPSLOCATION_H
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "qt-mobile/qmlmanager.h"
|
#include "qt-mobile/qmlmanager.h"
|
||||||
#include "qt-models/divelistmodel.h"
|
#include "qt-models/divelistmodel.h"
|
||||||
#include "qt-mobile/qmlprofile.h"
|
#include "qt-mobile/qmlprofile.h"
|
||||||
|
#include "gpslocation.h"
|
||||||
|
GpsLocation *locationProvider;
|
||||||
|
|
||||||
QObject *qqWindowObject = NULL;
|
QObject *qqWindowObject = NULL;
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ void run_ui()
|
||||||
qml_window->setHeight(1200);
|
qml_window->setHeight(1200);
|
||||||
qml_window->setWidth(800);
|
qml_window->setWidth(800);
|
||||||
#endif
|
#endif
|
||||||
|
locationProvider = new GpsLocation(qml_window);
|
||||||
qml_window->show();
|
qml_window->show();
|
||||||
qApp->exec();
|
qApp->exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue