Added settings load and save methods to Engine and MainWindow. list_panel
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 12 May 2010 13:51:36 +0000 (16:51 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 12 May 2010 13:51:36 +0000 (16:51 +0300)
21 files changed:
src/engine/engine.cpp
src/engine/engine.h
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookcommon.h
src/gps/gpsposition.cpp
src/gps/gpsposition.h
src/gps/gpspositioninterface.h
src/gps/gpspositionmockup.cpp
src/gps/gpspositionmockup.h
src/map/mapcommon.h
src/map/mapengine.cpp
src/map/mapengine.h
src/situarecommon.h [new file with mode: 0644]
src/src.pro
src/ui/friendlistitem.cpp
src/ui/friendlistitem.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h
src/ui/settingsdialog.cpp

index 0ebc402..184224a 100644 (file)
@@ -21,6 +21,7 @@
     USA.
  */
 
+#include "situarecommon.h"
 #include "engine.h"
 #include "ui/mainwindow.h"
 #include "gps/gpspositioninterface.h"
@@ -80,8 +81,10 @@ SituareEngine::SituareEngine(QMainWindow *parent)
             m_ui, SLOT(gpsError(QString)));
     connect(m_ui, SIGNAL(enableGPS(bool)),
             this, SLOT(enableGPS(bool)));
-    connect(m_gps, SIGNAL(position(QPointF)),
-            m_ui, SIGNAL(positionReceived(QPointF)));
+    connect(m_gps, SIGNAL(position(QPointF, qreal)),
+            m_ui, SIGNAL(positionReceived(QPointF, qreal)));
+    connect(m_ui, SIGNAL(enableAutoCentering(bool)),
+            this, SLOT(enableAutoCentering(bool)));
 
      m_facebookAuthenticator->start();
 }
@@ -89,6 +92,7 @@ SituareEngine::SituareEngine(QMainWindow *parent)
 SituareEngine::~SituareEngine()
 {
     qDebug() << __PRETTY_FUNCTION__;
+
     delete m_ui;
 }
 
@@ -111,14 +115,19 @@ void SituareEngine::loginOk()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    QVariant gpsEnabled = settings.value(GPS_ENABLED);
+    QVariant autoCenteringEnabled = settings.value(AUTO_CENTERING_ENABLED);
+
     m_facebookAuthenticator->setAttribute(Qt::WA_DeleteOnClose);
     m_facebookAuthenticator->close();
     m_ui->show();
     m_situareService->fetchLocations(); // request user locations
 
-    //Debug, use settings instead
-    enableGPS(true);
-    m_ui->autoCenteringToggled(true);
+    qDebug() << __PRETTY_FUNCTION__ << "GPS: " << gpsEnabled;
+    qDebug() << __PRETTY_FUNCTION__ << "Center: " << autoCenteringEnabled;
+    enableGPS(gpsEnabled.toBool());
+    enableAutoCentering(autoCenteringEnabled.toBool());
 }
 
 void SituareEngine::requestAddress()
@@ -167,10 +176,30 @@ void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
 
 void SituareEngine::enableGPS(bool enabled)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
 
-    if (enabled)
+    if (enabled) {
+        m_gps->lastPosition();
         m_gps->start();
-    else
+        m_ui->setGPSButton(true);
+    }
+    else {
         m_gps->stop();
+        m_ui->setGPSButton(false);
+    }
+}
+
+void SituareEngine::enableAutoCentering(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
+
+    if (enabled) {
+        m_ui->setAutoCenteringButton(true);
+        m_ui->autoCenteringEnabled(true);
+        m_gps->lastPosition();
+    }
+    else {
+        m_ui->setAutoCenteringButton(false);
+        m_ui->autoCenteringEnabled(false);
+    }
 }
