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 "facebookloginbrowser.h"
38 #include "friendlistpanel.h"
39 #include "fullscreenbutton.h"
40 #include "indicatorbuttonpanel.h"
41 #include "locationsearchpanel.h"
42 #include "logindialog.h"
43 #include "map/mapcommon.h"
44 #include "map/mapview.h"
46 #include "panelcommon.h"
47 #include "routingpanel.h"
48 #include "searchdialog.h"
49 #include "settingsdialog.h"
50 #include "situareservice/situarecommon.h"
51 #include "tabbedpanel.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_email(), ///< @todo WTF?!?!?!?
80 m_fullScreenButton(0),
81 m_indicatorButtonPanel(0),
84 qDebug() << __PRETTY_FUNCTION__;
88 // map view is the only widget which size & location is handled automatically by the system
89 // default functionality
90 setCentralWidget(m_mapView);
95 setWindowTitle(tr("Situare"));
97 // set stacking order of widgets (from top to bottom)
98 // m_tabbedPanel is the topmost one
99 if (m_fullScreenButton) {
100 m_fullScreenButton->stackUnder(m_tabbedPanel);
101 m_crosshair->stackUnder(m_fullScreenButton);
103 m_crosshair->stackUnder(m_tabbedPanel);
105 m_zoomButtonPanel->stackUnder(m_crosshair);
106 m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
107 m_osmLicense->stackUnder(m_indicatorButtonPanel);
108 m_mapScale->stackUnder(m_osmLicense);
109 m_mapView->stackUnder(m_mapScale);
113 // Set default screen size
114 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
116 setAttribute(Qt::WA_Maemo5StackedWindow);
120 MainWindow::~MainWindow()
122 qDebug() << __PRETTY_FUNCTION__;
126 qDeleteAll(m_queue.begin(), m_queue.end());
129 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
130 m_error_queue.clear();
133 void MainWindow::automaticUpdateDialogFinished(int result)
135 qDebug() << __PRETTY_FUNCTION__;
137 if (result == QMessageBox::Yes) {
138 readAutomaticLocationUpdateSettings();
140 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
141 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
142 readAutomaticLocationUpdateSettings();
145 m_automaticUpdateLocationDialog->deleteLater();
148 void MainWindow::buildCrosshair()
150 qDebug() << __PRETTY_FUNCTION__;
152 m_crosshair = new QLabel(this);
153 QPixmap crosshairImage(":/res/images/sight.png");
154 m_crosshair->setPixmap(crosshairImage);
155 m_crosshair->setFixedSize(crosshairImage.size());
157 m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
159 connect(m_mapView, SIGNAL(viewResized(QSize)),
160 this, SLOT(moveCrosshair()));
162 connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
163 this, SLOT(mapCenterHorizontalShiftingChanged(int)));
166 void MainWindow::buildFriendListPanel()
168 qDebug() << __PRETTY_FUNCTION__;
170 m_friendsListPanel = new FriendListPanel(this);
172 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
173 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
175 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
176 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
178 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
179 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
181 connect(this, SIGNAL(friendImageReady(User*)),
182 m_friendsListPanel, SLOT(friendImageReady(User*)));
184 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
185 this, SIGNAL(routeTo(const GeoCoordinate&)));
187 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
188 this, SIGNAL(requestContactDialog(const QString &)));
191 void MainWindow::buildFullScreenButton()
193 qDebug() << __PRETTY_FUNCTION__;
196 m_fullScreenButton = new FullScreenButton(this);
198 if (m_fullScreenButton) {
199 connect(m_fullScreenButton, SIGNAL(clicked()),
200 this, SLOT(toggleFullScreen()));
202 connect(qApp, SIGNAL(showFullScreenButton()),
203 m_fullScreenButton, SLOT(invoke()));
205 #endif // Q_WS_MAEMO_5
208 void MainWindow::buildIndicatorButtonPanel()
210 qDebug() << __PRETTY_FUNCTION__;
212 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
214 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
215 this, SIGNAL(autoCenteringTriggered(bool)));
217 connect(m_mapView, SIGNAL(viewResized(QSize)),
218 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
220 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
221 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
223 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
224 this, SIGNAL(draggingModeTriggered()));
227 void MainWindow::buildInformationBox(const QString &message, bool modal)
229 qDebug() << __PRETTY_FUNCTION__;
231 QString errorMessage = message;
235 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
238 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
239 // extra line changes are needed to make error notes broader
240 errorMessage.prepend("\n");
241 errorMessage.append("\n");
243 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
245 QLabel *label = new QLabel(msgBox);
246 label->setAlignment(Qt::AlignCenter);
247 label->setText(errorMessage);
248 msgBox->setWidget(label);
250 QMessageBox *msgBox = new QMessageBox(this);
251 msgBox->button(QMessageBox::Ok);
252 msgBox->setText(errorMessage);
253 msgBox->setModal(modal);
259 void MainWindow::buildLocationSearchPanel()
261 qDebug() << __PRETTY_FUNCTION__;
263 m_locationSearchPanel = new LocationSearchPanel(this);
265 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
266 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
268 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
269 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
271 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
272 this, SIGNAL(routeTo(const GeoCoordinate&)));
274 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
275 this, SLOT(startLocationSearch()));
277 connect(this, SIGNAL(searchForLocation(QString)),
278 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
280 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
281 this, SIGNAL(searchHistoryItemClicked(QString)));
284 void MainWindow::buildLoginDialog(FacebookLoginBrowser *browser)
286 qWarning() << __PRETTY_FUNCTION__;
288 if (!m_loginDialog) {
289 m_loginDialog = new QDialog(this);
291 m_loginDialog->setWindowTitle(tr("Login"));
292 m_loginDialog->setLayout(new QVBoxLayout());
293 m_loginDialog->layout()->addWidget(browser);
294 m_loginDialog->layout()->setContentsMargins(QMargins()); // zero margins
295 connect(m_loginDialog, SIGNAL(rejected()), this, SLOT(destroyLoginDialog()));
300 m_loginDialog->show();
303 void MainWindow::buildMap()
305 qDebug() << __PRETTY_FUNCTION__;
307 m_mapView = new MapView(this);
309 buildZoomButtonPanel();
312 buildFullScreenButton();
313 buildIndicatorButtonPanel();
316 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
317 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
319 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
320 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
322 connect(m_mapView, SIGNAL(viewResized(QSize)),
323 this, SIGNAL(mapViewResized(QSize)));
325 connect(m_mapView, SIGNAL(viewResized(QSize)),
326 this, SLOT(drawFullScreenButton(QSize)));
328 connect(m_mapView, SIGNAL(viewResized(QSize)),
329 this, SLOT(drawMapScale(QSize)));
331 connect(m_mapView, SIGNAL(viewResized(QSize)),
332 this, SLOT(moveCrosshair()));
334 connect(this, SIGNAL(zoomLevelChanged(int)),
335 m_mapView, SLOT(setZoomLevel(int)));
337 connect(m_mapView, SIGNAL(viewZoomFinished()),
338 this, SIGNAL(viewZoomFinished()));
340 connect(m_mapView, SIGNAL(zoomIn()),
341 this, SIGNAL(zoomIn()));
344 void MainWindow::buildMapScale()
346 m_mapScale = new MapScale(this);
347 connect(this, SIGNAL(newMapResolution(qreal)),
348 m_mapScale, SLOT(updateMapResolution(qreal)));
351 void MainWindow::buildOsmLicense()
353 qDebug() << __PRETTY_FUNCTION__;
355 m_osmLicense = new QLabel(this);
356 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
357 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
358 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
359 m_osmLicense->setFont(QFont("Nokia Sans", 9));
360 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
361 m_osmLicense->fontMetrics().height());
363 connect(m_mapView, SIGNAL(viewResized(QSize)),
364 this, SLOT(drawOsmLicense(QSize)));
367 void MainWindow::buildPanels()
369 qDebug() << __PRETTY_FUNCTION__;
371 buildUserInfoPanel();
372 buildFriendListPanel();
373 buildLocationSearchPanel();
376 m_tabbedPanel = new TabbedPanel(this);
378 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
379 m_situareTabsIndexes.append(
380 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
381 m_situareTabsIndexes.append(
382 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
384 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
385 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
387 connect(m_mapView, SIGNAL(viewResized(QSize)),
388 m_tabbedPanel, SLOT(resizePanel(QSize)));
390 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
391 m_tabbedPanel, SLOT(openPanel(QWidget*)));
393 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
394 m_tabbedPanel, SLOT(openPanel(QWidget*)));
396 connect(m_tabbedPanel, SIGNAL(panelClosed()),
397 m_friendsListPanel, SLOT(anyPanelClosed()));
399 connect(m_tabbedPanel, SIGNAL(panelOpened()),
400 m_friendsListPanel, SLOT(anyPanelOpened()));
402 connect(m_tabbedPanel, SIGNAL(panelClosed()),
403 m_routingPanel, SLOT(clearListsSelections()));
405 connect(m_tabbedPanel, SIGNAL(panelClosed()),
406 m_mapView, SLOT(disableCenterShift()));
408 connect(m_tabbedPanel, SIGNAL(panelOpened()),
409 m_mapView, SLOT(enableCenterShift()));
411 connect(m_tabbedPanel, SIGNAL(panelClosed()),
412 m_userInfoPanel, SIGNAL(collapse()));
414 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
415 m_userInfoPanel, SIGNAL(collapse()));
417 // signals for showing and hiding list item context buttons
418 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
419 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
421 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
422 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
424 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
425 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
428 void MainWindow::buildRoutingPanel()
430 qDebug() << __PRETTY_FUNCTION__;
432 m_routingPanel = new RoutingPanel(this);
434 connect(m_routingPanel, SIGNAL(routeToCursor()),
435 this, SIGNAL(routeToCursor()));
437 connect(this, SIGNAL(routeParsed(Route&)),
438 m_routingPanel, SLOT(setRoute(Route&)));
440 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
441 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
443 connect(m_routingPanel, SIGNAL(clearRoute()),
444 this, SIGNAL(clearRoute()));
447 void MainWindow::buildUserInfoPanel()
449 qDebug() << __PRETTY_FUNCTION__;
451 m_userInfoPanel = new UserInfoPanel(this);
453 connect(this, SIGNAL(userLocationReady(User*)),
454 m_userInfoPanel, SLOT(userDataReceived(User*)));
456 connect(this, SIGNAL(reverseGeoReady(QString)),
457 m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
459 connect(this, SIGNAL(clearUpdateLocationDialogData()),
460 m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
462 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
463 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
465 connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
466 this, SIGNAL(requestReverseGeo()));
468 connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
469 this, SIGNAL(statusUpdate(QString,bool)));
471 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
472 this, SIGNAL(refreshUserData()));
474 connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
475 this, SLOT(buildInformationBox(QString, bool)));
478 void MainWindow::buildZoomButtonPanel()
480 qDebug() << __PRETTY_FUNCTION__;
482 m_zoomButtonPanel = new ZoomButtonPanel(this);
484 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
485 this, SIGNAL(zoomIn()));
487 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
488 this, SIGNAL(zoomOut()));
490 connect(this, SIGNAL(zoomLevelChanged(int)),
491 m_zoomButtonPanel, SLOT(resetButtons()));
493 connect(this, SIGNAL(maxZoomLevelReached()),
494 m_zoomButtonPanel, SLOT(disableZoomInButton()));
496 connect(this, SIGNAL(minZoomLevelReached()),
497 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
499 connect(m_mapView, SIGNAL(viewResized(QSize)),
500 m_zoomButtonPanel, SLOT(screenResized(QSize)));
502 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
503 this, SIGNAL(draggingModeTriggered()));
506 void MainWindow::createMenus()
508 qDebug() << __PRETTY_FUNCTION__;
511 m_loginAct = new QAction(tr("Login"), this);
512 connect(m_loginAct, SIGNAL(triggered()),
513 this, SIGNAL(loginActionPressed()));
516 m_toSettingsAct = new QAction(tr("Settings"), this);
517 connect(m_toSettingsAct, SIGNAL(triggered()),
518 this, SLOT(openSettingsDialog()));
521 m_gpsToggleAct = new QAction(tr("GPS"), this);
522 m_gpsToggleAct->setCheckable(true);
524 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
525 this, SIGNAL(gpsTriggered(bool)));
527 // build the actual menu
528 m_viewMenu = menuBar()->addMenu(tr("Main"));
529 m_viewMenu->addAction(m_loginAct);
530 m_viewMenu->addAction(m_toSettingsAct);
531 m_viewMenu->addAction(m_gpsToggleAct);
532 m_viewMenu->setObjectName(tr("Menu"));
535 void MainWindow::destroyLoginDialog()
537 qWarning() << __PRETTY_FUNCTION__;
540 m_loginDialog->hide();
541 m_loginDialog->deleteLater();
546 void MainWindow::dialogFinished(int status)
548 qDebug() << __PRETTY_FUNCTION__;
550 QDialog *dialog = m_queue.takeFirst();
551 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
552 if ((searchDialog) && (status != 0))
553 emit searchForLocation(searchDialog->input());
555 dialog->deleteLater();
557 if(!m_error_queue.isEmpty() && m_errorShown == false) {
558 showErrorInformationBox();
560 if(!m_queue.isEmpty()) {
561 showInformationBox();
566 void MainWindow::drawFullScreenButton(const QSize &size)
568 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
570 if (m_fullScreenButton) {
571 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
572 size.height() - m_fullScreenButton->size().height());
576 void MainWindow::drawMapScale(const QSize &size)
578 qDebug() << __PRETTY_FUNCTION__;
580 const int LEFT_SCALE_MARGIN = 10;
581 const int BOTTOM_SCALE_MARGIN = 2;
583 m_mapScale->move(LEFT_SCALE_MARGIN,
584 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
587 void MainWindow::drawOsmLicense(const QSize &size)
589 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
591 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
593 size.height() - m_osmLicense->fontMetrics().height());
596 void MainWindow::errorDialogFinished(int status)
598 qDebug() << __PRETTY_FUNCTION__;
601 QDialog *dialog = m_error_queue.takeFirst();
603 dialog->deleteLater();
604 m_errorShown = false;
606 if(!m_error_queue.isEmpty())
607 showErrorInformationBox();
608 else if(!m_queue.isEmpty())
609 showInformationBox();
612 void MainWindow::gpsTimeout()
614 qDebug() << __PRETTY_FUNCTION__;
616 buildInformationBox(tr("GPS timeout"));
619 void MainWindow::grabZoomKeys(bool grab)
621 qDebug() << __PRETTY_FUNCTION__;
624 // Can't grab keys unless we have a window id
628 unsigned long val = (grab) ? 1 : 0;
629 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
633 XChangeProperty (QX11Info::display(),
639 reinterpret_cast<unsigned char *>(&val),
643 #endif // Q_WS_MAEMO_5
646 void MainWindow::keyPressEvent(QKeyEvent* event)
648 qDebug() << __PRETTY_FUNCTION__;
650 switch (event->key()) {
661 QWidget::keyPressEvent(event);
664 void MainWindow::loggedIn(bool logged)
667 qDebug() << __PRETTY_FUNCTION__;
672 m_loginAct->setText(tr("Logout"));
678 m_loginAct->setText(tr("Login"));
679 m_userInfoPanel->showUserInfo(false);
681 updateItemVisibility();
684 void MainWindow::loginFailed()
687 qDebug() << __PRETTY_FUNCTION__;
693 bool MainWindow::loginState()
695 qDebug() << __PRETTY_FUNCTION__;
700 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
702 m_mapCenterHorizontalShifting = shifting;
706 void MainWindow::moveCrosshair()
708 qDebug() << __PRETTY_FUNCTION__;
711 int mapHeight = m_mapView->size().height();
712 int mapWidth = m_mapView->size().width();
713 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
714 - m_mapCenterHorizontalShifting,
715 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
719 void MainWindow::openSettingsDialog()
721 qDebug() << __PRETTY_FUNCTION__;
723 SettingsDialog *settingsDialog = new SettingsDialog(this);
724 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
725 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
727 settingsDialog->show();
730 void MainWindow::queueDialog(QDialog *dialog)
732 qDebug() << __PRETTY_FUNCTION__;
734 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
735 if(dialog->isModal()) {
736 m_error_queue.append(dialog);
738 m_queue.append(dialog);
741 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
742 if(m_error_queue.count() == 1 && m_errorShown == false)
743 showErrorInformationBox();
744 else if(m_queue.count() == 1 && m_errorShown == false)
745 showInformationBox();
748 void MainWindow::readAutomaticLocationUpdateSettings()
750 qDebug() << __PRETTY_FUNCTION__;
752 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
753 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
754 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
757 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
759 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
761 emit enableAutomaticLocationUpdate(false);
765 void MainWindow::setCrosshairVisibility(bool visibility)
767 qDebug() << __PRETTY_FUNCTION__;
777 void MainWindow::setGPSButtonEnabled(bool enabled)
779 qDebug() << __PRETTY_FUNCTION__;
781 m_gpsToggleAct->setChecked(enabled);
784 void MainWindow::setIndicatorButtonEnabled(bool enabled)
786 qDebug() << __PRETTY_FUNCTION__;
788 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
791 void MainWindow::setMapViewScene(QGraphicsScene *scene)
793 qDebug() << __PRETTY_FUNCTION__;
795 m_mapView->setScene(scene);
798 void MainWindow::settingsDialogAccepted()
800 qDebug() << __PRETTY_FUNCTION__;
802 readAutomaticLocationUpdateSettings();
805 void MainWindow::showContactDialog(const QString &guid)
807 qDebug() << __PRETTY_FUNCTION__;
809 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
810 OssoABookDialog::showContactDialog(guid);
813 buildInformationBox(tr("Contact dialog works only on phone!"), true);
817 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
819 qDebug() << __PRETTY_FUNCTION__;
821 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
822 tr("Automatic location update"), text,
823 QMessageBox::Yes | QMessageBox::No |
824 QMessageBox::Cancel, this);
825 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
826 this, SLOT(automaticUpdateDialogFinished(int)));
828 m_automaticUpdateLocationDialog->show();
831 void MainWindow::showErrorInformationBox()
833 qDebug() << __PRETTY_FUNCTION__;
835 if(m_error_queue.count()) {
837 QDialog *dialog = m_error_queue.first();
838 connect(dialog, SIGNAL(finished(int)),
839 this, SLOT(errorDialogFinished(int)));
844 void MainWindow::showInformationBox()
846 qDebug() << __PRETTY_FUNCTION__;
848 if(m_queue.count()) {
849 QDialog *dialog = m_queue.first();
850 connect(dialog, SIGNAL(finished(int)),
851 this, SLOT(dialogFinished(int)));
856 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
858 qWarning() << __PRETTY_FUNCTION__;
860 reply->ignoreSslErrors();
863 void MainWindow::startLocationSearch()
865 qDebug() << __PRETTY_FUNCTION__;
867 SearchDialog *searchDialog = new SearchDialog();
868 queueDialog(searchDialog);
871 void MainWindow::startLoginProcess()
873 qDebug() << __PRETTY_FUNCTION__;
875 LoginDialog *loginDialog = new LoginDialog();
877 emit fetchUsernameFromSettings();
879 loginDialog->clearTextFields();
881 if(!m_email.isEmpty())
882 loginDialog->setEmailField(m_email);
884 queueDialog(loginDialog);
887 void MainWindow::toggleFullScreen()
889 qDebug() << __PRETTY_FUNCTION__;
891 if(windowState() == Qt::WindowNoState)
897 void MainWindow::toggleProgressIndicator(bool value)
899 qDebug() << __PRETTY_FUNCTION__;
903 m_progressIndicatorCount++;
904 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
906 if(m_progressIndicatorCount > 0)
907 m_progressIndicatorCount--;
909 if(m_progressIndicatorCount == 0)
910 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
914 #endif // Q_WS_MAEMO_5
917 void MainWindow::updateItemVisibility()
919 qDebug() << __PRETTY_FUNCTION__;
921 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn);
924 const QString MainWindow::username()
926 qDebug() << __PRETTY_FUNCTION__;