Merge branch 'master' into settings_auto_update
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 31 May 2010 06:23:20 +0000 (09:23 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 31 May 2010 06:23:20 +0000 (09:23 +0300)
Conflicts:
src/engine/engine.cpp
src/engine/engine.h
src/gps/gpspositionprivate.cpp
src/src.pro

1  2 
src/engine/engine.cpp
src/engine/engine.h
src/gps/gpspositionprivate.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h

@@@ -86,25 -85,7 +89,11 @@@ SituareEngine::SituareEngine(QMainWindo
      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();
 +
 +    m_automaticUpdateIntervalTimer = new QTimer(this);
 +    connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
 +            this, SLOT(automaticUpdateIntervalTimerTimeout()));
  }
  
  SituareEngine::~SituareEngine()
@@@ -295,21 -274,18 +315,34 @@@ void SituareEngine::requestUpdateLocati
          m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
  }
  
 +void SituareEngine::saveGPSPosition(QPointF position)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    qDebug() << __PRETTY_FUNCTION__ << m_lastUpdatedGPSPosition.x() << m_lastUpdatedGPSPosition.y();
 +    qDebug() << __PRETTY_FUNCTION__ << position.x() << position.y();
 +    qDebug() << __PRETTY_FUNCTION__ << "=" << fabs(m_lastUpdatedGPSPosition.x() - position.x()) <<
 +            fabs(m_lastUpdatedGPSPosition.y() - position.y());
 +
 +    if ((fabs(m_lastUpdatedGPSPosition.x() - position.x()) > 0.003) ||
 +        (fabs(m_lastUpdatedGPSPosition.y() - position.y()) > 0.001)) {
 +        qDebug() << __PRETTY_FUNCTION__ << "m_userMoved = true";
 +        m_lastUpdatedGPSPosition = position;
 +        m_userMoved = true;
 +    }
++
+ 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()
@@@ -143,11 -140,10 +143,15 @@@ public slots
  
  private:
      /**
 +    * @brief Checks if user is moved enough for position auto update.
 +    *
 +    * @return true if moved engouh, false otherwise
 +    */
 +    bool isUserMoved();
+       * @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
@@@ -144,15 -154,7 +152,9 @@@ qreal GPSPositionPrivate::accuracy(cons
  {
      qDebug() << __PRETTY_FUNCTION__;
  
 +    QDateTime timestamp;
 +
- //#ifdef Q_WS_MAEMO_5
- //    timestamp = positionInfo.dateTime();
- //#else
-     timestamp = positionInfo.timestamp();
- //#endif
-     if (!timestamp.isValid())
+     if (!positionInfo.timestamp().isValid())
          return GPS_ACCURACY_UNDEFINED;
  
      if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
Simple merge
Simple merge