index edb3b27..f04687c 100644 (file)
@@ -110,6 +110,14 @@ public slots:
     void userDataChanged(User *user, QList<User *> &friendsList);
 
     /**
+    * @brief Slot for auto centering enabling.
+    *
+    * Calls gps to send last known position
+    * @parma enabled true if auto centering was enabled, false otherwise
+    */
+    void enableAutoCentering(bool enabled);
+
+    /**
     * @brief Slot for gps enabling.
     *
     * @parma enabled true if gps should be enabled, false otherwise
index 8dbaf02..f35ac34 100644 (file)
@@ -29,6 +29,7 @@
 #include <QMaemo5InformationBox>
 #endif // Q_WS_MAEMO_5
 
+#include "situarecommon.h"
 #include "facebookauthentication.h"
 #include "facebookcommon.h"
 #include "parser.h"
index fd2ee1f..7758978 100644 (file)
@@ -51,8 +51,4 @@ const QString LOGIN_SUCCESS_REPLY = "http://www.facebook.com/connect/login_succe
 const QString LOGIN_FAILURE_REPLY = "https://login.facebook.com/login.php?login_attempt=";
 const QString LOGIN_PAGE = "http://www.facebook.com/login.php?api_key=";
 
-// QSettings identifiers
-const QString DIRECTORY_NAME = "Ixonos";
-const QString FILE_NAME = "Situare";
-
 #endif // FACEBOOKCOMMON_H
index 6f43d9b..8217565 100644 (file)
@@ -92,12 +92,29 @@ void GPSPosition::update()
     emit m_gpsSource->requestUpdate(DEFAULT_UPDATE_INTERVAL);
 }
 
+void GPSPosition::lastPosition()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QGeoCoordinate coordinate = m_gpsSource->lastKnownPosition().coordinate();
+
+    if (coordinate.isValid()) {
+        qreal accuracy = biggerAccuracy(m_gpsSource->lastKnownPosition());
+        emit position(QPointF(coordinate.longitude(), coordinate.latitude()), accuracy);
+    }
+}
+
 void GPSPosition::positionUpdated(QGeoPositionInfo positionInfo)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    emit position(QPointF(positionInfo.coordinate().longitude(),
-                          positionInfo.coordinate().latitude()));
+    if (positionInfo.coordinate().isValid()) {
+
+        qreal accuracy = biggerAccuracy(positionInfo);
+
+        emit position(QPointF(positionInfo.coordinate().longitude(),
+                          positionInfo.coordinate().latitude()), accuracy);
+    }
 }
 
 void GPSPosition::updateTimeout()
@@ -109,8 +126,31 @@ void GPSPosition::updateTimeout()
 
 void GPSPosition::setUpdateInterval(int interval)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     if (m_updateInterval != interval) {
         m_updateInterval = interval;
         m_gpsSource->setUpdateInterval(m_updateInterval);
     }
 }
+
+qreal GPSPosition::biggerAccuracy(QGeoPositionInfo positionInfo)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    qreal horizontalAccuracy = -1;
+    qreal verticalAccuracy = -1;
+
+    if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+        horizontalAccuracy = positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy);
+
+    if (positionInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
+        verticalAccuracy = positionInfo.attribute(QGeoPositionInfo::VerticalAccuracy);
+
+    int accuracy = verticalAccuracy;
+
+    if (horizontalAccuracy > accuracy)
+        accuracy = horizontalAccuracy;
+
+    return accuracy;
+}
index 329cef7..6d4481d 100644 (file)
@@ -63,6 +63,11 @@ public:
     bool isRunning();
 
     /**
+    * @brief Informs gps to emit last known position.
+    */
+    void lastPosition();
+
+    /**
     * @brief Set GPS update interval
     *
     * @return interval interval in milliseconds
@@ -79,6 +84,15 @@ public:
     */
     void stop();
 
+private:
+    /**
+    * @brief Return bigger accuracy value from latitude and longitude values.
+    *
+    * @param positionInfo geo position info
+    * @return bigger accuracy value, -1 if undefined
+    */
+    qreal biggerAccuracy(QGeoPositionInfo positionInfo);
+
 private slots:
 
     /**
index 28aa234..fb948a0 100644 (file)
@@ -60,6 +60,11 @@ public:
     virtual bool isRunning() = 0;
 
     /**
+    * @brief Informs gps to emit last known position.
+    */
+    virtual void lastPosition() = 0;
+
+    /**
     * @brief Set GPS update interval
     *
     * @return interval interval in milliseconds
@@ -97,8 +102,9 @@ signals:
     * @brief Signal for position information.
     *
     * @param latLonCoordinate latitude and longitude values
+    * @param accuracy accuracy in metres
     */
