2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Jussi Laitinen - jussi.laitinen@ixonos.com
8 Sami Rämö - sami.ramo@ixonos.com
9 Ville Tiensuu - ville.tiensuu@ixonos.com
10 Katri Kaikkonen - katri.kaikkonen@ixonos.com
12 Situare is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 version 2 as published by the Free Software Foundation.
16 Situare is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with Situare; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 #include <QtAlgorithms>
31 #include <QApplication>
33 #include <QMessageBox>
36 #include "engine/updatelocation.h"
38 #include "friendlistpanel.h"
39 #include "fullscreenbutton.h"
40 #include "indicatorbuttonpanel.h"
41 #include "locationsearchpanel.h"
42 #include "map/mapcommon.h"
43 #include "map/mapview.h"
45 #include "panelcommon.h"
46 #include "routingpanel.h"
47 #include "searchdialog.h"
48 #include "settingsdialog.h"
49 #include "situareservice/situarecommon.h"
50 #include "tabbedpanel.h"
51 #include "updatelocation/updatelocationdialog.h"
52 #include "userinfopanel.h"
53 #include "zoombuttonpanel.h"
55 #include "mainwindow.h"
57 // These MUST BE HERE, compiling for Maemo fails if moved
59 #include <QtMaemo5/QMaemo5InformationBox>
60 #include <QtGui/QX11Info>
61 #include <X11/Xatom.h>
63 #endif // Q_WS_MAEMO_5
65 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
66 #include "ossoabookdialog.h"
69 MainWindow::MainWindow(QWidget *parent)
70 : QMainWindow(parent),
74 m_mapCenterHorizontalShifting(0),
75 m_progressIndicatorCount(0),
78 m_fullScreenButton(0),
79 m_indicatorButtonPanel(0),
82 qDebug() << __PRETTY_FUNCTION__;
86 // map view is the only widget which size & location is handled automatically by the system
87 // default functionality
88 setCentralWidget(m_mapView);
93 setWindowTitle(tr("Situare"));
95 // set stacking order of widgets (from top to bottom)
96 // m_tabbedPanel is the topmost one
97 if (m_fullScreenButton) {
98 m_fullScreenButton->stackUnder(m_tabbedPanel);
99 m_crosshair->stackUnder(m_fullScreenButton);
101 m_crosshair->stackUnder(m_tabbedPanel);
103 m_zoomButtonPanel->stackUnder(m_crosshair);
104 m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
105 m_osmLicense->stackUnder(m_indicatorButtonPanel);
106 m_mapScale->stackUnder(m_osmLicense);
107 m_mapView->stackUnder(m_mapScale);
111 // Set default screen size
112 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
114 setAttribute(Qt::WA_Maemo5StackedWindow);
117 m_updateLocationController = new UpdateLocation(this);
119 connect(this, SIGNAL(updateWasSuccessful()), m_updateLocationController, SLOT(clear()));
120 connect(m_updateLocationController, SIGNAL(locationUpdate(QString,bool)),
121 this, SIGNAL(locationUpdate(QString,bool)));
124 MainWindow::~MainWindow()
126 qDebug() << __PRETTY_FUNCTION__;
130 qDeleteAll(m_queue.begin(), m_queue.end());
133 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
134 m_error_queue.clear();
137 void MainWindow::automaticUpdateDialogFinished(int result)
139 qDebug() << __PRETTY_FUNCTION__;
141 if (result == QMessageBox::Yes) {
142 readAutomaticLocationUpdateSettings();
144 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
145 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
146 readAutomaticLocationUpdateSettings();
149 m_automaticUpdateLocationDialog->deleteLater();
152 void MainWindow::buildCrosshair()
154 qDebug() << __PRETTY_FUNCTION__;
156 m_crosshair = new QLabel(this);
157 QPixmap crosshairImage(":/res/images/sight.png");
158 m_crosshair->setPixmap(crosshairImage);
159 m_crosshair->setFixedSize(crosshairImage.size());
161 m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
163 connect(m_mapView, SIGNAL(viewResized(QSize)),
164 this, SLOT(moveCrosshair()));
166 connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
167 this, SLOT(mapCenterHorizontalShiftingChanged(int)));
170 void MainWindow::buildFriendListPanel()
172 qDebug() << __PRETTY_FUNCTION__;
174 m_friendsListPanel = new FriendListPanel(this);
176 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
177 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
179 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
180 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
182 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
183 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
185 connect(this, SIGNAL(friendImageReady(User*)),
186 m_friendsListPanel, SLOT(friendImageReady(User*)));
188 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
189 this, SIGNAL(routeTo(const GeoCoordinate&)));
191 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
192 this, SIGNAL(requestContactDialog(const QString &)));
195 void MainWindow::buildFullScreenButton()
197 qDebug() << __PRETTY_FUNCTION__;
200 m_fullScreenButton = new FullScreenButton(this);
202 if (m_fullScreenButton) {
203 connect(m_fullScreenButton, SIGNAL(clicked()),
204 this, SLOT(toggleFullScreen()));
206 connect(qApp, SIGNAL(showFullScreenButton()),
207 m_fullScreenButton, SLOT(invoke()));
209 #endif // Q_WS_MAEMO_5
212 void MainWindow::buildIndicatorButtonPanel()
214 qDebug() << __PRETTY_FUNCTION__;
216 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
218 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
219 this, SIGNAL(autoCenteringTriggered(bool)));
221 connect(m_mapView, SIGNAL(viewResized(QSize)),
222 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
224 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
225 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
227 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
228 this, SIGNAL(draggingModeTriggered()));
231 void MainWindow::buildInformationBox(const QString &message, bool modal)
233 qDebug() << __PRETTY_FUNCTION__;
235 QString errorMessage = message;
239 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
242 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
243 // extra line changes are needed to make error notes broader
244 errorMessage.prepend("\n");
245 errorMessage.append("\n");
247 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
249 QLabel *label = new QLabel(msgBox);
250 label->setAlignment(Qt::AlignCenter);
251 label->setText(errorMessage);
252 msgBox->setWidget(label);
254 QMessageBox *msgBox = new QMessageBox(this);
255 msgBox->button(QMessageBox::Ok);
256 msgBox->setText(errorMessage);
257 msgBox->setModal(modal);
263 void MainWindow::buildLocationSearchPanel()
265 qDebug() << __PRETTY_FUNCTION__;
267 m_locationSearchPanel = new LocationSearchPanel(this);
269 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
270 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
272 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
273 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
275 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
276 this, SIGNAL(routeTo(const GeoCoordinate&)));
278 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
279 this, SLOT(startLocationSearch()));
281 connect(this, SIGNAL(searchForLocation(QString)),
282 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
284 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
285 this, SIGNAL(searchHistoryItemClicked(QString)));
288 void MainWindow::buildLoginDialog(QWebView *browser)
290 qDebug() << __PRETTY_FUNCTION__;
292 if (!m_loginDialog) {
293 m_loginDialog = new QDialog(this);
295 m_loginDialog->setWindowTitle(tr("Login"));
296 m_loginDialog->setLayout(new QVBoxLayout());
297 m_loginDialog->layout()->addWidget(browser);
298 m_loginDialog->layout()->setContentsMargins(QMargins()); // zero margins
299 connect(m_loginDialog, SIGNAL(rejected()), this, SLOT(destroyLoginDialog()));
304 m_loginDialog->show();
307 void MainWindow::buildMap()
309 qDebug() << __PRETTY_FUNCTION__;
311 m_mapView = new MapView(this);
313 buildZoomButtonPanel();
316 buildFullScreenButton();
317 buildIndicatorButtonPanel();
320 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
321 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
323 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
324 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
326 connect(m_mapView, SIGNAL(viewResized(QSize)),
327 this, SIGNAL(mapViewResized(QSize)));
329 connect(m_mapView, SIGNAL(viewResized(QSize)),
330 this, SLOT(drawFullScreenButton(QSize)));
332 connect(m_mapView, SIGNAL(viewResized(QSize)),
333 this, SLOT(drawMapScale(QSize)));
335 connect(m_mapView, SIGNAL(viewResized(QSize)),
336 this, SLOT(moveCrosshair()));
338 connect(this, SIGNAL(zoomLevelChanged(int)),
339 m_mapView, SLOT(setZoomLevel(int)));
341 connect(m_mapView, SIGNAL(viewZoomFinished()),
342 this, SIGNAL(viewZoomFinished()));
344 connect(m_mapView, SIGNAL(zoomIn()),
345 this, SIGNAL(zoomIn()));
348 void MainWindow::buildMapScale()
350 m_mapScale = new MapScale(this);
351 connect(this, SIGNAL(newMapResolution(qreal)),
352 m_mapScale, SLOT(updateMapResolution(qreal)));
355 void MainWindow::buildOsmLicense()
357 qDebug() << __PRETTY_FUNCTION__;
359 m_osmLicense = new QLabel(this);
360 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
361 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
362 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
363 m_osmLicense->setFont(QFont("Nokia Sans", 9));
364 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
365 m_osmLicense->fontMetrics().height());
367 connect(m_mapView, SIGNAL(viewResized(QSize)),
368 this, SLOT(drawOsmLicense(QSize)));
371 void MainWindow::buildPanels()
373 qDebug() << __PRETTY_FUNCTION__;
375 buildUserInfoPanel();
376 buildFriendListPanel();
377 buildLocationSearchPanel();
380 m_tabbedPanel = new TabbedPanel(this);
382 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
383 m_situareTabsIndexes.append(
384 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
385 m_situareTabsIndexes.append(
386 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
388 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
389 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
391 connect(m_mapView, SIGNAL(viewResized(QSize)),
392 m_tabbedPanel, SLOT(resizePanel(QSize)));
394 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
395 m_tabbedPanel, SLOT(openPanel(QWidget*)));
397 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
398 m_tabbedPanel, SLOT(openPanel(QWidget*)));
400 connect(m_tabbedPanel, SIGNAL(panelClosed()),
401 m_friendsListPanel, SLOT(anyPanelClosed()));
403 connect(m_tabbedPanel, SIGNAL(panelOpened()),
404 m_friendsListPanel, SLOT(anyPanelOpened()));
406 connect(m_tabbedPanel, SIGNAL(panelClosed()),
407 m_routingPanel, SLOT(clearListsSelections()));
409 connect(m_tabbedPanel, SIGNAL(panelClosed()),
410 m_mapView, SLOT(disableCenterShift()));
412 connect(m_tabbedPanel, SIGNAL(panelOpened()),
413 m_mapView, SLOT(enableCenterShift()));
415 connect(m_tabbedPanel, SIGNAL(panelClosed()),
416 m_userInfoPanel, SIGNAL(collapse()));
418 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
419 m_userInfoPanel, SIGNAL(collapse()));
421 // signals for showing and hiding list item context buttons
422 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
423 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
425 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
426 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
428 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
429 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
432 void MainWindow::buildRoutingPanel()
434 qDebug() << __PRETTY_FUNCTION__;
436 m_routingPanel = new RoutingPanel(this);
438 connect(m_routingPanel, SIGNAL(routeToCursor()),
439 this, SIGNAL(routeToCursor()));
441 connect(this, SIGNAL(routeParsed(Route&)),
442 m_routingPanel, SLOT(setRoute(Route&)));
444 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
445 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
447 connect(m_routingPanel, SIGNAL(clearRoute()),
448 this, SIGNAL(clearRoute()));
451 void MainWindow::buildUserInfoPanel()
453 qDebug() << __PRETTY_FUNCTION__;
455 m_userInfoPanel = new UserInfoPanel(this);
457 connect(this, SIGNAL(userLocationReady(User*)),
458 m_userInfoPanel, SLOT(userDataReceived(User*)));
460 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
461 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
463 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
464 this, SIGNAL(refreshUserData()));
466 connect(m_userInfoPanel, SIGNAL(updateLocationMessageButtonClicked()),
467 this, SLOT(showUpdateLocationDialog()));
470 void MainWindow::buildZoomButtonPanel()
472 qDebug() << __PRETTY_FUNCTION__;
474 m_zoomButtonPanel = new ZoomButtonPanel(this);
476 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
477 this, SIGNAL(zoomIn()));
479 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
480 this, SIGNAL(zoomOut()));
482 connect(this, SIGNAL(zoomLevelChanged(int)),
483 m_zoomButtonPanel, SLOT(resetButtons()));
485 connect(this, SIGNAL(maxZoomLevelReached()),
486 m_zoomButtonPanel, SLOT(disableZoomInButton()));
488 connect(this, SIGNAL(minZoomLevelReached()),
489 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
491 connect(m_mapView, SIGNAL(viewResized(QSize)),
492 m_zoomButtonPanel, SLOT(screenResized(QSize)));
494 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
495 this, SIGNAL(draggingModeTriggered()));
498 void MainWindow::createMenus()
500 qDebug() << __PRETTY_FUNCTION__;
503 m_loginAct = new QAction(tr("Login"), this);
504 connect(m_loginAct, SIGNAL(triggered()),
505 this, SIGNAL(loginActionPressed()));
508 m_toSettingsAct = new QAction(tr("Settings"), this);
509 connect(m_toSettingsAct, SIGNAL(triggered()),
510 this, SLOT(openSettingsDialog()));
513 m_gpsToggleAct = new QAction(tr("GPS"), this);
514 m_gpsToggleAct->setCheckable(true);
516 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
517 this, SIGNAL(gpsTriggered(bool)));
519 // build the actual menu
520 m_viewMenu = menuBar()->addMenu(tr("Main"));
521 m_viewMenu->addAction(m_loginAct);
522 m_viewMenu->addAction(m_toSettingsAct);
523 m_viewMenu->addAction(m_gpsToggleAct);
524 m_viewMenu->setObjectName(tr("Menu"));
527 void MainWindow::destroyLoginDialog()
529 qDebug() << __PRETTY_FUNCTION__;
532 m_loginDialog->hide();
533 m_loginDialog->deleteLater();
538 void MainWindow::dialogFinished(int status)
540 qDebug() << __PRETTY_FUNCTION__;
542 QDialog *dialog = m_queue.takeFirst();
543 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
544 if ((searchDialog) && (status != 0))
545 emit searchForLocation(searchDialog->input());
547 dialog->deleteLater();
549 if(!m_error_queue.isEmpty() && m_errorShown == false) {
550 showErrorInformationBox();
552 if(!m_queue.isEmpty()) {
553 showInformationBox();
558 void MainWindow::drawFullScreenButton(const QSize &size)
560 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
562 if (m_fullScreenButton) {
563 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
564 size.height() - m_fullScreenButton->size().height());
568 void MainWindow::drawMapScale(const QSize &size)
570 qDebug() << __PRETTY_FUNCTION__;
572 const int LEFT_SCALE_MARGIN = 10;
573 const int BOTTOM_SCALE_MARGIN = 2;
575 m_mapScale->move(LEFT_SCALE_MARGIN,
576 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
579 void MainWindow::drawOsmLicense(const QSize &size)
581 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
583 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
585 size.height() - m_osmLicense->fontMetrics().height());
588 void MainWindow::errorDialogFinished(int status)
590 qDebug() << __PRETTY_FUNCTION__;
593 QDialog *dialog = m_error_queue.takeFirst();
595 dialog->deleteLater();
596 m_errorShown = false;
598 if(!m_error_queue.isEmpty())
599 showErrorInformationBox();
600 else if(!m_queue.isEmpty())
601 showInformationBox();
604 void MainWindow::gpsTimeout()
606 qDebug() << __PRETTY_FUNCTION__;
608 buildInformationBox(tr("GPS timeout"));
611 void MainWindow::grabZoomKeys(bool grab)
613 qDebug() << __PRETTY_FUNCTION__;
616 // Can't grab keys unless we have a window id
620 unsigned long val = (grab) ? 1 : 0;
621 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
625 XChangeProperty (QX11Info::display(),
631 reinterpret_cast<unsigned char *>(&val),
635 #endif // Q_WS_MAEMO_5
638 void MainWindow::keyPressEvent(QKeyEvent* event)
640 qDebug() << __PRETTY_FUNCTION__;
642 switch (event->key()) {
653 QWidget::keyPressEvent(event);
656 void MainWindow::loggedIn(bool logged)
658 qDebug() << __PRETTY_FUNCTION__;
663 m_loginAct->setText(tr("Logout"));
665 m_loginAct->setText(tr("Login"));
666 m_userInfoPanel->showUserInfo(false);
667 m_updateLocationController->clear();
669 updateItemVisibility(logged);
672 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
674 m_mapCenterHorizontalShifting = shifting;
678 void MainWindow::moveCrosshair()
680 qDebug() << __PRETTY_FUNCTION__;
683 int mapHeight = m_mapView->size().height();
684 int mapWidth = m_mapView->size().width();
685 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
686 - m_mapCenterHorizontalShifting,
687 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
691 void MainWindow::openSettingsDialog()
693 qDebug() << __PRETTY_FUNCTION__;
695 SettingsDialog *settingsDialog = new SettingsDialog(this);
696 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
697 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
699 settingsDialog->show();
702 void MainWindow::queueDialog(QDialog *dialog)
704 qDebug() << __PRETTY_FUNCTION__;
706 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
707 if(dialog->isModal()) {
708 m_error_queue.append(dialog);
710 m_queue.append(dialog);
713 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
714 if(m_error_queue.count() == 1 && m_errorShown == false)
715 showErrorInformationBox();
716 else if(m_queue.count() == 1 && m_errorShown == false)
717 showInformationBox();
720 void MainWindow::readAutomaticLocationUpdateSettings()
722 qDebug() << __PRETTY_FUNCTION__;
724 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
725 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
726 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
729 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
731 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
733 emit enableAutomaticLocationUpdate(false);
737 void MainWindow::setCrosshairVisibility(bool visibility)
739 qDebug() << __PRETTY_FUNCTION__;
749 void MainWindow::setGPSButtonEnabled(bool enabled)
751 qDebug() << __PRETTY_FUNCTION__;
753 m_gpsToggleAct->setChecked(enabled);
756 void MainWindow::setIndicatorButtonEnabled(bool enabled)
758 qDebug() << __PRETTY_FUNCTION__;
760 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
763 void MainWindow::setMapViewScene(QGraphicsScene *scene)
765 qDebug() << __PRETTY_FUNCTION__;
767 m_mapView->setScene(scene);
770 void MainWindow::settingsDialogAccepted()
772 qDebug() << __PRETTY_FUNCTION__;
774 readAutomaticLocationUpdateSettings();
777 void MainWindow::showContactDialog(const QString &guid)
779 qDebug() << __PRETTY_FUNCTION__;
781 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
782 OssoABookDialog::showContactDialog(guid);
785 buildInformationBox(tr("Contact dialog works only on phone!"), true);
789 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
791 qDebug() << __PRETTY_FUNCTION__;
793 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
794 tr("Automatic location update"), text,
795 QMessageBox::Yes | QMessageBox::No |
796 QMessageBox::Cancel, this);
797 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
798 this, SLOT(automaticUpdateDialogFinished(int)));
800 m_automaticUpdateLocationDialog->show();
803 void MainWindow::showErrorInformationBox()
805 qDebug() << __PRETTY_FUNCTION__;
807 if(m_error_queue.count()) {
809 QDialog *dialog = m_error_queue.first();
810 connect(dialog, SIGNAL(finished(int)),
811 this, SLOT(errorDialogFinished(int)));
816 void MainWindow::showInformationBox()
818 qDebug() << __PRETTY_FUNCTION__;
820 if(m_queue.count()) {
821 QDialog *dialog = m_queue.first();
822 connect(dialog, SIGNAL(finished(int)),
823 this, SLOT(dialogFinished(int)));
828 void MainWindow::showUpdateLocationDialog()
830 qDebug() << __PRETTY_FUNCTION__;
832 UpdateLocationDialog *updateLocationDialog
833 = new UpdateLocationDialog(m_updateLocationController, this);
835 connect(this, SIGNAL(reverseGeoReady(QString)),
836 updateLocationDialog, SLOT(setAddress(QString)));
838 updateLocationDialog->show();
840 emit requestReverseGeo();
843 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
845 qDebug() << __PRETTY_FUNCTION__;
848 reply->ignoreSslErrors();
851 void MainWindow::startLocationSearch()
853 qDebug() << __PRETTY_FUNCTION__;
855 SearchDialog *searchDialog = new SearchDialog();
856 queueDialog(searchDialog);
859 void MainWindow::toggleFullScreen()
861 qDebug() << __PRETTY_FUNCTION__;
863 if(windowState() == Qt::WindowNoState)
869 void MainWindow::toggleProgressIndicator(bool value)
871 qDebug() << __PRETTY_FUNCTION__;
875 m_progressIndicatorCount++;
876 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
878 if(m_progressIndicatorCount > 0)
879 m_progressIndicatorCount--;
881 if(m_progressIndicatorCount == 0)
882 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
886 #endif // Q_WS_MAEMO_5
889 void MainWindow::updateItemVisibility(bool loggedIn)
891 qDebug() << __PRETTY_FUNCTION__;
893 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn);