mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add instance method for GpsLocation
This way we can call members from different parts of the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1bfcf5c0f8
commit
962341ae9f
2 changed files with 23 additions and 3 deletions
|
@ -13,8 +13,12 @@
|
||||||
#define GPS_FIX_ADD_URL "http://api.subsurface-divelog.org/api/dive/add/"
|
#define GPS_FIX_ADD_URL "http://api.subsurface-divelog.org/api/dive/add/"
|
||||||
#define GET_WEBSERVICE_UID_URL "https://cloud.subsurface-divelog.org/webuserid/"
|
#define GET_WEBSERVICE_UID_URL "https://cloud.subsurface-divelog.org/webuserid/"
|
||||||
|
|
||||||
|
GpsLocation *GpsLocation::m_Instance = NULL;
|
||||||
|
|
||||||
GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent)
|
GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT_X(m_Instance == NULL, "GpsLocation", "GpsLocation recreated");
|
||||||
|
m_Instance = this;
|
||||||
showMessageCB = showMsgCB;
|
showMessageCB = showMsgCB;
|
||||||
// create a QSettings object that's separate from the main application settings
|
// create a QSettings object that's separate from the main application settings
|
||||||
geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope,
|
geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope,
|
||||||
|
@ -22,6 +26,18 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent)
|
||||||
userAgent = getUserAgent();
|
userAgent = getUserAgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GpsLocation *GpsLocation::instance()
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_Instance != NULL);
|
||||||
|
|
||||||
|
return m_Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpsLocation::~GpsLocation()
|
||||||
|
{
|
||||||
|
m_Instance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
QGeoPositionInfoSource *GpsLocation::getGpsSource()
|
QGeoPositionInfoSource *GpsLocation::getGpsSource()
|
||||||
{
|
{
|
||||||
static QGeoPositionInfoSource *gpsSource = NULL;
|
static QGeoPositionInfoSource *gpsSource = NULL;
|
||||||
|
@ -31,7 +47,10 @@ QGeoPositionInfoSource *GpsLocation::getGpsSource()
|
||||||
gpsSource = QGeoPositionInfoSource::createDefaultSource(this);
|
gpsSource = QGeoPositionInfoSource::createDefaultSource(this);
|
||||||
initGpsSource = true;
|
initGpsSource = true;
|
||||||
if (gpsSource != 0) {
|
if (gpsSource != 0) {
|
||||||
status("created GPS source");
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
if (verbose)
|
||||||
|
#endif
|
||||||
|
status("created GPS source");
|
||||||
QString msg = QString("have position source %1").arg(gpsSource->sourceName());
|
QString msg = QString("have position source %1").arg(gpsSource->sourceName());
|
||||||
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
||||||
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
||||||
|
|
|
@ -14,6 +14,8 @@ class GpsLocation : QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
||||||
|
~GpsLocation();
|
||||||
|
static GpsLocation *instance();
|
||||||
void applyLocations();
|
void applyLocations();
|
||||||
int getGpsNum() const;
|
int getGpsNum() const;
|
||||||
QString getUserid(QString user, QString passwd);
|
QString getUserid(QString user, QString passwd);
|
||||||
|
@ -27,8 +29,7 @@ private:
|
||||||
QNetworkReply *reply;
|
QNetworkReply *reply;
|
||||||
QString userAgent;
|
QString userAgent;
|
||||||
void (*showMessageCB)(const char *msg);
|
void (*showMessageCB)(const char *msg);
|
||||||
|
static GpsLocation *m_Instance;
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void serviceEnable(bool toggle);
|
void serviceEnable(bool toggle);
|
||||||
|
|
Loading…
Add table
Reference in a new issue