-    void position(QPointF latLonCoordinate);
+    void position(QPointF latLonCoordinate, qreal accuracy);
 
     /**
     * @brief Signal for timeout.
index 127ec77..1729916 100644 (file)
@@ -60,3 +60,8 @@ void GPSPositionMockup::update()
 {
     qDebug() << __PRETTY_FUNCTION__;
 }
+
+void GPSPositionMockup::lastPosition()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
index 5191fb9..62c2aea 100644 (file)
@@ -61,6 +61,13 @@ public:
     bool isRunning();
 
     /**
+    * @brief Informs gps to emit last known position.
+    *
+    * DOES NOTHING.
+    */
+    void lastPosition();
+
+    /**
     * @brief Set GPS update interval.
     *
     * DOES NOTHING.
index 264d2c7..85a9e44 100644 (file)
@@ -70,6 +70,8 @@ const int GRID_PADDING = 1;  ///< Grid padding used in tile grid calculation
 
 const QString OSM_LICENSE = QString::fromUtf8("© OpenStreetMap contributors, CC-BY-SA");
 
+const int AUTO_CENTERING_DISABLE_DISTANCE = 200; ///< Distance in pixels
+
 /**
 * @var UNDEFINED
 * @brief Value to be used when zoom level, tile numbers or position are not defined
index 8cd40d2..5bc7a17 100644 (file)
 
 MapEngine::MapEngine(QObject *parent)
     : QObject(parent)
+    , m_autoCenteringEnabled(false)
     , m_centerTile(QPoint(UNDEFINED, UNDEFINED))
+    , m_lastManualPosition(QPoint(0, 0))
     , m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
     , m_zoomedIn(false)
     , m_zoomLevel(DEFAULT_ZOOM_LEVEL)
+
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -81,7 +84,11 @@ void MapEngine::setViewLocation(QPointF latLonCoordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    setLocation(convertLatLonToSceneCoordinate(latLonCoordinate));
+    QPoint sceneCoordinate = convertLatLonToSceneCoordinate(latLonCoordinate);
+
+    m_lastManualPosition = sceneCoordinate;
+
+    setLocation(sceneCoordinate);
 }
 
 void MapEngine::mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image)
@@ -142,6 +149,9 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    if (disableAutoCentering(sceneCoordinate))
+        emit mapScrolled();
+
     m_sceneCoordinate = sceneCoordinate;
     emit locationChanged(m_sceneCoordinate);
 
@@ -329,3 +339,30 @@ void MapEngine::receiveOwnLocation(User *user)
     if (!m_ownLocation->isVisible())
         m_ownLocation->show();
 }
+
+bool MapEngine::disableAutoCentering(QPoint sceneCoordinate)
+{
+    if (isAutoCenteringEnabled()) {
+        QPoint oldPixelValue = QPoint(m_lastManualPosition.x() / m_zoomLevel,
+                                      m_lastManualPosition.y() / m_zoomLevel);
+
+        QPoint newPixelValue = QPoint(sceneCoordinate.x() / m_zoomLevel,
+                                      sceneCoordinate.y() / m_zoomLevel);
+
+        if ((abs(oldPixelValue.x() - newPixelValue.x()) > AUTO_CENTERING_DISABLE_DISTANCE) ||
+            (abs(oldPixelValue.y() - newPixelValue.y()) > AUTO_CENTERING_DISABLE_DISTANCE))
+            return true;
+    }
+
+    return false;
+}
+
+bool MapEngine::isAutoCenteringEnabled()
+{
+    return m_autoCenteringEnabled;
+}
+
+void MapEngine::setAutoCentering(bool enabled)
+{
+    m_autoCenteringEnabled = enabled;
+}
index 3608856..09baeb5 100644 (file)
@@ -106,6 +106,13 @@ public:
     QGraphicsScene* scene();
 
     /**
+    * @brief Set auto centering.
+    *
+    * @param enabled true if enabled, false otherwise
+    */
+    void setAutoCentering(bool enabled);
+
+    /**
     * @brief Return tile path created from tile values.
     *
     * @param zoomLevel tile's zoom level
@@ -174,6 +181,13 @@ private:
     void getTiles(QPoint sceneCoordinate);
 
     /**
+    * @brief Check if auto centering is enabled
+    *
+    * @param true if enabled, false otherwise
+    */
+    bool isAutoCenteringEnabled();
+
+    /**
     * @brief Check if center tile has changed.
     *
     * @param sceneCoordinate scene's center coordinate
@@ -182,6 +196,14 @@ private:
     bool isCenterTileChanged(QPoint sceneCoordinate);
 
     /**
+    * @brief Check if auto centering should be disabled.
+    *
+    * @param sceneCoordinate scene's center coordinate
+    * @return bool true if auto centering should be disabled
+    */
+    bool disableAutoCentering(QPoint sceneCoordinate);
+
+    /**
     * @brief Calculate maximum value for tile in this zoom level.
     *
     * @param zoomLevel zoom level
@@ -256,6 +278,11 @@ signals:
     void locationChanged(QPoint sceneCoordinate);
 
     /**
+    * @brief Signal to notify map scrolling.
+    */
+    void mapScrolled();
+
+    /**
     * @brief Signal for zoom level change
     *
     * @param newZoomLevel New zoom level
@@ -266,8 +293,10 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
+    bool m_autoCenteringEnabled;    ///< Auto centering enabled
     QPoint m_centerTile; ///< Current center tile
     FriendItemsHandler *m_friendItemsHandler; ///< Handler for friend and group items
+    QPoint m_lastManualPosition;  ///< Last manually set position in scene coordinate
     MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
     MapScene *m_mapScene; ///< Scene for map tiles
     MapZoomPanel *m_mapZoomPanel; ///< Toolbar for zoom buttons
diff --git a/src/situarecommon.h b/src/situarecommon.h
new file mode 100644 (file)
index 0000000..d4d842b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef SITUARECOMMON_H
+#define SITUARECOMMON_H
+
+#include <QString>
+
+// QSettings identifiers
+const QString DIRECTORY_NAME = "Ixonos";
+const QString FILE_NAME = "Situare";
+
+const QString GPS_ENABLED = "GPS_ENABLED";
+const QString AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";
+
+#endif // SITUARECOMMON_H
index af28831..61f41f1 100644 (file)
@@ -78,7 +78,8 @@ HEADERS += ui/mainwindow.h \
     ui/panelsliderbar.h \
     map/friendgroupitem.h \
     map/frienditemshandler.h \
-    gps/gpspositioninterface.h
+    gps/gpspositioninterface.h \
+    situarecommon.h
 QT += network \
     webkit
 #DEFINES += QT_NO_DEBUG_OUTPUT
index f8cb015..ee7e8eb 100644 (file)
@@ -83,9 +83,6 @@ FriendListItem::FriendListItem(QWidget *parent)
     m_distanceLabel = new QLabel();
     m_distanceLabel->setFixedHeight(IMAGE_HEIGHT);
 
-//    QLabel *button = new QLabel();
-//    button->setPixmap(QPixmap(":/res/images/show_position.png"));
-//    button->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
     m_findButton = new ImageButton(this, ":/res/images/show_position.png",
                                    ":/res/images/show_position_s.png");
 
index 5f4758e..f360611 100644 (file)
@@ -114,7 +114,11 @@ private slots:
 * SIGNALS
 ******************************************************************************/
 signals:
