Merge branch 'master' into settings_auto_update
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 8 Jun 2010 11:30:11 +0000 (14:30 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 8 Jun 2010 11:30:11 +0000 (14:30 +0300)
Conflicts:
doc/testing/functionality-tests.doc
src/ui/mainwindow.cpp
src/ui/mainwindow.h

1  2 
src/engine/engine.cpp
src/facebookservice/facebookauthentication.cpp
src/src.pro
src/ui/mainwindow.cpp
src/ui/mainwindow.h

@@@ -39,6 -38,6 +39,7 @@@ const QString SETTINGS_AUTO_CENTERING_E
  const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12;  ///< Default zoom level when GPS available
  const qreal USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE = 0.003;///< Min value for user move latitude
  const qreal USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE = 0.001;///< Min value for user move longitude
++const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
  
  SituareEngine::SituareEngine(QMainWindow *parent)
      : QObject(parent),
@@@ -170,31 -167,16 +171,34 @@@ void SituareEngine::enableGPS(bool enab
  
  void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
  {
 -    qDebug() << __PRETTY_FUNCTION__;
 +    qWarning() << __PRETTY_FUNCTION__ << enabled;
  
 -    if (m_automaticUpdateIntervalTimer) {
 +    bool accepted = false;
  
 -        if (enabled && m_gps->isRunning()) {
 -            m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
 -            m_automaticUpdateIntervalTimer->start();
 +    if (m_automaticUpdateFirstStart && enabled) {
 +        accepted = m_ui->showEnableAutomaticUpdateLocationDialog();
 +        m_automaticUpdateFirstStart = false;
 +        m_ui->automaticLocationUpdateEnabled(accepted);
 +    }
 +    else {
 +        accepted = true;
 +    }
 +
 +    qWarning() << __PRETTY_FUNCTION__ << accepted;
 +
 +    if (accepted) {
 +        if (m_automaticUpdateIntervalTimer) {
 +
 +            if (enabled && m_gps->isRunning()) {
-                 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
++                if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
++                    m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
++                else
++                    m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
 +                m_automaticUpdateIntervalTimer->start();
 +            }
 +            else
 +                m_automaticUpdateIntervalTimer->stop();
          }
 -        else
 -            m_automaticUpdateIntervalTimer->stop();
      }
  }
  
diff --cc src/src.pro
@@@ -98,7 -98,7 +98,7 @@@ HEADERS += ui/mainwindow.h 
  QT += network \
      webkit
  
--DEFINES += QT_NO_DEBUG_OUTPUT
++#DEFINES += QT_NO_DEBUG_OUTPUT
  
  simulator {
      SOURCES += network/networkhandlerprivatestub.cpp \
@@@ -109,13 -111,14 +111,19 @@@ MainWindow::~MainWindow(
  
      if(m_webView)
          delete m_webView;
+     qDeleteAll(m_queue.begin(), m_queue.end());
+     m_queue.clear();
+     qDeleteAll(m_error_queue.begin(), m_error_queue.end());
+     m_error_queue.clear();
  }
  
 +void MainWindow::automaticLocationUpdateEnabled(bool enabled)
 +{
 +    m_settingsDialog->setAutomaticLocationUpdateSettings(enabled);
 +}
 +
  void MainWindow::buildFullScreenButton()
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -559,13 -649,24 +654,31 @@@ void MainWindow::openSettingsDialog(
      m_settingsDialog->show();
  }
  
 +void MainWindow::requestAutomaticLocationUpdateSettings()
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    m_settingsDialog->emitAutomaticLocationUpdateSettings();
 +}
 +
+ void MainWindow::queueDialog(QDialog *dialog)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
+     if(dialog->isModal()) {
+         m_error_queue.append(dialog);
+     } else {
+         m_queue.append(dialog);
+     }
+     // show error dialog if there is only one error dialog in the queue and no error dialog is shown
+     if(m_error_queue.count() == 1 && m_errorShown == false)
+         showErrorInformationBox();
+     else if(m_queue.count() == 1 && m_errorShown == false)
+         showInformationBox();
+ }
  void MainWindow::saveCookies()
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -643,37 -743,6 +755,20 @@@ void MainWindow::setViewPortSize(int wi
      m_viewPortHeight = height;
  }
  
 +bool MainWindow::showEnableAutomaticUpdateLocationDialog()
 +{
 +    QMessageBox msgBox(QMessageBox::Warning, tr("Automatic location update"),
 +                       tr("Are you sure you want to enable automatic location update?"),
 +                       QMessageBox::Ok | QMessageBox::Cancel, 0);
 +    msgBox.button(QMessageBox::Ok)->setText(tr("Ok"));
 +    int ret = msgBox.exec();
 +
 +    if (ret == QMessageBox::Ok)
 +        return true;
 +    else
 +        return false;
 +}
 +
- void MainWindow::showMaemoInformationBox(const QString &message, bool modal)
- {
-     qDebug() << __PRETTY_FUNCTION__;
- #ifdef Q_WS_MAEMO_5
-     if(modal) {
-         QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::NoTimeout);
-     }
-     else {
-         QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
-     }
- #else
-     Q_UNUSED(modal);
-     QMessageBox::information(this, tr("Situare"), message, QMessageBox::Ok);
- #endif
- }
  void MainWindow::toggleFullScreen()
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -80,13 -81,14 +81,21 @@@ private
   ******************************************************************************/
  public:
      /**
 +    * @brief Sets automatic location update enabled from settings dialog.
 +    *
 +    * @param enabled true if enabled, false otherwise
 +    */
 +    void automaticLocationUpdateEnabled(bool enabled);
 +
 +    /**
+     * @brief Builds information box with message.
+     *
+     * @param message Information message
+     * @param modal Modal = true, non-modal false
+     */
+     void buildInformationBox(const QString &message, bool modal=false);
+     /**
      * @brief Clears cookie jar
      *
      */
      void setMapViewScene(QGraphicsScene *scene);
  
      /**
 +    * Shows dialog with enable automatic location update question.
 +    *
 +    * @return true if accepted, false otherwise
 +    */
 +    bool showEnableAutomaticUpdateLocationDialog();
 +
 +    /**
-     * @brief Show Maemo information box with message.
-     *
-     * @param message Information message
-     * @param modal Modal = true, non-modal false
-     */
-     void showMaemoInformationBox(const QString &message, bool modal=false);
-     /**
      * @brief Gets the username from member variable for saving purposes
      *
      * @return QString Username