From 962341ae9f781e10a6276b9f7d81d9da72bd90f6 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 2 Dec 2015 14:30:47 -0800 Subject: Add instance method for GpsLocation This way we can call members from different parts of the code. Signed-off-by: Dirk Hohndel --- subsurface-core/gpslocation.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'subsurface-core/gpslocation.cpp') diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp index e75856a98..532c142b6 100644 --- a/subsurface-core/gpslocation.cpp +++ b/subsurface-core/gpslocation.cpp @@ -13,8 +13,12 @@ #define GPS_FIX_ADD_URL "http://api.subsurface-divelog.org/api/dive/add/" #define GET_WEBSERVICE_UID_URL "https://cloud.subsurface-divelog.org/webuserid/" +GpsLocation *GpsLocation::m_Instance = NULL; + GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) { + Q_ASSERT_X(m_Instance == NULL, "GpsLocation", "GpsLocation recreated"); + m_Instance = this; showMessageCB = showMsgCB; // create a QSettings object that's separate from the main application settings geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope, @@ -22,6 +26,18 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) userAgent = getUserAgent(); } +GpsLocation *GpsLocation::instance() +{ + Q_ASSERT(m_Instance != NULL); + + return m_Instance; +} + +GpsLocation::~GpsLocation() +{ + m_Instance = NULL; +} + QGeoPositionInfoSource *GpsLocation::getGpsSource() { static QGeoPositionInfoSource *gpsSource = NULL; @@ -31,7 +47,10 @@ QGeoPositionInfoSource *GpsLocation::getGpsSource() gpsSource = QGeoPositionInfoSource::createDefaultSource(this); initGpsSource = true; 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()); connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo))); connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); -- cgit v1.2.3-70-g09d2