-
+    /**
+    * @brief Signal for finding friend.
+    *
+    * @param coordinates friend's geo coordinates
+    */
     void findFriend(const QPointF &coordinates);
 
 /******************************************************************************
index 148e676..e3484b3 100644 (file)
@@ -32,6 +32,7 @@
 #include "settingsdialog.h"
 #include "facebookservice/facebookauthentication.h"
 #include "situareservice/situareservice.h"
+#include "situarecommon.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
@@ -56,10 +57,10 @@ MainWindow::MainWindow(QWidget *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
-    connect(this, SIGNAL(enableAutoCentering(bool)),
+    connect(this, SIGNAL(autoCentering(bool)),
             m_mapViewScreen, SLOT(enableAutoCentering(bool)));
-    connect(this, SIGNAL(positionReceived(QPointF)),
-            m_mapViewScreen, SLOT(positionReceived(QPointF)));
+    connect(this, SIGNAL(positionReceived(QPointF, qreal)),
+            m_mapViewScreen, SLOT(positionReceived(QPointF, qreal)));
     connect(m_mapViewScreen, SIGNAL(mapLocationChanged()), this, SLOT(mapLocationChanged()));
 
     this->toggleProgressIndicator(true);
@@ -85,7 +86,7 @@ void MainWindow::createMenus()
         m_gpsToggleAct = new QAction(tr("GPS"), this);
     m_gpsToggleAct->setCheckable(true);
     m_gpsToggleAct->setChecked(true);
-    connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsActionToggled(bool)));
+    connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsToggled(bool)));
     m_autoCenteringAct = new QAction(tr("Auto centering"), this);
     m_autoCenteringAct->setCheckable(true);
     m_autoCenteringAct->setChecked(true);
@@ -114,20 +115,41 @@ void MainWindow::openSettingsDialog()
     dialog->show();
 }
 
-void MainWindow::gpsActionToggled(bool checked)
+void MainWindow::gpsToggled(bool checked)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (checked) {
+    if (checked)
         emit enableGPS(true);
+    else
+        emit enableGPS(false);
+}
+
+void MainWindow::setGPSButton(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (enabled) {
         showMaemoInformationBox(tr("GPS enabled"));
+        m_gpsToggleAct->setChecked(true);
         m_autoCenteringAct->setVisible(true);
     }
     else {
-        emit enableGPS(false);
         showMaemoInformationBox(tr("GPS disabled"));
+        m_gpsToggleAct->setChecked(false);
         m_autoCenteringAct->setVisible(false);
+    }
+}
 
+void MainWindow::setAutoCenteringButton(bool enabled)
+{
+    if (enabled) {
+        showMaemoInformationBox(tr("Auto centering enabled"));
+        m_autoCenteringAct->setChecked(true);
+    }
+    else {
+        showMaemoInformationBox(tr("Auto centering disabled"));
+        m_autoCenteringAct->setChecked(false);
     }
 }
 
@@ -149,21 +171,24 @@ void MainWindow::mapLocationChanged()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_autoCenteringAct->setChecked(false);
+    emit enableAutoCentering(false);
 }
 
 void MainWindow::autoCenteringToggled(bool checked)
 {
-    qDebug() << __PRETTY_FUNCTION__ << " " << checked;
+    qDebug() << __PRETTY_FUNCTION__ << checked;
 
-    if (checked) {
+    if (checked)
         emit enableAutoCentering(true);
-        showMaemoInformationBox(tr("Auto centering enabled"));
-    }
-    else {
+    else
         emit enableAutoCentering(false);
-        showMaemoInformationBox(tr("Auto centering disabled"));
-    }
+}
+
+void MainWindow::autoCenteringEnabled(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__ << enabled;
+
+    emit autoCentering(enabled);
 }
 
 void MainWindow::showMaemoInformationBox(const QString &message)
@@ -176,3 +201,10 @@ void MainWindow::showMaemoInformationBox(const QString &message)
     Q_UNUSED(message);
 #endif
 }
+
+MainWindow::~MainWindow()
+{
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    settings.setValue(GPS_ENABLED, m_gpsToggleAct->isChecked());
+    settings.setValue(AUTO_CENTERING_ENABLED, m_autoCenteringAct->isChecked());
+}
index 24edd20..bbfb56d 100644 (file)
@@ -54,9 +54,21 @@ public:
     */
     MainWindow(QWidget *parent = 0);
 
