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),
81 m_updateLocationController(0)
83 qDebug() << __PRETTY_FUNCTION__;
87 // map view is the only widget which size & location is handled automatically by the system
88 // default functionality
89 setCentralWidget(m_mapView);
94 setWindowTitle(tr("Situare"));
96 // set stacking order of widgets (from top to bottom)
97 // m_tabbedPanel is the topmost one
98 if (m_fullScreenButton) {
99 m_fullScreenButton->stackUnder(m_tabbedPanel);
100 m_crosshair->stackUnder(m_fullScreenButton);
102 m_crosshair->stackUnder(m_tabbedPanel);
104 m_zoomButtonPanel->stackUnder(m_crosshair);
105 m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
106 m_osmLicense->stackUnder(m_indicatorButtonPanel);
107 m_mapScale->stackUnder(m_osmLicense);
108 m_mapView->stackUnder(m_mapScale);
112 // Set default screen size
113 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
115 setAttribute(Qt::WA_Maemo5StackedWindow);
119 MainWindow::~MainWindow()
121 qDebug() << __PRETTY_FUNCTION__;
125 qDeleteAll(m_queue.begin(), m_queue.end());
128 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
129 m_error_queue.clear();
132 void MainWindow::automaticUpdateDialogFinished(int result)
134 qDebug() << __PRETTY_FUNCTION__;
136 if (result == QMessageBox::Yes) {
137 readAutomaticLocationUpdateSettings();
139 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
140 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
141 readAutomaticLocationUpdateSettings();
144 m_automaticUpdateLocationDialog->deleteLater();
147 void MainWindow::buildCrosshair()
149 qDebug() << __PRETTY_FUNCTION__;
151 m_crosshair = new QLabel(this);
152 QPixmap crosshairImage(":/res/images/sight.png");
153 m_crosshair->setPixmap(crosshairImage);
154 m_crosshair->setFixedSize(crosshairImage.size());
156 m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
158 connect(m_mapView, SIGNAL(viewResized(QSize)),
159 this, SLOT(moveCrosshair()));
161 connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
162 this, SLOT(mapCenterHorizontalShiftingChanged(int)));
165 void MainWindow::buildFriendListPanel()
167 qDebug() << __PRETTY_FUNCTION__;
169 m_friendsListPanel = new FriendListPanel(this);
171 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
172 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
174 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
175 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
177 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
178 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
180 connect(this, SIGNAL(friendImageReady(User*)),
181 m_friendsListPanel, SLOT(friendImageReady(User*)));
183 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
184 this, SIGNAL(routeTo(const GeoCoordinate&)));
186 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
187 this, SIGNAL(requestContactDialog(const QString &)));
190 void MainWindow::buildFullScreenButton()
192 qDebug() << __PRETTY_FUNCTION__;
195 m_fullScreenButton = new FullScreenButton(this);
197 if (m_fullScreenButton) {
198 connect(m_fullScreenButton, SIGNAL(clicked()),
199 this, SLOT(toggleFullScreen()));
201 connect(qApp, SIGNAL(showFullScreenButton()),
202 m_fullScreenButton, SLOT(invoke()));
204 #endif // Q_WS_MAEMO_5
207 void MainWindow::buildIndicatorButtonPanel()
209 qDebug() << __PRETTY_FUNCTION__;
211 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
213 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
214 this, SIGNAL(autoCenteringTriggered(bool)));
216 connect(m_mapView, SIGNAL(viewResized(QSize)),
217 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
219 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
220 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
222 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
223 this, SIGNAL(draggingModeTriggered()));
226 void MainWindow::buildInformationBox(const QString &message, bool modal)
228 qDebug() << __PRETTY_FUNCTION__;
230 QString errorMessage = message;
234 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
237 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
238 // extra line changes are needed to make error notes broader
239 errorMessage.prepend("\n");
240 errorMessage.append("\n");
242 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
244 QLabel *label = new QLabel(msgBox);
245 label->setAlignment(Qt::AlignCenter);
246 label->setText(errorMessage);
247 msgBox->setWidget(label);
249 QMessageBox *msgBox = new QMessageBox(this);
250 msgBox->button(QMessageBox::Ok);
251 msgBox->setText(errorMessage);
252 msgBox->setModal(modal);
258 void MainWindow::buildLocationSearchPanel()
260 qDebug() << __PRETTY_FUNCTION__;
262 m_locationSearchPanel = new LocationSearchPanel(this);
264 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
265 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
267 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
268 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
270 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
271 this, SIGNAL(routeTo(const GeoCoordinate&)));
273 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
274 this, SLOT(startLocationSearch()));
276 connect(this, SIGNAL(searchForLocation(QString)),
277 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
279 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
280 this, SIGNAL(searchHistoryItemClicked(QString)));
283 void MainWindow::buildLoginDialog(QWebView *browser)
285 qWarning() << __PRETTY_FUNCTION__;
287 if (!m_loginDialog) {
288 m_loginDialog = new QDialog(this);
290 m_loginDialog->setWindowTitle(tr("Login"));
291 m_loginDialog->setLayout(new QVBoxLayout());
292 m_loginDialog->layout()->addWidget(browser);
293 m_loginDialog->layout()->setContentsMargins(QMargins()); // zero margins
294 connect(m_loginDialog, SIGNAL(rejected()), this, SLOT(destroyLoginDialog()));
299 m_loginDialog->show();
302 void MainWindow::buildMap()
304 qDebug() << __PRETTY_FUNCTION__;
306 m_mapView = new MapView(this);
308 buildZoomButtonPanel();
311 buildFullScreenButton();
312 buildIndicatorButtonPanel();
315 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
316 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
318 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
319 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
321 connect(m_mapView, SIGNAL(viewResized(QSize)),
322 this, SIGNAL(mapViewResized(QSize)));
324 connect(m_mapView, SIGNAL(viewResized(QSize)),
325 this, SLOT(drawFullScreenButton(QSize)));
327 connect(m_mapView, SIGNAL(viewResized(QSize)),
328 this, SLOT(drawMapScale(QSize)));
330 connect(m_mapView, SIGNAL(viewResized(QSize)),
331 this, SLOT(moveCrosshair()));
333 connect(this, SIGNAL(zoomLevelChanged(int)),
334 m_mapView, SLOT(setZoomLevel(int)));
336 connect(m_mapView, SIGNAL(viewZoomFinished()),
337 this, SIGNAL(viewZoomFinished()));
339 connect(m_mapView, SIGNAL(zoomIn()),
340 this, SIGNAL(zoomIn()));
343 void MainWindow::buildMapScale()
345 m_mapScale = new MapScale(this);
346 connect(this, SIGNAL(newMapResolution(qreal)),
347 m_mapScale, SLOT(updateMapResolution(qreal)));
350 void MainWindow::buildOsmLicense()
352 qDebug() << __PRETTY_FUNCTION__;
354 m_osmLicense = new QLabel(this);
355 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
356 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
357 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
358 m_osmLicense->setFont(QFont("Nokia Sans", 9));
359 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
360 m_osmLicense->fontMetrics().height());
362 connect(m_mapView, SIGNAL(viewResized(QSize)),
363 this, SLOT(drawOsmLicense(QSize)));
366 void MainWindow::buildPanels()
368 qDebug() << __PRETTY_FUNCTION__;
370 buildUserInfoPanel();
371 buildFriendListPanel();
372 buildLocationSearchPanel();
375 m_tabbedPanel = new TabbedPanel(this);
377 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
378 m_situareTabsIndexes.append(
379 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
380 m_situareTabsIndexes.append(
381 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
383 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
384 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
386 connect(m_mapView, SIGNAL(viewResized(QSize)),
387 m_tabbedPanel, SLOT(resizePanel(QSize)));
389 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
390 m_tabbedPanel, SLOT(openPanel(QWidget*)));
392 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
393 m_tabbedPanel, SLOT(openPanel(QWidget*)));
395 connect(m_tabbedPanel, SIGNAL(panelClosed()),
396 m_friendsListPanel, SLOT(anyPanelClosed()));
398 connect(m_tabbedPanel, SIGNAL(panelOpened()),
399 m_friendsListPanel, SLOT(anyPanelOpened()));
401 connect(m_tabbedPanel, SIGNAL(panelClosed()),
402 m_routingPanel, SLOT(clearListsSelections()));
404 connect(m_tabbedPanel, SIGNAL(panelClosed()),
405 m_mapView, SLOT(disableCenterShift()));
407 connect(m_tabbedPanel, SIGNAL(panelOpened()),
408 m_mapView, SLOT(enableCenterShift()));
410 connect(m_tabbedPanel, SIGNAL(panelClosed()),
411 m_userInfoPanel, SIGNAL(collapse()));
413 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
414 m_userInfoPanel, SIGNAL(collapse()));
416 // signals for showing and hiding list item context buttons
417 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
418 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
420 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
421 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
423 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
424 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
427 void MainWindow::buildRoutingPanel()
429 qDebug() << __PRETTY_FUNCTION__;
431 m_routingPanel = new RoutingPanel(this);
433 connect(m_routingPanel, SIGNAL(routeToCursor()),
434 this, SIGNAL(routeToCursor()));
436 connect(this, SIGNAL(routeParsed(Route&)),
437 m_routingPanel, SLOT(setRoute(Route&)));
439 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
440 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
442 connect(m_routingPanel, SIGNAL(clearRoute()),
443 this, SIGNAL(clearRoute()));
446 void MainWindow::buildUserInfoPanel()
448 qDebug() << __PRETTY_FUNCTION__;
450 m_userInfoPanel = new UserInfoPanel(this);
452 connect(this, SIGNAL(userLocationReady(User*)),
453 m_userInfoPanel, SLOT(userDataReceived(User*)));
455 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
456 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
458 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
459 this, SIGNAL(refreshUserData()));
461 connect(m_userInfoPanel, SIGNAL(updateLocationMessageButtonClicked()),
462 this, SLOT(showUpdateLocationDialog()));
465 void MainWindow::buildZoomButtonPanel()
467 qDebug() << __PRETTY_FUNCTION__;
469 m_zoomButtonPanel = new ZoomButtonPanel(this);
471 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
472 this, SIGNAL(zoomIn()));
474 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
475 this, SIGNAL(zoomOut()));
477 connect(this, SIGNAL(zoomLevelChanged(int)),
478 m_zoomButtonPanel, SLOT(resetButtons()));
480 connect(this, SIGNAL(maxZoomLevelReached()),
481 m_zoomButtonPanel, SLOT(disableZoomInButton()));
483 connect(this, SIGNAL(minZoomLevelReached()),
484 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
486 connect(m_mapView, SIGNAL(viewResized(QSize)),
487 m_zoomButtonPanel, SLOT(screenResized(QSize)));
489 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
490 this, SIGNAL(draggingModeTriggered()));
493 void MainWindow::createMenus()
495 qDebug() << __PRETTY_FUNCTION__;
498 m_loginAct = new QAction(tr("Login"), this);
499 connect(m_loginAct, SIGNAL(triggered()),
500 this, SIGNAL(loginActionPressed()));
503 m_toSettingsAct = new QAction(tr("Settings"), this);
504 connect(m_toSettingsAct, SIGNAL(triggered()),
505 this, SLOT(openSettingsDialog()));
508 m_gpsToggleAct = new QAction(tr("GPS"), this);
509 m_gpsToggleAct->setCheckable(true);
511 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
512 this, SIGNAL(gpsTriggered(bool)));
514 // build the actual menu
515 m_viewMenu = menuBar()->addMenu(tr("Main"));
516 m_viewMenu->addAction(m_loginAct);
517 m_viewMenu->addAction(m_toSettingsAct);
518 m_viewMenu->addAction(m_gpsToggleAct);
519 m_viewMenu->setObjectName(tr("Menu"));
522 void MainWindow::destroyLoginDialog()
524 qWarning() << __PRETTY_FUNCTION__;
527 m_loginDialog->hide();
528 m_loginDialog->deleteLater();
533 void MainWindow::dialogFinished(int status)
535 qDebug() << __PRETTY_FUNCTION__;
537 QDialog *dialog = m_queue.takeFirst();
538 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
539 if ((searchDialog) && (status != 0))
540 emit searchForLocation(searchDialog->input());
542 dialog->deleteLater();
544 if(!m_error_queue.isEmpty() && m_errorShown == false) {
545 showErrorInformationBox();
547 if(!m_queue.isEmpty()) {
548 showInformationBox();
553 void MainWindow::drawFullScreenButton(const QSize &size)
555 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
557 if (m_fullScreenButton) {
558 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
559 size.height() - m_fullScreenButton->size().height());
563 void MainWindow::drawMapScale(const QSize &size)
565 qDebug() << __PRETTY_FUNCTION__;
567 const int LEFT_SCALE_MARGIN = 10;
568 const int BOTTOM_SCALE_MARGIN = 2;
570 m_mapScale->move(LEFT_SCALE_MARGIN,
571 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
574 void MainWindow::drawOsmLicense(const QSize &size)
576 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
578 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
580 size.height() - m_osmLicense->fontMetrics().height());
583 void MainWindow::errorDialogFinished(int status)
585 qDebug() << __PRETTY_FUNCTION__;
588 QDialog *dialog = m_error_queue.takeFirst();
590 dialog->deleteLater();
591 m_errorShown = false;
593 if(!m_error_queue.isEmpty())
594 showErrorInformationBox();
595 else if(!m_queue.isEmpty())
596 showInformationBox();
599 void MainWindow::gpsTimeout()
601 qDebug() << __PRETTY_FUNCTION__;
603 buildInformationBox(tr("GPS timeout"));
606 void MainWindow::grabZoomKeys(bool grab)
608 qDebug() << __PRETTY_FUNCTION__;
611 // Can't grab keys unless we have a window id
615 unsigned long val = (grab) ? 1 : 0;
616 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
620 XChangeProperty (QX11Info::display(),
626 reinterpret_cast<unsigned char *>(&val),
630 #endif // Q_WS_MAEMO_5
633 void MainWindow::keyPressEvent(QKeyEvent* event)
635 qDebug() << __PRETTY_FUNCTION__;
637 switch (event->key()) {
648 QWidget::keyPressEvent(event);
651 void MainWindow::loggedIn(bool logged)
653 qDebug() << __PRETTY_FUNCTION__;
658 m_loginAct->setText(tr("Logout"));
660 m_loginAct->setText(tr("Login"));
661 m_userInfoPanel->showUserInfo(false);
662 m_updateLocationController->clear();
664 updateItemVisibility(logged);
667 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
669 m_mapCenterHorizontalShifting = shifting;
673 void MainWindow::moveCrosshair()
675 qDebug() << __PRETTY_FUNCTION__;
678 int mapHeight = m_mapView->size().height();
679 int mapWidth = m_mapView->size().width();
680 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
681 - m_mapCenterHorizontalShifting,
682 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
686 void MainWindow::openSettingsDialog()
688 qDebug() << __PRETTY_FUNCTION__;
690 SettingsDialog *settingsDialog = new SettingsDialog(this);
691 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
692 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
694 settingsDialog->show();
697 void MainWindow::queueDialog(QDialog *dialog)
699 qDebug() << __PRETTY_FUNCTION__;
701 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
702 if(dialog->isModal()) {
703 m_error_queue.append(dialog);
705 m_queue.append(dialog);
708 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
709 if(m_error_queue.count() == 1 && m_errorShown == false)
710 showErrorInformationBox();
711 else if(m_queue.count() == 1 && m_errorShown == false)
712 showInformationBox();
715 void MainWindow::readAutomaticLocationUpdateSettings()
717 qDebug() << __PRETTY_FUNCTION__;
719 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
720 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
721 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
724 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
726 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
728 emit enableAutomaticLocationUpdate(false);
732 void MainWindow::setCrosshairVisibility(bool visibility)
734 qDebug() << __PRETTY_FUNCTION__;
744 void MainWindow::setGPSButtonEnabled(bool enabled)
746 qDebug() << __PRETTY_FUNCTION__;
748 m_gpsToggleAct->setChecked(enabled);
751 void MainWindow::setIndicatorButtonEnabled(bool enabled)
753 qDebug() << __PRETTY_FUNCTION__;
755 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
758 void MainWindow::setMapViewScene(QGraphicsScene *scene)
760 qDebug() << __PRETTY_FUNCTION__;
762 m_mapView->setScene(scene);
765 void MainWindow::settingsDialogAccepted()
767 qDebug() << __PRETTY_FUNCTION__;
769 readAutomaticLocationUpdateSettings();
772 void MainWindow::showContactDialog(const QString &guid)
774 qDebug() << __PRETTY_FUNCTION__;
776 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
777 OssoABookDialog::showContactDialog(guid);
780 buildInformationBox(tr("Contact dialog works only on phone!"), true);
784 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
786 qDebug() << __PRETTY_FUNCTION__;
788 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
789 tr("Automatic location update"), text,
790 QMessageBox::Yes | QMessageBox::No |
791 QMessageBox::Cancel, this);
792 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
793 this, SLOT(automaticUpdateDialogFinished(int)));
795 m_automaticUpdateLocationDialog->show();
798 void MainWindow::showErrorInformationBox()
800 qDebug() << __PRETTY_FUNCTION__;
802 if(m_error_queue.count()) {
804 QDialog *dialog = m_error_queue.first();
805 connect(dialog, SIGNAL(finished(int)),
806 this, SLOT(errorDialogFinished(int)));
811 void MainWindow::showInformationBox()
813 qDebug() << __PRETTY_FUNCTION__;
815 if(m_queue.count()) {
816 QDialog *dialog = m_queue.first();
817 connect(dialog, SIGNAL(finished(int)),
818 this, SLOT(dialogFinished(int)));
823 void MainWindow::showUpdateLocationDialog()
825 qDebug() << __PRETTY_FUNCTION__;
827 if (!m_updateLocationController) {
828 m_updateLocationController = new UpdateLocation(this);
829 if (!m_updateLocationController)
832 connect(this, SIGNAL(updateWasSuccessful()), m_updateLocationController, SLOT(clear()));
833 connect(m_updateLocationController, SIGNAL(locationUpdate(QString,bool)),
834 this, SIGNAL(locationUpdate(QString,bool)));
837 UpdateLocationDialog *updateLocationDialog
838 = new UpdateLocationDialog(m_updateLocationController, this);
840 connect(this, SIGNAL(reverseGeoReady(QString)),
841 updateLocationDialog, SLOT(setAddress(QString)));
843 updateLocationDialog->show();
845 emit requestReverseGeo();
848 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
850 qWarning() << __PRETTY_FUNCTION__;
853 reply->ignoreSslErrors();
856 void MainWindow::startLocationSearch()
858 qDebug() << __PRETTY_FUNCTION__;
860 SearchDialog *searchDialog = new SearchDialog();
861 queueDialog(searchDialog);
864 void MainWindow::toggleFullScreen()
866 qDebug() << __PRETTY_FUNCTION__;
868 if(windowState() == Qt::WindowNoState)
874 void MainWindow::toggleProgressIndicator(bool value)
876 qDebug() << __PRETTY_FUNCTION__;
880 m_progressIndicatorCount++;
881 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
883 if(m_progressIndicatorCount > 0)
884 m_progressIndicatorCount--;
886 if(m_progressIndicatorCount == 0)
887 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
891 #endif // Q_WS_MAEMO_5
894 void MainWindow::updateItemVisibility(bool loggedIn)
896 qDebug() << __PRETTY_FUNCTION__;
898 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn);