From fd03621a4b1e82c218dddbc7e833838ef3fdf7be Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Tue, 25 Jul 2017 11:44:30 +0200 Subject: Mobile: honour location service time threshold Independ of the settings, the threshold to reset the GPS data was hard coded to 5 minutes. Now, honour the entered (and updated during a session) time to refresh the GPS data in the location service. Signed-off-by: Jan Mulder --- core/gpslocation.cpp | 10 +++++++++- core/gpslocation.h | 1 + mobile-widgets/qmlmanager.cpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index 30b101419..a823a9124 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -56,6 +56,14 @@ GpsLocation::~GpsLocation() m_Instance = NULL; } +void GpsLocation::setGpsTimeThreshold(int seconds) +{ + if (m_GpsSource) { + m_GpsSource->setUpdateInterval(seconds * 1000); + status(QString("Set GPS service update interval to %1").arg(m_GpsSource->updateInterval())); + } +} + QGeoPositionInfoSource *GpsLocation::getGpsSource() { if (haveSource == NOGPS) @@ -86,7 +94,7 @@ QGeoPositionInfoSource *GpsLocation::getGpsSource() connect(m_GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo))); connect(m_GpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); connect(m_GpsSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(positionSourceError(QGeoPositionInfoSource::Error))); - m_GpsSource->setUpdateInterval(5 * 60 * 1000); // 5 minutes so the device doesn't drain the battery + setGpsTimeThreshold(prefs.time_threshold); } else { #ifdef SUBSURFACE_MOBILE status("don't have GPS source"); diff --git a/core/gpslocation.h b/core/gpslocation.h index 9922997f1..efb1b34df 100644 --- a/core/gpslocation.h +++ b/core/gpslocation.h @@ -33,6 +33,7 @@ public: QString getUserid(QString user, QString passwd); bool hasLocationsSource(); QString currentPosition(); + void setGpsTimeThreshold(int seconds); QMap currentGPSInfo() const; diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index cc9b1356d..cb594a13d 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1307,6 +1307,7 @@ int QMLManager::timeThreshold() const void QMLManager::setTimeThreshold(int time) { m_timeThreshold = time; + locationProvider->setGpsTimeThreshold(m_timeThreshold * 60); emit timeThresholdChanged(); } -- cgit v1.2.3-70-g09d2