+    /**
+    * @brief Destructor.
+    */
+    ~MainWindow();
+
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
+public:
+    void setGPSButton(bool enabled);
+
+    void setAutoCenteringButton(bool enabled);
+
+    void autoCenteringEnabled(bool enabled);
+
 public slots:
     /**
     * @brief Slot for auto centering enabling.
@@ -66,6 +78,13 @@ public slots:
     void autoCenteringToggled(bool checked);
 
     /**
+    * @brief Slot for gps enabling.
+    *
+    * @param checked true if button state is checked, false otherwise
+    */
+    void gpsToggled(bool checked);
+
+    /**
     * @brief Slot for map location change.
     */
     void mapLocationChanged();
@@ -96,13 +115,6 @@ private:
     void showMaemoInformationBox(const QString &message);
 
 private slots:
-       /**
-    * @brief Slot for gps enabling.
-    *
-    * @param checked true if button state is checked, false otherwise
-    */
-    void gpsActionToggled(bool checked);
-
     /**
     * @brief Slot for gps timeout.
     *
@@ -127,12 +139,12 @@ private slots:
  * SIGNALS
  ******************************************************************************/
 signals:
-       /**
+    /**
     * @brief Signal for map auto centering
     *
     * @param enabled true if map should auto center to gps location
     */
