Show cross-hair always when not auto centering
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 29 Jul 2010 12:40:08 +0000 (15:40 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 29 Jul 2010 12:40:08 +0000 (15:40 +0300)
 - Reviewed by Henri Lampela

 - Show cross-hair always when auto centering is disabled and vice
   versa. Cross-hair is shown also when not logged in. Also the
   functional tests document was updated.

 - Enable GPS when auto centering is enabled

doc/testing/functionality-tests.doc
src/engine/engine.cpp
src/engine/engine.h
src/gps/gpspositionprivateliblocation.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index abe8e45..551cb19 100644 (file)
Binary files a/doc/testing/functionality-tests.doc and b/doc/testing/functionality-tests.doc differ
index 9b78942..2ab3808 100644 (file)
@@ -146,10 +146,10 @@ SituareEngine::~SituareEngine()
 
 void SituareEngine::changeAutoCenteringSetting(bool enabled)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
 
     m_autoCenteringEnabled = enabled;
-    enableAutoCentering(enabled);
+    setAutoCentering(enabled);
 }
 
 void SituareEngine::disableAutoCentering()
@@ -159,49 +159,6 @@ void SituareEngine::disableAutoCentering()
     changeAutoCenteringSetting(false);
 }
 
-void SituareEngine::enableAutoCentering(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_ui->setIndicatorButtonEnabled(enabled);
-    m_mapEngine->setAutoCentering(enabled);
-
-    if (enabled)
-        m_gps->requestLastPosition();
-}
-
-void SituareEngine::enableGPS(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_ui->setOwnLocationCrosshairVisibility(!enabled);
-
-    if (m_gps->isInitialized()) {
-        m_ui->setGPSButtonEnabled(enabled);
-        m_mapEngine->setGPSEnabled(enabled);
-
-        if (enabled && !m_gps->isRunning()) {
-            m_gps->start();
-            enableAutoCentering(m_autoCenteringEnabled);
-            m_gps->requestLastPosition();
-
-            if(m_ui->loginState())
-                m_ui->readAutomaticLocationUpdateSettings();
-        }
-        else if (!enabled && m_gps->isRunning()) {
-            m_gps->stop();
-            enableAutoCentering(false);
-            enableAutomaticLocationUpdate(false);
-        }
-    }
-    else {
-        if (enabled)
-            m_ui->buildInformationBox(tr("Unable to start GPS"));
-        m_ui->setGPSButtonEnabled(false);
-        m_mapEngine->setGPSEnabled(false);
-    }
-}
-
 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -236,7 +193,7 @@ void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateInterv
 
 void SituareEngine::enablePowerSave(bool enabled)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
 
     m_gps->enablePowerSave(enabled);
 
@@ -321,7 +278,7 @@ void SituareEngine::error(const int context, const int error)
         m_ui->buildInformationBox(tr("Map image download failed"), true);
         break;
     case SituareError::GPS_INITIALIZATION_FAILED:
-        enableGPS(false);
+        setGPS(false);
         m_ui->buildInformationBox(tr("GPS initialization failed"), true);
         break;
     case SituareError::INVALID_JSON:
@@ -377,19 +334,19 @@ void SituareEngine::initializeGpsAndAutocentering()
                     this, SLOT(setFirstStartZoomLevel()));
 
             changeAutoCenteringSetting(true);
-            enableGPS(true);
+            setGPS(true);
 
             m_ui->buildInformationBox(tr("GPS enabled"));
 
         } else { // Normal start
             changeAutoCenteringSetting(autoCenteringEnabled.toBool());
-            enableGPS(gpsEnabled.toBool());
+            setGPS(gpsEnabled.toBool());
 
             if (gpsEnabled.toBool())
                 m_ui->buildInformationBox(tr("GPS enabled"));
         }
     } else {
-        enableGPS(false);
+        setGPS(false);
     }
 }
 
@@ -526,6 +483,20 @@ void SituareEngine::requestAutomaticUpdateIfMoved(GeoCoordinate position)
     }
 }
 
+void SituareEngine::setAutoCentering(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
+
+    m_ui->setIndicatorButtonEnabled(enabled);
+    m_mapEngine->setAutoCentering(enabled);
+    m_ui->setOwnLocationCrosshairVisibility(!enabled);
+
+    if (enabled) {
+        setGPS(true);
+        m_gps->requestLastPosition();
+    }
+}
+
 void SituareEngine::setFirstStartZoomLevel()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -537,6 +508,35 @@ void SituareEngine::setFirstStartZoomLevel()
                this, SLOT(setFirstStartZoomLevel()));
 }
 
