Power save mode review and iteration.
[situare] / src / engine / engine.cpp
index 65ed9a2..f5358c8 100644 (file)
@@ -91,7 +91,7 @@ SituareEngine::SituareEngine(QMainWindow *parent)
 
     m_automaticUpdateIntervalTimer = new QTimer(this);
     connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
-            this, SLOT(automaticUpdateIntervalTimerTimeout()));
+            this, SLOT(startAutomaticUpdate()));
 
     // signals connected, now it's time to show the main window
     // but init the MapEngine before so starting location is set
@@ -104,7 +104,7 @@ SituareEngine::SituareEngine(QMainWindow *parent)
     initializeGpsAndAutocentering();
 
     m_mce = new MCE(this);
-    connect(m_mce, SIGNAL(displayOn(bool)), this, SLOT(displayOn(bool)));
+    connect(m_mce, SIGNAL(displayStateChanged(bool)), this, SLOT(displayStateChanged(bool)));
 }
 
 SituareEngine::~SituareEngine()
@@ -118,14 +118,6 @@ SituareEngine::~SituareEngine()
     settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
 }
 
-void SituareEngine::automaticUpdateIntervalTimerTimeout()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_gps->requestUpdate();
-    m_automaticUpdateRequest = true;
-}
-
 void SituareEngine::changeAutoCenteringSetting(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -142,14 +134,14 @@ void SituareEngine::disableAutoCentering()
     m_ui->buildInformationBox(tr("Auto centering disabled"));
 }
 
-void SituareEngine::displayOn(bool on)
+void SituareEngine::displayStateChanged(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_gps->enablePowerSave(!on);
+    m_gps->enablePowerSave(!enabled);
 
     if (m_autoCenteringEnabled)
-        enableAutoCentering(on);
+        enableAutoCentering(enabled);
 }
 
 void SituareEngine::enableAutoCentering(bool enabled)
@@ -214,13 +206,13 @@ void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateInterv
                 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
 
             connect(m_gps, SIGNAL(position(QPointF,qreal)),
-                    this, SLOT(saveGPSPosition(QPointF)));
+                    this, SLOT(requestAutomaticUpdateIfMoved(QPointF)));
 
             m_automaticUpdateIntervalTimer->start();
 
         } else {
             disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
-                    this, SLOT(saveGPSPosition(QPointF)));
+                    this, SLOT(requestAutomaticUpdateIfMoved(QPointF)));
 
             m_automaticUpdateIntervalTimer->stop();
         }
@@ -420,7 +412,7 @@ void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
         m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
 }
 
-void SituareEngine::saveGPSPosition(QPointF position)
+void SituareEngine::requestAutomaticUpdateIfMoved(QPointF position)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -434,7 +426,7 @@ void SituareEngine::saveGPSPosition(QPointF position)
     }
 
     if (m_automaticUpdateRequest && m_userMoved) {
-        requestUpdateLocation(tr("Automatic location update"));
+        requestUpdateLocation(tr("Automatic location update."));
         m_automaticUpdateRequest = false;
         m_userMoved = false;
     }
@@ -611,6 +603,14 @@ void SituareEngine::signalsFromSituareService()
             m_ui, SIGNAL(clearUpdateLocationDialogData()));
 }
 
+void SituareEngine::startAutomaticUpdate()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_gps->requestUpdate();
+    m_automaticUpdateRequest = true;
+}
+
 void SituareEngine::updateWasSuccessful()
 {
     qDebug() << __PRETTY_FUNCTION__;