-    void enableAutoCentering(bool enabled);
+    void autoCentering(bool enabled);
 
        /**
     * @brief Signal for gps enabling.
@@ -141,6 +153,13 @@ signals:
     */
     void enableGPS(bool enabled);
 
+    /**
+    * @brief Signal for auto centering enabling.
+    *
+    * @param enabled if auto centering should be enabled
+    */
+    void enableAutoCentering(bool enabled);
+
        /**
     * @brief Signal for friend location ready.
     *
@@ -148,12 +167,13 @@ signals:
     */
     void friendsLocationsReady(QList<User *> &friendsList);
 
-       /**
+    /**
     * @brief Signal for gps position.
     *
     * @param position longitude and latitude values
+    * @param accuracy coordinate accuracy in metres
     */
-    void positionReceived(QPointF position);
+    void positionReceived(QPointF position, qreal accuracy);
 
        /**
     * @brief Signal for refreshing user data.
@@ -195,9 +215,9 @@ signals:
 private:
     UpdateLocationDialog *m_locationDialog; ///< Message dialog
     MapViewScreen *m_mapViewScreen; ///< Instance of the map view
-       QAction *m_autoCenteringAct;    ///< Action to auto center map using gps position
+    QAction *m_autoCenteringAct;    ///< Action to auto center map using gps position
     QAction *m_gpsToggleAct;    ///< Action to trigger gps toggle      
-       QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
+    QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
     QMenu *m_viewMenu; ///< Object that hold the view menu items
 };
 
index c08cbae..8154a03 100644 (file)
@@ -74,7 +74,7 @@ MapViewScreen::MapViewScreen(QWidget *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
-    connect(mapView, SIGNAL(viewScrolled(QPoint)), this, SLOT(locationChanged()));
+    connect(mapEngine, SIGNAL(mapScrolled()), this, SLOT(locationChanged()));
 
     QHBoxLayout *mapViewLayout = new QHBoxLayout;
 
@@ -111,13 +111,13 @@ void MapViewScreen::drawOsmLicense(int width, int height)
 
 void MapViewScreen::locationChanged()
 {
-    qDebug() << __PRETTY_FUNCTION__ << " m_autoCentering: " << m_autoCenteringEnabled;
+    qDebug() << __PRETTY_FUNCTION__;
 
     if (m_autoCenteringEnabled)
         emit mapLocationChanged();
 }
 
-void MapViewScreen::positionReceived(QPointF position)
+void MapViewScreen::positionReceived(QPointF position, qreal accuracy)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -130,4 +130,5 @@ void MapViewScreen::enableAutoCentering(bool enabled)
     qDebug() << __PRETTY_FUNCTION__;
 
     m_autoCenteringEnabled = enabled;
+    mapEngine->setAutoCentering(enabled);
 }
index c92d59e..64b105b 100644 (file)
@@ -75,8 +75,9 @@ private slots:
     * @brief Slot for GPS position.
     *
     * @param position latitude and longitude values
+    * @param accuracy coordinate accuracy in metres
     */
-    void positionReceived(QPointF position);
+    void positionReceived(QPointF position, qreal accuracy);
 
 /*******************************************************************************
  * SIGNALS
index 48e3333..9dcc31f 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <QtGui>
 #include <QDebug>
-#include "facebookservice/facebookcommon.h"
+#include "situarecommon.h"
 #include "settingsdialog.h"
 
 const QString AUTOMATIC_LOCATION_UPDATE("Automatic_location_update");
@@ -76,8 +76,8 @@ void SettingsDialog::dialogFinished(int /* reason */)
 void SettingsDialog::saveValues()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    settings.setValue(AUTOMATIC_LOCATION_UPDATE, m_automaticLocationUpdate->isChecked());
+//    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+//    settings.setValue(AUTOMATIC_LOCATION_UPDATE, m_automaticLocationUpdate->isChecked());
     accept();
 
 }