void SituareEngine::automaticUpdateIntervalTimerTimeout()
{
- qWarning() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
if (m_gps->isRunning() && m_userMoved) {
// requestUpdateLocation();
void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
{
- qWarning() << __PRETTY_FUNCTION__ << enabled;
+ qDebug() << __PRETTY_FUNCTION__;
bool accepted = false;
if (m_automaticUpdateFirstStart && enabled) {
- accepted = m_ui->showEnableAutomaticUpdateLocationDialog();
+ accepted = m_ui->showEnableAutomaticUpdateLocationDialog(
+ tr("Do you want to enable automatic location update with %1 min update interval?")
+ .arg(updateIntervalMsecs/1000/60));
m_automaticUpdateFirstStart = false;
m_ui->automaticLocationUpdateEnabled(accepted);
}
accepted = true;
}
- qWarning() << __PRETTY_FUNCTION__ << accepted;
-
if (accepted) {
- if (m_automaticUpdateIntervalTimer) {
+ if (m_automaticUpdateIntervalTimer) {
if (enabled && m_gps->isRunning()) {
-// if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
-// m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
-// else
+ if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
+ m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS / 60);
+ else
m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs / 60);
+
m_automaticUpdateIntervalTimer->start();
}
- else
+ else {
m_automaticUpdateIntervalTimer->stop();
+ }
}
}
}
#include "gpspositionprivatestub.h"
GPSPositionPrivate::GPSPositionPrivate(QObject *parent)
- : QObject(parent)
+ : QObject(parent),
+ m_isRunning(false)
{
qDebug() << __PRETTY_FUNCTION__;
}
{
qDebug() << __PRETTY_FUNCTION__;
- return false;
+ return m_isRunning;
}
void GPSPositionPrivate::setUpdateInterval(int interval)
void GPSPositionPrivate::start()
{
qDebug() << __PRETTY_FUNCTION__;
+
+ m_isRunning = true;
}
void GPSPositionPrivate::stop()
{
qDebug() << __PRETTY_FUNCTION__;
+
+ m_isRunning = false;
}
QPointF GPSPositionPrivate::lastPosition()
* DOES NOTHING.
*/
void stop();
+
+private:
+ bool m_isRunning; ///< GPS running flag
};
#endif // GPSPOSITIONMOCKUP_H
m_viewPortHeight = height;
}
-bool MainWindow::showEnableAutomaticUpdateLocationDialog()
+bool MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
{
- QMessageBox msgBox(QMessageBox::Question, tr("Automatic location update"),
- tr("Are you sure you want to enable automatic location update?"),
+ QMessageBox msgBox(QMessageBox::Question, tr("Automatic location update"), text,
QMessageBox::Ok | QMessageBox::Cancel, 0);
msgBox.button(QMessageBox::Ok)->setText(tr("Ok"));
qWarning() << __PRETTY_FUNCTION__;
/**
* Shows dialog with enable automatic location update question.
*
+ * @param text text to show in dialog
* @return true if accepted, false otherwise
*/
- bool showEnableAutomaticUpdateLocationDialog();
+ bool showEnableAutomaticUpdateLocationDialog(const QString &text);
/**
* @brief Gets the username from member variable for saving purposes
scrollArea->show();
- setTime(QTime(0, LIST_MINUTES_STEP));
readSettings();
}
qDebug() << __PRETTY_FUNCTION__;
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, m_automaticLocationUpdate->isChecked());
- settings.setValue(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, time());
+ settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, m_automaticLocationUpdateOldValue);
+ settings.setValue(SETTINGS_AUTOMATIC_UPDATE_INTERVAL,
+ m_automaticLocationUpdateIntervalOldValue);
}
void SettingsDialog::setAutomaticLocationUpdateSettings(bool checked)
{
- qWarning() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
m_automaticLocationUpdate->setChecked(checked);
m_automaticLocationUpdateOldValue = checked;
qDebug() << __PRETTY_FUNCTION__;
m_automaticLocationUpdate->setEnabled(enabled);
+
+ if (enabled)
+ toggleAutomaticLocationUpdate(m_automaticLocationUpdate->isChecked());
+ else
+ toggleAutomaticLocationUpdate(false);
}
void SettingsDialog::readSettings()
{
- qWarning() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
QSettings settings(DIRECTORY_NAME, FILE_NAME);
bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
if (!automaticUpdateInterval.isEmpty())
setTime(QTime::fromString(automaticUpdateInterval, "hh:mm:ss"));
+ else
+ setTime(QTime(0, LIST_MINUTES_STEP));
+
+ m_automaticLocationUpdateOldValue = automaticUpdateEnabled;
+ m_automaticLocationUpdateIntervalOldValue = time();
}
void SettingsDialog::emitAutomaticLocationUpdateSettings()
{
- qWarning() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
if (m_automaticLocationUpdate->isChecked()) {
QTime emptyTime = QTime();
- qDebug() << emptyTime.msecsTo(time());
emit enableAutomaticLocationUpdate(true, emptyTime.msecsTo(time()));
}
else {
#ifdef Q_WS_MAEMO_5
int index = time.minute()/LIST_MINUTES_STEP - 1;
+
+ if (index < 0)
+ index = 0;
+ if (index >= m_timePick->model()->rowCount())
+ index = m_timePick->model()->rowCount() - 1;
+
m_timePick->setCurrentIndex(index);
#else
m_automaticLocationUpdateInterval->setTime(time);
time = m_automaticLocationUpdateInterval->time();
#endif
+ if (time < QTime(0, LIST_MINUTES_STEP))
+ time = QTime(0, LIST_MINUTES_STEP);
+ if (time > QTime(LIST_HOURS_MAX, 0))
+ time = QTime(LIST_HOURS_MAX, 0);
+
return time;
}