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),
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();
}
}
QT += network \
webkit
--DEFINES += QT_NO_DEBUG_OUTPUT
++#DEFINES += QT_NO_DEBUG_OUTPUT
simulator {
SOURCES += network/networkhandlerprivatestub.cpp \
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__;
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__;
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__;
******************************************************************************/
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