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 "logindialog.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 "userinfopanel.h"
52 #include "zoombuttonpanel.h"
54 #include "mainwindow.h"
56 // These MUST BE HERE, compiling for Maemo fails if moved
58 #include <QtMaemo5/QMaemo5InformationBox>
59 #include <QtGui/QX11Info>
60 #include <X11/Xatom.h>
62 #endif // Q_WS_MAEMO_5
64 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
65 #include "ossoabookdialog.h"
68 MainWindow::MainWindow(QWidget *parent)
69 : QMainWindow(parent),
73 m_mapCenterHorizontalShifting(0),
74 m_progressIndicatorCount(0),
77 m_email(), ///< @todo WTF?!?!?!?
79 m_fullScreenButton(0),
80 m_indicatorButtonPanel(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(this, SIGNAL(reverseGeoReady(QString)),
456 m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
458 connect(this, SIGNAL(clearUpdateLocationDialogData()),
459 m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
461 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
462 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
464 connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
465 this, SIGNAL(requestReverseGeo()));
467 connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
468 this, SIGNAL(statusUpdate(QString,bool)));
470 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
471 this, SIGNAL(refreshUserData()));
473 connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
474 this, SLOT(buildInformationBox(QString, bool)));
477 void MainWindow::buildZoomButtonPanel()
479 qDebug() << __PRETTY_FUNCTION__;
481 m_zoomButtonPanel = new ZoomButtonPanel(this);
483 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
484 this, SIGNAL(zoomIn()));
486 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
487 this, SIGNAL(zoomOut()));
489 connect(this, SIGNAL(zoomLevelChanged(int)),
490 m_zoomButtonPanel, SLOT(resetButtons()));
492 connect(this, SIGNAL(maxZoomLevelReached()),
493 m_zoomButtonPanel, SLOT(disableZoomInButton()));
495 connect(this, SIGNAL(minZoomLevelReached()),
496 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
498 connect(m_mapView, SIGNAL(viewResized(QSize)),
499 m_zoomButtonPanel, SLOT(screenResized(QSize)));
501 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
502 this, SIGNAL(draggingModeTriggered()));
505 void MainWindow::createMenus()
507 qDebug() << __PRETTY_FUNCTION__;
510 m_loginAct = new QAction(tr("Login"), this);
511 connect(m_loginAct, SIGNAL(triggered()),
512 this, SIGNAL(loginActionPressed()));
515 m_toSettingsAct = new QAction(tr("Settings"), this);
516 connect(m_toSettingsAct, SIGNAL(triggered()),
517 this, SLOT(openSettingsDialog()));
520 m_gpsToggleAct = new QAction(tr("GPS"), this);
521 m_gpsToggleAct->setCheckable(true);
523 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
524 this, SIGNAL(gpsTriggered(bool)));
526 // build the actual menu
527 m_viewMenu = menuBar()->addMenu(tr("Main"));
528 m_viewMenu->addAction(m_loginAct);
529 m_viewMenu->addAction(m_toSettingsAct);
530 m_viewMenu->addAction(m_gpsToggleAct);
531 m_viewMenu->setObjectName(tr("Menu"));
534 void MainWindow::destroyLoginDialog()
536 qWarning() << __PRETTY_FUNCTION__;
539 m_loginDialog->hide();
540 m_loginDialog->deleteLater();
545 void MainWindow::dialogFinished(int status)
547 qDebug() << __PRETTY_FUNCTION__;
549 QDialog *dialog = m_queue.takeFirst();
550 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
551 if ((searchDialog) && (status != 0))
552 emit searchForLocation(searchDialog->input());
554 dialog->deleteLater();
556 if(!m_error_queue.isEmpty() && m_errorShown == false) {
557 showErrorInformationBox();
559 if(!m_queue.isEmpty()) {
560 showInformationBox();
565 void MainWindow::drawFullScreenButton(const QSize &size)
567 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
569 if (m_fullScreenButton) {
570 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
571 size.height() - m_fullScreenButton->size().height());
575 void MainWindow::drawMapScale(const QSize &size)
577 qDebug() << __PRETTY_FUNCTION__;
579 const int LEFT_SCALE_MARGIN = 10;
580 const int BOTTOM_SCALE_MARGIN = 2;
582 m_mapScale->move(LEFT_SCALE_MARGIN,
583 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
586 void MainWindow::drawOsmLicense(const QSize &size)
588 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
590 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
592 size.height() - m_osmLicense->fontMetrics().height());
595 void MainWindow::errorDialogFinished(int status)
597 qDebug() << __PRETTY_FUNCTION__;
600 QDialog *dialog = m_error_queue.takeFirst();
602 dialog->deleteLater();
603 m_errorShown = false;
605 if(!m_error_queue.isEmpty())
606 showErrorInformationBox();
607 else if(!m_queue.isEmpty())
608 showInformationBox();
611 void MainWindow::gpsTimeout()
613 qDebug() << __PRETTY_FUNCTION__;
615 buildInformationBox(tr("GPS timeout"));
618 void MainWindow::grabZoomKeys(bool grab)
620 qDebug() << __PRETTY_FUNCTION__;
623 // Can't grab keys unless we have a window id
627 unsigned long val = (grab) ? 1 : 0;
628 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
632 XChangeProperty (QX11Info::display(),
638 reinterpret_cast<unsigned char *>(&val),
642 #endif // Q_WS_MAEMO_5
645 void MainWindow::keyPressEvent(QKeyEvent* event)
647 qDebug() << __PRETTY_FUNCTION__;
649 switch (event->key()) {
660 QWidget::keyPressEvent(event);
663 void MainWindow::loggedIn(bool logged)
666 qDebug() << __PRETTY_FUNCTION__;
671 m_loginAct->setText(tr("Logout"));
677 m_loginAct->setText(tr("Login"));
678 m_userInfoPanel->showUserInfo(false);
680 updateItemVisibility();
683 void MainWindow::loginFailed()
686 qDebug() << __PRETTY_FUNCTION__;
692 bool MainWindow::loginState()
694 qDebug() << __PRETTY_FUNCTION__;
699 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
701 m_mapCenterHorizontalShifting = shifting;
705 void MainWindow::moveCrosshair()
707 qDebug() << __PRETTY_FUNCTION__;
710 int mapHeight = m_mapView->size().height();
711 int mapWidth = m_mapView->size().width();
712 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
713 - m_mapCenterHorizontalShifting,
714 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
718 void MainWindow::openSettingsDialog()
720 qDebug() << __PRETTY_FUNCTION__;
722 SettingsDialog *settingsDialog = new SettingsDialog(this);
723 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
724 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
726 settingsDialog->show();
729 void MainWindow::queueDialog(QDialog *dialog)
731 qDebug() << __PRETTY_FUNCTION__;
733 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
734 if(dialog->isModal()) {
735 m_error_queue.append(dialog);
737 m_queue.append(dialog);
740 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
741 if(m_error_queue.count() == 1 && m_errorShown == false)
742 showErrorInformationBox();
743 else if(m_queue.count() == 1 && m_errorShown == false)
744 showInformationBox();
747 void MainWindow::readAutomaticLocationUpdateSettings()
749 qDebug() << __PRETTY_FUNCTION__;
751 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
752 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
753 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
756 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
758 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
760 emit enableAutomaticLocationUpdate(false);
764 void MainWindow::setCrosshairVisibility(bool visibility)
766 qDebug() << __PRETTY_FUNCTION__;
776 void MainWindow::setGPSButtonEnabled(bool enabled)
778 qDebug() << __PRETTY_FUNCTION__;
780 m_gpsToggleAct->setChecked(enabled);
783 void MainWindow::setIndicatorButtonEnabled(bool enabled)
785 qDebug() << __PRETTY_FUNCTION__;
787 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
790 void MainWindow::setMapViewScene(QGraphicsScene *scene)
792 qDebug() << __PRETTY_FUNCTION__;
794 m_mapView->setScene(scene);
797 void MainWindow::settingsDialogAccepted()
799 qDebug() << __PRETTY_FUNCTION__;
801 readAutomaticLocationUpdateSettings();
804 void MainWindow::showContactDialog(const QString &guid)
806 qDebug() << __PRETTY_FUNCTION__;
808 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
809 OssoABookDialog::showContactDialog(guid);
812 buildInformationBox(tr("Contact dialog works only on phone!"), true);
816 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
818 qDebug() << __PRETTY_FUNCTION__;
820 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
821 tr("Automatic location update"), text,
822 QMessageBox::Yes | QMessageBox::No |
823 QMessageBox::Cancel, this);
824 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
825 this, SLOT(automaticUpdateDialogFinished(int)));
827 m_automaticUpdateLocationDialog->show();
830 void MainWindow::showErrorInformationBox()
832 qDebug() << __PRETTY_FUNCTION__;
834 if(m_error_queue.count()) {
836 QDialog *dialog = m_error_queue.first();
837 connect(dialog, SIGNAL(finished(int)),
838 this, SLOT(errorDialogFinished(int)));
843 void MainWindow::showInformationBox()
845 qDebug() << __PRETTY_FUNCTION__;
847 if(m_queue.count()) {
848 QDialog *dialog = m_queue.first();
849 connect(dialog, SIGNAL(finished(int)),
850 this, SLOT(dialogFinished(int)));
855 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
857 qWarning() << __PRETTY_FUNCTION__;
859 reply->ignoreSslErrors();
862 void MainWindow::startLocationSearch()
864 qDebug() << __PRETTY_FUNCTION__;
866 SearchDialog *searchDialog = new SearchDialog();
867 queueDialog(searchDialog);
870 void MainWindow::startLoginProcess()
872 qDebug() << __PRETTY_FUNCTION__;
874 LoginDialog *loginDialog = new LoginDialog();
876 emit fetchUsernameFromSettings();
878 loginDialog->clearTextFields();
880 if(!m_email.isEmpty())
881 loginDialog->setEmailField(m_email);
883 queueDialog(loginDialog);
886 void MainWindow::toggleFullScreen()
888 qDebug() << __PRETTY_FUNCTION__;
890 if(windowState() == Qt::WindowNoState)
896 void MainWindow::toggleProgressIndicator(bool value)
898 qDebug() << __PRETTY_FUNCTION__;
902 m_progressIndicatorCount++;
903 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
905 if(m_progressIndicatorCount > 0)
906 m_progressIndicatorCount--;
908 if(m_progressIndicatorCount == 0)
909 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
913 #endif // Q_WS_MAEMO_5
916 void MainWindow::updateItemVisibility()
918 qDebug() << __PRETTY_FUNCTION__;
920 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn);
923 const QString MainWindow::username()
925 qDebug() << __PRETTY_FUNCTION__;