+void SituareEngine::setGPS(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
+
+    if (m_gps->isInitialized()) {
+        m_ui->setGPSButtonEnabled(enabled);
+        m_mapEngine->setGPSEnabled(enabled);
+
+        if (enabled && !m_gps->isRunning()) {
+            m_gps->start();
+            m_gps->requestLastPosition();
+
+            if(m_ui->loginState())
+                m_ui->readAutomaticLocationUpdateSettings();
+        }
+        else if (!enabled && m_gps->isRunning()) {
+            m_gps->stop();
+            changeAutoCenteringSetting(false);
+            enableAutomaticLocationUpdate(false);
+        }
+    }
+    else {
+        if (enabled)
+            m_ui->buildInformationBox(tr("Unable to start GPS"));
+        m_ui->setGPSButtonEnabled(false);
+        m_mapEngine->setGPSEnabled(false);
+    }
+}
+
 void SituareEngine::signalsFromFacebookAuthenticator()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -612,7 +612,7 @@ void SituareEngine::signalsFromMainWindow()
 
     // signals from menu buttons
     connect(m_ui, SIGNAL(gpsTriggered(bool)),
-            this, SLOT(enableGPS(bool)));
+            this, SLOT(setGPS(bool)));
 
     //signals from dialogs
     connect(m_ui, SIGNAL(cancelLoginProcess()),
index b710b3b..72a0c63 100644 (file)
@@ -215,22 +215,6 @@ private slots:
     void disableAutoCentering();
 
     /**
-    * @brief Slot for auto centering enabling.
-    *
-    * Calls gps to send last known position
-    *
-    * @param enabled true if auto centering was enabled, false otherwise
-    */
-    void enableAutoCentering(bool enabled);
-
-    /**
-    * @brief Slot for gps enabling.
-    *
-    * @param enabled true if gps should be enabled, false otherwise
-    */
-    void enableGPS(bool enabled);
-
-    /**
     * @brief Enables automatic location update.
     *
     * @param enabled true if enabled, false otherwise
@@ -262,12 +246,28 @@ private slots:
     void requestAutomaticUpdateIfMoved(GeoCoordinate position);
 
     /**
+    * @brief Slot for setting auto centering state.
+    *
+    * Calls gps to send last known position
+    *
+    * @param enabled true if auto centering was enabled, false otherwise
+    */
+    void setAutoCentering(bool enabled);
+
+    /**
      * @brief Sets zoom level to default when first GPS location is received if autocentering
      * is enabled.
      */
     void setFirstStartZoomLevel();
 
     /**
+    * @brief Slot for setting GPS state.
+    *
+    * @param enabled true if gps should be enabled, false otherwise
+    */
+    void setGPS(bool enabled);
+
+    /**
     * @brief Automatic update interval timer timeout.
     *
     * Requests update location if user has moved.
index 24ea392..5dced5a 100644 (file)
@@ -125,6 +125,8 @@ void GPSPositionPrivate::start()
         m_liblocationWrapper->startUpdates();
         m_running = true;
     }
+
+    setPowerSave(false);
 }
 
 void GPSPositionPrivate::stop()
index 7f5997f..ee2c85e 100644 (file)
@@ -53,7 +53,6 @@
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent),
-    m_drawOwnLocationCrosshair(false),
     m_errorShown(false),
     m_loggedIn(false),
     m_refresh(false),
@@ -532,7 +531,7 @@ void MainWindow::drawOwnLocationCrosshair(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
+    if (m_ownLocationCrosshair != 0) {
         m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2,
                             size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2);
     }
@@ -799,8 +798,6 @@ void MainWindow::setGPSButtonEnabled(bool enabled)
     qDebug() << __PRETTY_FUNCTION__;
 
     m_gpsToggleAct->setChecked(enabled);
-
-    setOwnLocationCrosshairVisibility(!enabled);
 }
 
 void MainWindow::setIndicatorButtonEnabled(bool enabled)
@@ -822,13 +819,11 @@ void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (visibility && m_loggedIn) {
+    if (visibility) {
         m_ownLocationCrosshair->show();
-        m_drawOwnLocationCrosshair = true;
         drawOwnLocationCrosshair(m_viewPortSize);
     } else {
         m_ownLocationCrosshair->hide();
-        m_drawOwnLocationCrosshair = false;
     }
 }
 
@@ -969,18 +964,13 @@ void MainWindow::updateItemVisibility()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(m_loggedIn) {
-
-        if(!m_gpsToggleAct->isChecked())
-            setOwnLocationCrosshairVisibility(true);
-    } else {
+    if(!m_loggedIn) {
         m_friendsListPanel->closePanel();
         m_friendsListPanel->hide();
         m_friendsListPanelSidebar->hide();
         m_userPanel->closePanel();
         m_userPanel->hide();
         m_userPanelSidebar->hide();
-        setOwnLocationCrosshairVisibility(false);
     }
 }
 
index 6c0177f..1d59362 100644 (file)
@@ -113,13 +113,6 @@ public:
      */
     void readAutomaticLocationUpdateSettings();
 
-//    /**
-//     * @brief Enable / disable auto centering button.
-//     *
-//     * @param enabled true if shoud be enabled, false otherwise
-//     */
-//    void setAutoCenteringButtonEnabled(bool enabled);
-
     /**
      * @brief Enable / disable GPS button.
      *
@@ -615,14 +608,12 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
     bool m_errorShown;                      ///< Indicates if error dialog/note is shown
     bool m_loggedIn;                        ///< Indicates login state
     bool m_refresh;                         ///< Indicates when webpage is refreshed
 
     int m_progressIndicatorCount;           ///< Indicates the number of progress indicator calls
 
-    QAction *m_autoCenteringAct;            ///< Action to auto center map using gps position
     QAction *m_gpsToggleAct;                ///< Action to trigger gps toggle
     QAction *m_loginAct;                    ///< Action to Login/Logout
     QAction *m_toSettingsAct;               ///< Action to trigger switch to settings dialog