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>
37 #include "friendlistpanel.h"
38 #include "fullscreenbutton.h"
39 #include "indicatorbuttonpanel.h"
40 #include "locationsearchpanel.h"
41 #include "map/mapcommon.h"
42 #include "map/mapview.h"
44 #include "panelcommon.h"
45 #include "routingpanel.h"
46 #include "searchdialog.h"
47 #include "settingsdialog.h"
48 #include "situareservice/situarecommon.h"
49 #include "tabbedpanel.h"
50 #include "userinfopanel.h"
51 #include "zoombuttonpanel.h"
53 #include "mainwindow.h"
55 // These MUST BE HERE, compiling for Maemo fails if moved
57 #include <QtMaemo5/QMaemo5InformationBox>
58 #include <QtGui/QX11Info>
59 #include <X11/Xatom.h>
61 #endif // Q_WS_MAEMO_5
63 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
64 #include "ossoabookdialog.h"
67 MainWindow::MainWindow(QWidget *parent)
68 : QMainWindow(parent),
72 m_mapCenterHorizontalShifting(0),
73 m_progressIndicatorCount(0),
76 m_fullScreenButton(0),
77 m_indicatorButtonPanel(0),
80 qDebug() << __PRETTY_FUNCTION__;
84 // map view is the only widget which size & location is handled automatically by the system
85 // default functionality
86 setCentralWidget(m_mapView);
91 setWindowTitle(tr("Situare"));
93 // set stacking order of widgets (from top to bottom)
94 // m_tabbedPanel is the topmost one
95 if (m_fullScreenButton) {
96 m_fullScreenButton->stackUnder(m_tabbedPanel);
97 m_crosshair->stackUnder(m_fullScreenButton);
99 m_crosshair->stackUnder(m_tabbedPanel);
101 m_zoomButtonPanel->stackUnder(m_crosshair);
102 m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
103 m_osmLicense->stackUnder(m_indicatorButtonPanel);
104 m_mapScale->stackUnder(m_osmLicense);
105 m_mapView->stackUnder(m_mapScale);
109 // Set default screen size
110 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
112 setAttribute(Qt::WA_Maemo5StackedWindow);
116 MainWindow::~MainWindow()
118 qDebug() << __PRETTY_FUNCTION__;
122 qDeleteAll(m_queue.begin(), m_queue.end());
125 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
126 m_error_queue.clear();
129 void MainWindow::automaticUpdateDialogFinished(int result)
131 qDebug() << __PRETTY_FUNCTION__;
133 if (result == QMessageBox::Yes) {
134 readAutomaticLocationUpdateSettings();
136 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
137 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
138 readAutomaticLocationUpdateSettings();
141 m_automaticUpdateLocationDialog->deleteLater();
144 void MainWindow::buildCrosshair()
146 qDebug() << __PRETTY_FUNCTION__;
148 m_crosshair = new QLabel(this);
149 QPixmap crosshairImage(":/res/images/sight.png");
150 m_crosshair->setPixmap(crosshairImage);
151 m_crosshair->setFixedSize(crosshairImage.size());
153 m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
155 connect(m_mapView, SIGNAL(viewResized(QSize)),
156 this, SLOT(moveCrosshair()));
158 connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
159 this, SLOT(mapCenterHorizontalShiftingChanged(int)));
162 void MainWindow::buildFriendListPanel()
164 qDebug() << __PRETTY_FUNCTION__;
166 m_friendsListPanel = new FriendListPanel(this);
168 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
169 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
171 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
172 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
174 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
175 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
177 connect(this, SIGNAL(friendImageReady(User*)),
178 m_friendsListPanel, SLOT(friendImageReady(User*)));
180 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
181 this, SIGNAL(routeTo(const GeoCoordinate&)));
183 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
184 this, SIGNAL(requestContactDialog(const QString &)));
187 void MainWindow::buildFullScreenButton()
189 qDebug() << __PRETTY_FUNCTION__;
192 m_fullScreenButton = new FullScreenButton(this);
194 if (m_fullScreenButton) {
195 connect(m_fullScreenButton, SIGNAL(clicked()),
196 this, SLOT(toggleFullScreen()));
198 connect(qApp, SIGNAL(showFullScreenButton()),
199 m_fullScreenButton, SLOT(invoke()));
201 #endif // Q_WS_MAEMO_5
204 void MainWindow::buildIndicatorButtonPanel()
206 qDebug() << __PRETTY_FUNCTION__;
208 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
210 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
211 this, SIGNAL(autoCenteringTriggered(bool)));
213 connect(m_mapView, SIGNAL(viewResized(QSize)),
214 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
216 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
217 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
219 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
220 this, SIGNAL(draggingModeTriggered()));
223 void MainWindow::buildInformationBox(const QString &message, bool modal)
225 qDebug() << __PRETTY_FUNCTION__;
227 QString errorMessage = message;
231 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
234 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
235 // extra line changes are needed to make error notes broader
236 errorMessage.prepend("\n");
237 errorMessage.append("\n");
239 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
241 QLabel *label = new QLabel(msgBox);
242 label->setAlignment(Qt::AlignCenter);
243 label->setText(errorMessage);
244 msgBox->setWidget(label);
246 QMessageBox *msgBox = new QMessageBox(this);
247 msgBox->button(QMessageBox::Ok);
248 msgBox->setText(errorMessage);
249 msgBox->setModal(modal);
255 void MainWindow::buildLocationSearchPanel()
257 qDebug() << __PRETTY_FUNCTION__;
259 m_locationSearchPanel = new LocationSearchPanel(this);
261 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
262 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
264 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
265 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
267 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
268 this, SIGNAL(routeTo(const GeoCoordinate&)));
270 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
271 this, SLOT(startLocationSearch()));
273 connect(this, SIGNAL(searchForLocation(QString)),
274 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
276 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
277 this, SIGNAL(searchHistoryItemClicked(QString)));
280 void MainWindow::buildLoginDialog(QWebView *browser)
282 qWarning() << __PRETTY_FUNCTION__;
284 if (!m_loginDialog) {
285 m_loginDialog = new QDialog(this);
287 m_loginDialog->setWindowTitle(tr("Login"));
288 m_loginDialog->setLayout(new QVBoxLayout());
289 m_loginDialog->layout()->addWidget(browser);
290 m_loginDialog->layout()->setContentsMargins(QMargins()); // zero margins
291 connect(m_loginDialog, SIGNAL(rejected()), this, SLOT(destroyLoginDialog()));
296 m_loginDialog->show();
299 void MainWindow::buildMap()
301 qDebug() << __PRETTY_FUNCTION__;
303 m_mapView = new MapView(this);
305 buildZoomButtonPanel();
308 buildFullScreenButton();
309 buildIndicatorButtonPanel();
312 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
313 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
315 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
316 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
318 connect(m_mapView, SIGNAL(viewResized(QSize)),
319 this, SIGNAL(mapViewResized(QSize)));
321 connect(m_mapView, SIGNAL(viewResized(QSize)),
322 this, SLOT(drawFullScreenButton(QSize)));
324 connect(m_mapView, SIGNAL(viewResized(QSize)),
325 this, SLOT(drawMapScale(QSize)));
327 connect(m_mapView, SIGNAL(viewResized(QSize)),
328 this, SLOT(moveCrosshair()));
330 connect(this, SIGNAL(zoomLevelChanged(int)),
331 m_mapView, SLOT(setZoomLevel(int)));
333 connect(m_mapView, SIGNAL(viewZoomFinished()),
334 this, SIGNAL(viewZoomFinished()));
336 connect(m_mapView, SIGNAL(zoomIn()),
337 this, SIGNAL(zoomIn()));
340 void MainWindow::buildMapScale()
342 m_mapScale = new MapScale(this);
343 connect(this, SIGNAL(newMapResolution(qreal)),
344 m_mapScale, SLOT(updateMapResolution(qreal)));
347 void MainWindow::buildOsmLicense()
349 qDebug() << __PRETTY_FUNCTION__;
351 m_osmLicense = new QLabel(this);
352 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
353 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
354 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
355 m_osmLicense->setFont(QFont("Nokia Sans", 9));
356 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
357 m_osmLicense->fontMetrics().height());
359 connect(m_mapView, SIGNAL(viewResized(QSize)),
360 this, SLOT(drawOsmLicense(QSize)));
363 void MainWindow::buildPanels()
365 qDebug() << __PRETTY_FUNCTION__;
367 buildUserInfoPanel();
368 buildFriendListPanel();
369 buildLocationSearchPanel();
372 m_tabbedPanel = new TabbedPanel(this);
374 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
375 m_situareTabsIndexes.append(
376 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
377 m_situareTabsIndexes.append(
378 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
380 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
381 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
383 connect(m_mapView, SIGNAL(viewResized(QSize)),
384 m_tabbedPanel, SLOT(resizePanel(QSize)));
386 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
387 m_tabbedPanel, SLOT(openPanel(QWidget*)));
389 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
390 m_tabbedPanel, SLOT(openPanel(QWidget*)));
392 connect(m_tabbedPanel, SIGNAL(panelClosed()),
393 m_friendsListPanel, SLOT(anyPanelClosed()));
395 connect(m_tabbedPanel, SIGNAL(panelOpened()),
396 m_friendsListPanel, SLOT(anyPanelOpened()));
398 connect(m_tabbedPanel, SIGNAL(panelClosed()),
399 m_routingPanel, SLOT(clearListsSelections()));
401 connect(m_tabbedPanel, SIGNAL(panelClosed()),
402 m_mapView, SLOT(disableCenterShift()));
404 connect(m_tabbedPanel, SIGNAL(panelOpened()),
405 m_mapView, SLOT(enableCenterShift()));
407 connect(m_tabbedPanel, SIGNAL(panelClosed()),
408 m_userInfoPanel, SIGNAL(collapse()));
410 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
411 m_userInfoPanel, SIGNAL(collapse()));
413 // signals for showing and hiding list item context buttons
414 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
415 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
417 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
418 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
420 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
421 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
424 void MainWindow::buildRoutingPanel()
426 qDebug() << __PRETTY_FUNCTION__;
428 m_routingPanel = new RoutingPanel(this);
430 connect(m_routingPanel, SIGNAL(routeToCursor()),
431 this, SIGNAL(routeToCursor()));
433 connect(this, SIGNAL(routeParsed(Route&)),
434 m_routingPanel, SLOT(setRoute(Route&)));
436 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
437 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
439 connect(m_routingPanel, SIGNAL(clearRoute()),
440 this, SIGNAL(clearRoute()));
443 void MainWindow::buildUserInfoPanel()
445 qDebug() << __PRETTY_FUNCTION__;
447 m_userInfoPanel = new UserInfoPanel(this);
449 connect(this, SIGNAL(userLocationReady(User*)),
450 m_userInfoPanel, SLOT(userDataReceived(User*)));
452 connect(this, SIGNAL(reverseGeoReady(QString)),
453 m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
455 connect(this, SIGNAL(clearUpdateLocationDialogData()),
456 m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
458 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
459 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
461 connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
462 this, SIGNAL(requestReverseGeo()));
464 connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
465 this, SIGNAL(statusUpdate(QString,bool)));
467 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
468 this, SIGNAL(refreshUserData()));
470 connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
471 this, SLOT(buildInformationBox(QString, bool)));
474 void MainWindow::buildZoomButtonPanel()
476 qDebug() << __PRETTY_FUNCTION__;
478 m_zoomButtonPanel = new ZoomButtonPanel(this);
480 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
481 this, SIGNAL(zoomIn()));
483 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
484 this, SIGNAL(zoomOut()));
486 connect(this, SIGNAL(zoomLevelChanged(int)),
487 m_zoomButtonPanel, SLOT(resetButtons()));
489 connect(this, SIGNAL(maxZoomLevelReached()),
490 m_zoomButtonPanel, SLOT(disableZoomInButton()));
492 connect(this, SIGNAL(minZoomLevelReached()),
493 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
495 connect(m_mapView, SIGNAL(viewResized(QSize)),
496 m_zoomButtonPanel, SLOT(screenResized(QSize)));
498 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
499 this, SIGNAL(draggingModeTriggered()));
502 void MainWindow::createMenus()
504 qDebug() << __PRETTY_FUNCTION__;
507 m_loginAct = new QAction(tr("Login"), this);
508 connect(m_loginAct, SIGNAL(triggered()),
509 this, SIGNAL(loginActionPressed()));
512 m_toSettingsAct = new QAction(tr("Settings"), this);
513 connect(m_toSettingsAct, SIGNAL(triggered()),
514 this, SLOT(openSettingsDialog()));
517 m_gpsToggleAct = new QAction(tr("GPS"), this);
518 m_gpsToggleAct->setCheckable(true);
520 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
521 this, SIGNAL(gpsTriggered(bool)));
523 // build the actual menu
524 m_viewMenu = menuBar()->addMenu(tr("Main"));
525 m_viewMenu->addAction(m_loginAct);
526 m_viewMenu->addAction(m_toSettingsAct);
527 m_viewMenu->addAction(m_gpsToggleAct);
528 m_viewMenu->setObjectName(tr("Menu"));
531 void MainWindow::destroyLoginDialog()
533 qWarning() << __PRETTY_FUNCTION__;
536 m_loginDialog->hide();
537 m_loginDialog->deleteLater();
542 void MainWindow::dialogFinished(int status)
544 qDebug() << __PRETTY_FUNCTION__;
546 QDialog *dialog = m_queue.takeFirst();
547 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
548 if ((searchDialog) && (status != 0))
549 emit searchForLocation(searchDialog->input());
551 dialog->deleteLater();
553 if(!m_error_queue.isEmpty() && m_errorShown == false) {
554 showErrorInformationBox();
556 if(!m_queue.isEmpty()) {
557 showInformationBox();
562 void MainWindow::drawFullScreenButton(const QSize &size)
564 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
566 if (m_fullScreenButton) {
567 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
568 size.height() - m_fullScreenButton->size().height());
572 void MainWindow::drawMapScale(const QSize &size)
574 qDebug() << __PRETTY_FUNCTION__;
576 const int LEFT_SCALE_MARGIN = 10;
577 const int BOTTOM_SCALE_MARGIN = 2;
579 m_mapScale->move(LEFT_SCALE_MARGIN,
580 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
583 void MainWindow::drawOsmLicense(const QSize &size)
585 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
587 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
589 size.height() - m_osmLicense->fontMetrics().height());
592 void MainWindow::errorDialogFinished(int status)
594 qDebug() << __PRETTY_FUNCTION__;
597 QDialog *dialog = m_error_queue.takeFirst();
599 dialog->deleteLater();
600 m_errorShown = false;
602 if(!m_error_queue.isEmpty())
603 showErrorInformationBox();
604 else if(!m_queue.isEmpty())
605 showInformationBox();
608 void MainWindow::gpsTimeout()
610 qDebug() << __PRETTY_FUNCTION__;
612 buildInformationBox(tr("GPS timeout"));
615 void MainWindow::grabZoomKeys(bool grab)
617 qDebug() << __PRETTY_FUNCTION__;
620 // Can't grab keys unless we have a window id
624 unsigned long val = (grab) ? 1 : 0;
625 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
629 XChangeProperty (QX11Info::display(),
635 reinterpret_cast<unsigned char *>(&val),
639 #endif // Q_WS_MAEMO_5
642 void MainWindow::keyPressEvent(QKeyEvent* event)
644 qDebug() << __PRETTY_FUNCTION__;
646 switch (event->key()) {
657 QWidget::keyPressEvent(event);
660 void MainWindow::loggedIn(bool logged)
662 qDebug() << __PRETTY_FUNCTION__;
667 m_loginAct->setText(tr("Logout"));
669 m_loginAct->setText(tr("Login"));
670 m_userInfoPanel->showUserInfo(false);
672 updateItemVisibility(logged);
675 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
677 m_mapCenterHorizontalShifting = shifting;
681 void MainWindow::moveCrosshair()
683 qDebug() << __PRETTY_FUNCTION__;
686 int mapHeight = m_mapView->size().height();
687 int mapWidth = m_mapView->size().width();
688 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
689 - m_mapCenterHorizontalShifting,
690 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
694 void MainWindow::openSettingsDialog()
696 qDebug() << __PRETTY_FUNCTION__;
698 SettingsDialog *settingsDialog = new SettingsDialog(this);
699 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
700 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
702 settingsDialog->show();
705 void MainWindow::queueDialog(QDialog *dialog)
707 qDebug() << __PRETTY_FUNCTION__;
709 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
710 if(dialog->isModal()) {
711 m_error_queue.append(dialog);
713 m_queue.append(dialog);
716 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
717 if(m_error_queue.count() == 1 && m_errorShown == false)
718 showErrorInformationBox();
719 else if(m_queue.count() == 1 && m_errorShown == false)
720 showInformationBox();
723 void MainWindow::readAutomaticLocationUpdateSettings()
725 qDebug() << __PRETTY_FUNCTION__;
727 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
728 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
729 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
732 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
734 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
736 emit enableAutomaticLocationUpdate(false);
740 void MainWindow::setCrosshairVisibility(bool visibility)
742 qDebug() << __PRETTY_FUNCTION__;
752 void MainWindow::setGPSButtonEnabled(bool enabled)
754 qDebug() << __PRETTY_FUNCTION__;
756 m_gpsToggleAct->setChecked(enabled);
759 void MainWindow::setIndicatorButtonEnabled(bool enabled)
761 qDebug() << __PRETTY_FUNCTION__;
763 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
766 void MainWindow::setMapViewScene(QGraphicsScene *scene)
768 qDebug() << __PRETTY_FUNCTION__;
770 m_mapView->setScene(scene);
773 void MainWindow::settingsDialogAccepted()
775 qDebug() << __PRETTY_FUNCTION__;
777 readAutomaticLocationUpdateSettings();
780 void MainWindow::showContactDialog(const QString &guid)
782 qDebug() << __PRETTY_FUNCTION__;
784 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
785 OssoABookDialog::showContactDialog(guid);
788 buildInformationBox(tr("Contact dialog works only on phone!"), true);
792 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
794 qDebug() << __PRETTY_FUNCTION__;
796 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
797 tr("Automatic location update"), text,
798 QMessageBox::Yes | QMessageBox::No |
799 QMessageBox::Cancel, this);
800 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
801 this, SLOT(automaticUpdateDialogFinished(int)));
803 m_automaticUpdateLocationDialog->show();
806 void MainWindow::showErrorInformationBox()
808 qDebug() << __PRETTY_FUNCTION__;
810 if(m_error_queue.count()) {
812 QDialog *dialog = m_error_queue.first();
813 connect(dialog, SIGNAL(finished(int)),
814 this, SLOT(errorDialogFinished(int)));
819 void MainWindow::showInformationBox()
821 qDebug() << __PRETTY_FUNCTION__;
823 if(m_queue.count()) {
824 QDialog *dialog = m_queue.first();
825 connect(dialog, SIGNAL(finished(int)),
826 this, SLOT(dialogFinished(int)));
831 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
833 qWarning() << __PRETTY_FUNCTION__;
835 reply->ignoreSslErrors();
838 void MainWindow::startLocationSearch()
840 qDebug() << __PRETTY_FUNCTION__;
842 SearchDialog *searchDialog = new SearchDialog();
843 queueDialog(searchDialog);
846 void MainWindow::toggleFullScreen()
848 qDebug() << __PRETTY_FUNCTION__;
850 if(windowState() == Qt::WindowNoState)
856 void MainWindow::toggleProgressIndicator(bool value)
858 qDebug() << __PRETTY_FUNCTION__;
862 m_progressIndicatorCount++;
863 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
865 if(m_progressIndicatorCount > 0)
866 m_progressIndicatorCount--;
868 if(m_progressIndicatorCount == 0)
869 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
873 #endif // Q_WS_MAEMO_5
876 void MainWindow::updateItemVisibility(bool loggedIn)
878 qDebug() << __PRETTY_FUNCTION__;
880 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn);