Merge branch 'master' of https://vcs.maemo.org/git/situare
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Wed, 26 May 2010 12:36:11 +0000 (15:36 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Wed, 26 May 2010 12:36:11 +0000 (15:36 +0300)
Conflicts:
doc/test_cases/functionality-tests.doc

doc/test_cases/functionality-tests.doc
src/common.h
src/engine/engine.cpp
src/engine/engine.h
src/map/mapengine.cpp
src/map/mapengine.h
tests/map/mapview/mapview.pro
tests/map/uselastlocation/testuselastlocation.cpp
tests/map/uselastlocation/uselastlocation.pro
tests/tests.pro

index 9c1643d..c471008 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index c9669f1..5390f72 100644 (file)
@@ -34,5 +34,6 @@ const QColor COLOR_GRAY = QColor(152, 152, 152);                           ///<
 const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal);    ///< Normal font
 const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);     ///< Small font
 
-const QString ZOOMPANEL_POSITION = "ZoomPanelPosition";
+const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12; ///< Default zoom level when GPS available
+const QString ZOOMPANEL_POSITION = "ZoomPanelPosition"; ///< Zoom panel position string
 #endif // COMMON_H
index 60a2e77..690a668 100644 (file)
@@ -77,25 +77,13 @@ SituareEngine::SituareEngine(QMainWindow *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
+    initializeGpsAndAutocentering();
+
     // signals connected, now it's time to show the main window
     // but init the MapEngine before so starting location is set
     m_mapEngine->init();
     m_ui->show();
 
-    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
-    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
-
-    // set features on / off based on settings
-    changeAutoCenteringSetting(autoCenteringEnabled.toBool());
-    enableGPS(gpsEnabled.toBool());
-
-    // show messages at startup if features are enabled automatically
-    if (gpsEnabled.toBool())
-        m_ui->showMaemoInformationBox(tr("GPS enabled"));
-    if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
-        m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
-
     m_facebookAuthenticator->start();
 }
 
@@ -166,9 +154,40 @@ void SituareEngine::error(const QString &error)
 void SituareEngine::fetchUsernameFromSettings()
 {
     qDebug() << __PRETTY_FUNCTION__;
+
     m_ui->setUsername(m_facebookAuthenticator->loadUsername());
 }
 
+void SituareEngine::initializeGpsAndAutocentering()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
+    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);     
+
+    if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
+
+        connect(m_gps, SIGNAL(position(QPointF,qreal)),
+                this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
+
+        changeAutoCenteringSetting(true);
+        enableGPS(true);
+
+        m_ui->showMaemoInformationBox(tr("GPS enabled"));
+        m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+    } else { // Normal start
+        changeAutoCenteringSetting(autoCenteringEnabled.toBool());
+        enableGPS(gpsEnabled.toBool());
+
+        if (gpsEnabled.toBool())
+            m_ui->showMaemoInformationBox(tr("GPS enabled"));
+
+        if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
+            m_ui->showMaemoInformationBox(tr("Auto centering enabled"));        
+    } 
+}
+
 void SituareEngine::invalidCredentials()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -253,6 +272,20 @@ void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
         m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
 }
 
