Power save mode review and iteration.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 22 Jun 2010 12:05:03 +0000 (15:05 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 22 Jun 2010 12:05:03 +0000 (15:05 +0300)
Reviewed by: Sami Rämö.

src/engine/engine.cpp
src/engine/engine.h
src/gps/gpsposition.cpp
src/gps/gpspositionprivate.cpp
src/gps/gpspositionprivate.h
src/gps/gpspositionprivateliblocation.cpp
src/gps/gpspositionprivateliblocation.h

index 6ac9974..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)
@@ -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__;
index c5ae5a4..fd66a99 100644 (file)
@@ -179,13 +179,6 @@ private:
 
 private slots:
     /**
-    * @brief Automatic update interval timer timeout.
-    *
-    * Requests update location if user has moved.
-    */
-    void automaticUpdateIntervalTimerTimeout();
-
-    /**
     * @brief Set auto centering feature enabled / disabled
     *
     * @param enabled true if enabled, false otherwise
@@ -198,6 +191,13 @@ private slots:
     void disableAutoCentering();
 
     /**
+    * @brief Slot for display state changed.
+    *
+    * @param enabled true if enabled, false otherwise
+    */
+    void displayStateChanged(bool enabled);
+
+    /**
     * @brief Slot for auto centering enabling.
     *
     * Calls gps to send last known position
@@ -222,11 +222,13 @@ private slots:
     void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
 
     /**
-    * @brief Slot for display on.
+    * @brief Requests automatic update.
     *
-    * @param on true if on, false otherwise
+    * Makes automatic location update request if user has moved enough.
+    *
+    * @param position geo coordinates
     */
-    void displayOn(bool on);
+    void requestAutomaticUpdateIfMoved(QPointF position);
 
     /**
      * @brief Sets zoom level to default when first GPS location is received if autocentering
@@ -238,13 +240,11 @@ private slots:
     void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
 
     /**
-    * @brief Requests automatic update.
-    *
-    * Makes automatic location update request if user has moved enough.
+    * @brief Automatic update interval timer timeout.
     *
-    * @param position geo coordinates
+    * Requests update location if user has moved.
     */
-    void requestAutomaticUpdateIfMoved(QPointF position);
+    void startAutomaticUpdate();
 
 /*******************************************************************************
  * SIGNALS
index 7185d32..282c6cb 100644 (file)
@@ -44,7 +44,7 @@ void GPSPosition::enablePowerSave(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_gpsPositionPrivate->enablePowerSave(enabled);
+    m_gpsPositionPrivate->setPowerSave(enabled);
 }
 
 bool GPSPosition::isInitialized()
index 66a7bef..9f6b7c4 100644 (file)
@@ -42,7 +42,7 @@ GPSPositionPrivate::GPSPositionPrivate(QObject *parent)
     m_parent = static_cast<GPSPosition*>(parent);
 }
 
-void GPSPositionPrivate::enablePowerSave(bool enabled)
+void GPSPositionPrivate::setPowerSave(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__;
 }
index 3e578c1..213c4ea 100644 (file)
@@ -52,13 +52,6 @@ public:
 ******************************************************************************/
 public:
     /**
-    * @brief Enables power save mode.
-    *
-    * Starts GPS for position update and then stops it.
-    */
-    void enablePowerSave(bool enabled);
-
-    /**
     * @brief Returns is GPS initialized.
     *
     * @return true if initialized, false otherwise
@@ -99,6 +92,13 @@ public:
     void setMode(GPSPosition::Mode mode, const QString &filePath = 0);
 
     /**
+    * @brief Sets power save mode.
+    *
+    * Starts GPS for position update and then stops it.
+    */
+    void setPowerSave(bool enabled);
+
+    /**
     * @brief Set GPS update interval
     *
     * @return interval interval in milliseconds
index 4b175c4..5606585 100644 (file)
@@ -60,24 +60,6 @@ void GPSPositionPrivate::delayedPowerSaveStart()
     m_liblocationWrapper->stopUpdates();
 }
 
-void GPSPositionPrivate::enablePowerSave(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    if (isRunning()) {
-        if (enabled) {
-            m_delayedPowerSaveTimer->start();
-        } else {
-            m_powerSave = false;
-            m_delayedPowerSaveTimer->stop();
-            m_liblocationWrapper->startUpdates();
-        }
-    }
-    else {
-        m_powerSave = false;
-    }
-}
-
 bool GPSPositionPrivate::isInitialized()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -117,6 +99,24 @@ void GPSPositionPrivate::setMode(GPSPosition::Mode mode, const QString &filePath
     }
 }
 
+void GPSPositionPrivate::setPowerSave(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (isRunning()) {
+        if (enabled) {
+            m_delayedPowerSaveTimer->start();
+        } else {
+            m_powerSave = false;
+            m_delayedPowerSaveTimer->stop();
+            m_liblocationWrapper->startUpdates();
+        }
+    }
+    else {
+        m_powerSave = false;
+    }
+}
+
 void GPSPositionPrivate::start()
 {
     qDebug() << __PRETTY_FUNCTION__;
index 6560370..eae5141 100644 (file)
@@ -50,13 +50,6 @@ public:
 ******************************************************************************/
 public:
     /**
-    * @brief Enables power save mode.
-    *
-    * Starts GPS for position update and then stops it.
-    */
-    void enablePowerSave(bool enabled);
-
-    /**
     * @brief Returns is GPS initialized.
     *
     * @return true if initialized, false otherwise
@@ -97,6 +90,13 @@ public:
     void setMode(GPSPosition::Mode mode, const QString &filePath = 0);
 
     /**
+    * @brief Sets power save mode.
+    *
+    * Starts GPS for position update and then stops it.
+    */
+    void setPowerSave(bool enabled);
+
+    /**
     * @brief Set GPS update interval
     *
     * @return interval interval in milliseconds
@@ -124,6 +124,9 @@ private:
     qreal accuracy(const GeoPositionInfo &positionInfo);
 
 private slots:
+    /**
+    * @brief Start power save.
+    */
     void delayedPowerSaveStart();
 
     /**