+void SituareEngine::setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    Q_UNUSED(latLonCoordinate);
+    Q_UNUSED(accuracy);
+
+    if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled        
+        m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
+
+    disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
+               this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
+}
+
 void SituareEngine::signalsFromFacebookAuthenticator()
 {
     qDebug() << __PRETTY_FUNCTION__;
index d171810..eb25a68 100644 (file)
@@ -27,6 +27,7 @@
 #define ENGINE_H
 
 #include <QObject>
+#include <QPointF>
 
 class QMainWindow;
 
@@ -139,6 +140,12 @@ public slots:
 
 private:
     /**
+      * @brief Read settings and determine whether to use GPS and autocentering.
+      * When values does not found on the settings, GPS and autocentering are enabled as a default.
+      */
+    void initializeGpsAndAutocentering();
+
+    /**
       * @brief Connect signals coming from Facdebook authenticator
       */
     void signalsFromFacebookAuthenticator();
@@ -196,6 +203,15 @@ private slots:
     void enableGPS(bool enabled);
 
     /**
+     * @brief Sets zoom level to default when first GPS location is received if autocentering
+     * is enabled.
+     *
+     * @param latLonCoordinate own location
+     * @param accuracy accuracy of GPS location
+     */
+    void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
+    
+    /**
     * @brief Slot for intercepting signal when credentials are invalid
     *
     */
index d8ad37e..9d82755 100644 (file)
@@ -244,16 +244,13 @@ void MapEngine::init()
     QPointF startLocation;
     QSettings settings(DIRECTORY_NAME, FILE_NAME);
 
-    if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() ==
-        ERROR_VALUE_NOT_FOUND_ON_SETTINGS ||
-        settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() ==
-        ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
+    if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString()
+        == ERROR_VALUE_NOT_FOUND_ON_SETTINGS || settings.value(MAP_LAST_ZOOMLEVEL,
+        ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() == ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
 
         startLocation = QPointF(DEFAULT_LONGITUDE, DEFAULT_LATITUDE);
         m_zoomLevel = DEFAULT_START_ZOOM_LEVEL;
-    }
-
-    else {
+    } else {
         m_zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toInt();
         startLocation = settings.value(MAP_LAST_POSITION,
                                        ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
@@ -348,6 +345,14 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
     }
 }
 
+void MapEngine::setZoomLevel(int newZoomLevel)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_zoomLevel = newZoomLevel;
+    emit zoomLevelChanged(m_zoomLevel);
+}
+
 void MapEngine::setViewLocation(QPointF latLonCoordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
index e80061a..1f2d5ba 100644 (file)
@@ -128,6 +128,13 @@ public:
     QGraphicsScene* scene();
 
     /**
+    * @brief Sets new zoom level
+    *
+    * @return newZoomLevel value that is set to new zoom level
+    */
+    void setZoomLevel(const int newZoomLevel);
+
+    /**
     * @brief Return tile path created from tile values.
     *
     * @param zoomLevel tile's zoom level
@@ -175,7 +182,7 @@ public slots:
     *
     * @param latLonCoordinate Latitude & longitude coordinates for location
     */
-    void setViewLocation(QPointF latLonCoordinate);
+    void setViewLocation(QPointF latLonCoordinate);    
 
     /**
     * @brief Slot for view resizing.
index aa145fa..e8234b4 100644 (file)
@@ -2,7 +2,7 @@
 # Automatically generated by qmake (2.01a) Fri Mar 26 15:22:56 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += opengl
+#QT += opengl
 TEMPLATE = app
 TARGET = 
 DEPENDPATH += .
index 15f2156..164edd3 100644 (file)
@@ -67,8 +67,7 @@ class TestUseLastPosition: public QObject
      // Check parameters of sended signals
      QList<QVariant> parameters = mapEngineSpy.takeFirst();
      QVERIFY(parameters.at(0).toInt() == DEFAULT_TEST_ZOOMLEVEL);
-//     parameters = mapEngineSpy.takeFirst();
-//     QVERIFY(parameters.at(0).toInt() == 0);
+
      parameters = mapEngineSpy.takeFirst();
      QVERIFY(parameters.at(0).toInt() == DEFAULT_START_ZOOM_LEVEL);
 
index 8d92a32..4dcdbd8 100644 (file)
@@ -26,12 +26,10 @@ SOURCES += testuselastlocation.cpp \
     ../../../src/map/friendlocationitem.cpp \
     ../../../src/map/friendgroupitem.cpp \
     ../../../src/ui/mainwindow.cpp \
-    ../../../src/ui/mapviewscreen.cpp \
     ../../../src/ui/settingsdialog.cpp \
     ../../../src/ui/logindialog.cpp \
     ../../../src/map/mapview.cpp \
     ../../../src/ui/friendlistpanel.cpp \
-    ../../../src/ui/userpanel.cpp \
     ../../../src/ui/panelsidebar.cpp \
     ../../../src/ui/zoombuttonpanel.cpp \
     ../../../src/ui/friendlistview.cpp \
@@ -40,7 +38,10 @@ SOURCES += testuselastlocation.cpp \
     ../../../src/ui/userinfo.cpp \
     ../../../src/ui/imagebutton.cpp \
     ../../../src/ui/updatelocation/updatelocationdialog.cpp \
-    ../../../src/ui/updatelocation/texteditautoresizer.cpp
+    ../../../src/ui/updatelocation/texteditautoresizer.cpp \
+    ../../../src/ui/userinfopanel.cpp \
+    ../../../src/ui/sidepanel.cpp \
+    ../../../src/ui/zoombutton.cpp
 
 HEADERS += ../../../src/map/mapengine.h \
     ../../../src/map/mapscene.h \
@@ -55,12 +56,10 @@ HEADERS += ../../../src/map/mapengine.h \
     ../../../src/map/friendlocationitem.h \
     ../../../src/map/friendgroupitem.h \
     ../../../src/ui/mainwindow.h \
-    ../../../src/ui/mapviewscreen.h \
     ../../../src/ui/settingsdialog.h \
     ../../../src/ui/logindialog.h \
     ../../../src/map/mapview.h \
     ../../../src/ui/friendlistpanel.h \
-    ../../../src/ui/userpanel.h \
     ../../../src/ui/panelsidebar.h \
     ../../../src/ui/zoombuttonpanel.h \
     ../../../src/ui/friendlistview.h \
@@ -69,7 +68,10 @@ HEADERS += ../../../src/map/mapengine.h \
     ../../../src/ui/userinfo.h \
     ../../../src/ui/imagebutton.h \
     ../../../src/ui/updatelocation/updatelocationdialog.h \
-    ../../../src/ui/updatelocation/texteditautoresizer.h
+    ../../../src/ui/updatelocation/texteditautoresizer.h \
+    ../../../src/ui/userinfopanel.h \
+    ../../../src/ui/sidepanel.h \
+    ../../../src/ui/zoombutton.h
 
 
 
index 990fbc4..f4aeb0c 100644 (file)
@@ -7,6 +7,7 @@ SUBDIRS = map/mapengine \
           map/friendgroupitem \
           map/mapscene \
           map/friendlocationitem \
+          map/uselastlocation \
           user \
           ui/friendlist \
           ui/zoombuttonpanel