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 "updatelocation/updatelocationdialog.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_fullScreenButton(0),
78 m_indicatorButtonPanel(0),
82 qDebug() << __PRETTY_FUNCTION__;
86 // map view is the only widget which size & location is handled automatically by the system
87 // default functionality
88 setCentralWidget(m_mapView);
93 setWindowTitle(tr("Situare"));
95 // set stacking order of widgets (from top to bottom)
96 // m_tabbedPanel is the topmost one
97 if (m_fullScreenButton) {
98 m_fullScreenButton->stackUnder(m_tabbedPanel);
99 m_crosshair->stackUnder(m_fullScreenButton);
101 m_crosshair->stackUnder(m_tabbedPanel);
103 m_zoomButtonPanel->stackUnder(m_crosshair);
104 m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
105 m_osmLicense->stackUnder(m_indicatorButtonPanel);
106 m_mapScale->stackUnder(m_osmLicense);
107 m_mapView->stackUnder(m_mapScale);
111 // Set default screen size
112 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
114 setAttribute(Qt::WA_Maemo5StackedWindow);
118 MainWindow::~MainWindow()
120 qDebug() << __PRETTY_FUNCTION__;
124 qDeleteAll(m_queue.begin(), m_queue.end());
127 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
128 m_error_queue.clear();
130 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
132 if (!m_backupMessage.isEmpty()) {
133 settings.setValue(USER_UNSEND_MESSAGE, m_backupMessage.toAscii());
134 settings.setValue(USER_UNSEND_MESSAGE_PUBLISH, m_backupFacebookPublishPolicity);
136 settings.remove(USER_UNSEND_MESSAGE);
137 settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
141 void MainWindow::automaticUpdateDialogFinished(int result)
143 qDebug() << __PRETTY_FUNCTION__;
145 if (result == QMessageBox::Yes) {
146 readAutomaticLocationUpdateSettings();
148 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
149 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
150 readAutomaticLocationUpdateSettings();
153 m_automaticUpdateLocationDialog->deleteLater();
156 void MainWindow::backupUpdateLocationDialogData(const QString &status, bool publish)
158 qDebug() << __PRETTY_FUNCTION__;
160 m_backupMessage = status;
161 m_backupFacebookPublishPolicity = publish;
164 void MainWindow::buildCrosshair()
166 qDebug() << __PRETTY_FUNCTION__;
168 m_crosshair = new QLabel(this);
169 QPixmap crosshairImage(":/res/images/sight.png");
170 m_crosshair->setPixmap(crosshairImage);
171 m_crosshair->setFixedSize(crosshairImage.size());
173 m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
175 connect(m_mapView, SIGNAL(viewResized(QSize)),
176 this, SLOT(moveCrosshair()));
178 connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
179 this, SLOT(mapCenterHorizontalShiftingChanged(int)));
182 void MainWindow::buildFriendListPanel()
184 qDebug() << __PRETTY_FUNCTION__;
186 m_friendsListPanel = new FriendListPanel(this);
188 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
189 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
191 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
192 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
194 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
195 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
197 connect(this, SIGNAL(friendImageReady(User*)),
198 m_friendsListPanel, SLOT(friendImageReady(User*)));
200 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
201 this, SIGNAL(routeTo(const GeoCoordinate&)));
203 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
204 this, SIGNAL(requestContactDialog(const QString &)));
207 void MainWindow::buildFullScreenButton()
209 qDebug() << __PRETTY_FUNCTION__;
212 m_fullScreenButton = new FullScreenButton(this);
214 if (m_fullScreenButton) {
215 connect(m_fullScreenButton, SIGNAL(clicked()),
216 this, SLOT(toggleFullScreen()));
218 connect(qApp, SIGNAL(showFullScreenButton()),
219 m_fullScreenButton, SLOT(invoke()));
221 #endif // Q_WS_MAEMO_5
224 void MainWindow::buildIndicatorButtonPanel()
226 qDebug() << __PRETTY_FUNCTION__;
228 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
230 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
231 this, SIGNAL(autoCenteringTriggered(bool)));
233 connect(m_mapView, SIGNAL(viewResized(QSize)),
234 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
236 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
237 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
239 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
240 this, SIGNAL(draggingModeTriggered()));
243 void MainWindow::buildInformationBox(const QString &message, bool modal)
245 qDebug() << __PRETTY_FUNCTION__;
247 QString errorMessage = message;
251 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
254 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
255 // extra line changes are needed to make error notes broader
256 errorMessage.prepend("\n");
257 errorMessage.append("\n");
259 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
261 QLabel *label = new QLabel(msgBox);
262 label->setAlignment(Qt::AlignCenter);
263 label->setText(errorMessage);
264 msgBox->setWidget(label);
266 QMessageBox *msgBox = new QMessageBox(this);
267 msgBox->button(QMessageBox::Ok);
268 msgBox->setText(errorMessage);
269 msgBox->setModal(modal);
275 void MainWindow::buildLocationSearchPanel()
277 qDebug() << __PRETTY_FUNCTION__;
279 m_locationSearchPanel = new LocationSearchPanel(this);
281 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
282 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
284 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
285 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
287 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
288 this, SIGNAL(routeTo(const GeoCoordinate&)));
290 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
291 this, SLOT(startLocationSearch()));
293 connect(this, SIGNAL(searchForLocation(QString)),
294 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
296 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
297 this, SIGNAL(searchHistoryItemClicked(QString)));
300 void MainWindow::buildLoginDialog(QWebView *browser)
302 qWarning() << __PRETTY_FUNCTION__;
304 if (!m_loginDialog) {
305 m_loginDialog = new QDialog(this);
307 m_loginDialog->setWindowTitle(tr("Login"));
308 m_loginDialog->setLayout(new QVBoxLayout());
309 m_loginDialog->layout()->addWidget(browser);
310 m_loginDialog->layout()->setContentsMargins(QMargins()); // zero margins
311 connect(m_loginDialog, SIGNAL(rejected()), this, SLOT(destroyLoginDialog()));
316 m_loginDialog->show();
319 void MainWindow::buildMap()
321 qDebug() << __PRETTY_FUNCTION__;
323 m_mapView = new MapView(this);
325 buildZoomButtonPanel();
328 buildFullScreenButton();
329 buildIndicatorButtonPanel();
332 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
333 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
335 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
336 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
338 connect(m_mapView, SIGNAL(viewResized(QSize)),
339 this, SIGNAL(mapViewResized(QSize)));
341 connect(m_mapView, SIGNAL(viewResized(QSize)),
342 this, SLOT(drawFullScreenButton(QSize)));
344 connect(m_mapView, SIGNAL(viewResized(QSize)),
345 this, SLOT(drawMapScale(QSize)));
347 connect(m_mapView, SIGNAL(viewResized(QSize)),
348 this, SLOT(moveCrosshair()));
350 connect(this, SIGNAL(zoomLevelChanged(int)),
351 m_mapView, SLOT(setZoomLevel(int)));
353 connect(m_mapView, SIGNAL(viewZoomFinished()),
354 this, SIGNAL(viewZoomFinished()));
356 connect(m_mapView, SIGNAL(zoomIn()),
357 this, SIGNAL(zoomIn()));
360 void MainWindow::buildMapScale()
362 m_mapScale = new MapScale(this);
363 connect(this, SIGNAL(newMapResolution(qreal)),
364 m_mapScale, SLOT(updateMapResolution(qreal)));
367 void MainWindow::buildOsmLicense()
369 qDebug() << __PRETTY_FUNCTION__;
371 m_osmLicense = new QLabel(this);
372 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
373 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
374 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
375 m_osmLicense->setFont(QFont("Nokia Sans", 9));
376 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
377 m_osmLicense->fontMetrics().height());
379 connect(m_mapView, SIGNAL(viewResized(QSize)),
380 this, SLOT(drawOsmLicense(QSize)));
383 void MainWindow::buildPanels()
385 qDebug() << __PRETTY_FUNCTION__;
387 buildUserInfoPanel();
388 buildFriendListPanel();
389 buildLocationSearchPanel();
392 m_tabbedPanel = new TabbedPanel(this);
394 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
395 m_situareTabsIndexes.append(
396 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
397 m_situareTabsIndexes.append(
398 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
400 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
401 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
403 connect(m_mapView, SIGNAL(viewResized(QSize)),
404 m_tabbedPanel, SLOT(resizePanel(QSize)));
406 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
407 m_tabbedPanel, SLOT(openPanel(QWidget*)));
409 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
410 m_tabbedPanel, SLOT(openPanel(QWidget*)));
412 connect(m_tabbedPanel, SIGNAL(panelClosed()),
413 m_friendsListPanel, SLOT(anyPanelClosed()));
415 connect(m_tabbedPanel, SIGNAL(panelOpened()),
416 m_friendsListPanel, SLOT(anyPanelOpened()));
418 connect(m_tabbedPanel, SIGNAL(panelClosed()),
419 m_routingPanel, SLOT(clearListsSelections()));
421 connect(m_tabbedPanel, SIGNAL(panelClosed()),
422 m_mapView, SLOT(disableCenterShift()));
424 connect(m_tabbedPanel, SIGNAL(panelOpened()),
425 m_mapView, SLOT(enableCenterShift()));
427 connect(m_tabbedPanel, SIGNAL(panelClosed()),
428 m_userInfoPanel, SIGNAL(collapse()));
430 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
431 m_userInfoPanel, SIGNAL(collapse()));
433 // signals for showing and hiding list item context buttons
434 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
435 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
437 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
438 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
440 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
441 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
444 void MainWindow::buildRoutingPanel()
446 qDebug() << __PRETTY_FUNCTION__;
448 m_routingPanel = new RoutingPanel(this);
450 connect(m_routingPanel, SIGNAL(routeToCursor()),
451 this, SIGNAL(routeToCursor()));
453 connect(this, SIGNAL(routeParsed(Route&)),
454 m_routingPanel, SLOT(setRoute(Route&)));
456 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
457 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
459 connect(m_routingPanel, SIGNAL(clearRoute()),
460 this, SIGNAL(clearRoute()));
463 void MainWindow::buildUserInfoPanel()
465 qDebug() << __PRETTY_FUNCTION__;
467 m_userInfoPanel = new UserInfoPanel(this);
469 connect(this, SIGNAL(userLocationReady(User*)),
470 m_userInfoPanel, SLOT(userDataReceived(User*)));
472 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
473 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
475 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
476 this, SIGNAL(refreshUserData()));
478 connect(m_userInfoPanel, SIGNAL(updateLocationMessageButtonClicked()),
479 this, SLOT(showUpdateLocationDialog()));
482 void MainWindow::buildZoomButtonPanel()
484 qDebug() << __PRETTY_FUNCTION__;
486 m_zoomButtonPanel = new ZoomButtonPanel(this);
488 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
489 this, SIGNAL(zoomIn()));
491 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
492 this, SIGNAL(zoomOut()));
494 connect(this, SIGNAL(zoomLevelChanged(int)),
495 m_zoomButtonPanel, SLOT(resetButtons()));
497 connect(this, SIGNAL(maxZoomLevelReached()),
498 m_zoomButtonPanel, SLOT(disableZoomInButton()));
500 connect(this, SIGNAL(minZoomLevelReached()),
501 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
503 connect(m_mapView, SIGNAL(viewResized(QSize)),
504 m_zoomButtonPanel, SLOT(screenResized(QSize)));
506 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
507 this, SIGNAL(draggingModeTriggered()));
510 void MainWindow::clearUpdateLocationDialogData()
512 qDebug() << __PRETTY_FUNCTION__;
514 m_backupMessage.clear();
515 m_backupFacebookPublishPolicity = false;
518 void MainWindow::createMenus()
520 qDebug() << __PRETTY_FUNCTION__;
523 m_loginAct = new QAction(tr("Login"), this);
524 connect(m_loginAct, SIGNAL(triggered()),
525 this, SIGNAL(loginActionPressed()));
528 m_toSettingsAct = new QAction(tr("Settings"), this);
529 connect(m_toSettingsAct, SIGNAL(triggered()),
530 this, SLOT(openSettingsDialog()));
533 m_gpsToggleAct = new QAction(tr("GPS"), this);
534 m_gpsToggleAct->setCheckable(true);
536 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
537 this, SIGNAL(gpsTriggered(bool)));
539 // build the actual menu
540 m_viewMenu = menuBar()->addMenu(tr("Main"));
541 m_viewMenu->addAction(m_loginAct);
542 m_viewMenu->addAction(m_toSettingsAct);
543 m_viewMenu->addAction(m_gpsToggleAct);
544 m_viewMenu->setObjectName(tr("Menu"));
547 void MainWindow::destroyLoginDialog()
549 qWarning() << __PRETTY_FUNCTION__;
552 m_loginDialog->hide();
553 m_loginDialog->deleteLater();
558 void MainWindow::dialogFinished(int status)
560 qDebug() << __PRETTY_FUNCTION__;
562 QDialog *dialog = m_queue.takeFirst();
563 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
564 if ((searchDialog) && (status != 0))
565 emit searchForLocation(searchDialog->input());
567 dialog->deleteLater();
569 if(!m_error_queue.isEmpty() && m_errorShown == false) {
570 showErrorInformationBox();
572 if(!m_queue.isEmpty()) {
573 showInformationBox();
578 void MainWindow::drawFullScreenButton(const QSize &size)
580 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
582 if (m_fullScreenButton) {
583 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
584 size.height() - m_fullScreenButton->size().height());
588 void MainWindow::drawMapScale(const QSize &size)
590 qDebug() << __PRETTY_FUNCTION__;
592 const int LEFT_SCALE_MARGIN = 10;
593 const int BOTTOM_SCALE_MARGIN = 2;
595 m_mapScale->move(LEFT_SCALE_MARGIN,
596 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
599 void MainWindow::drawOsmLicense(const QSize &size)
601 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
603 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
605 size.height() - m_osmLicense->fontMetrics().height());
608 void MainWindow::errorDialogFinished(int status)
610 qDebug() << __PRETTY_FUNCTION__;
613 QDialog *dialog = m_error_queue.takeFirst();
615 dialog->deleteLater();
616 m_errorShown = false;
618 if(!m_error_queue.isEmpty())
619 showErrorInformationBox();
620 else if(!m_queue.isEmpty())
621 showInformationBox();
624 void MainWindow::gpsTimeout()
626 qDebug() << __PRETTY_FUNCTION__;
628 buildInformationBox(tr("GPS timeout"));
631 void MainWindow::grabZoomKeys(bool grab)
633 qDebug() << __PRETTY_FUNCTION__;
636 // Can't grab keys unless we have a window id
640 unsigned long val = (grab) ? 1 : 0;
641 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
645 XChangeProperty (QX11Info::display(),
651 reinterpret_cast<unsigned char *>(&val),
655 #endif // Q_WS_MAEMO_5
658 void MainWindow::keyPressEvent(QKeyEvent* event)
660 qDebug() << __PRETTY_FUNCTION__;
662 switch (event->key()) {
673 QWidget::keyPressEvent(event);
676 void MainWindow::loggedIn(bool logged)
678 qDebug() << __PRETTY_FUNCTION__;
683 m_loginAct->setText(tr("Logout"));
685 m_loginAct->setText(tr("Login"));
686 m_userInfoPanel->showUserInfo(false);
688 updateItemVisibility(logged);
691 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
693 m_mapCenterHorizontalShifting = shifting;
697 void MainWindow::moveCrosshair()
699 qDebug() << __PRETTY_FUNCTION__;
702 int mapHeight = m_mapView->size().height();
703 int mapWidth = m_mapView->size().width();
704 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
705 - m_mapCenterHorizontalShifting,
706 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
710 void MainWindow::openSettingsDialog()
712 qDebug() << __PRETTY_FUNCTION__;
714 SettingsDialog *settingsDialog = new SettingsDialog(this);
715 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
716 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
718 settingsDialog->show();
721 void MainWindow::queueDialog(QDialog *dialog)
723 qDebug() << __PRETTY_FUNCTION__;
725 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
726 if(dialog->isModal()) {
727 m_error_queue.append(dialog);
729 m_queue.append(dialog);
732 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
733 if(m_error_queue.count() == 1 && m_errorShown == false)
734 showErrorInformationBox();
735 else if(m_queue.count() == 1 && m_errorShown == false)
736 showInformationBox();
739 void MainWindow::readAutomaticLocationUpdateSettings()
741 qDebug() << __PRETTY_FUNCTION__;
743 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
744 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
745 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
748 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
750 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
752 emit enableAutomaticLocationUpdate(false);
756 void MainWindow::restoreUnsendMessage()
758 qDebug() << __PRETTY_FUNCTION__;
760 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
761 m_backupMessage = settings.value(USER_UNSEND_MESSAGE).toString();
762 m_backupFacebookPublishPolicity = settings.value(USER_UNSEND_MESSAGE_PUBLISH, false).toBool();
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::showUpdateLocationDialog()
858 qDebug() << __PRETTY_FUNCTION__;
860 delete m_updateLocation;
861 m_updateLocation = new UpdateLocationDialog(m_backupMessage, m_backupFacebookPublishPolicity,
864 connect(this, SIGNAL(reverseGeoReady(QString)),
865 m_updateLocation, SLOT(setAddress(QString)));
867 connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
868 this, SIGNAL(statusUpdate(QString, bool)));
870 connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
871 this, SLOT(backupUpdateLocationDialogData(QString, bool)));
873 connect(m_updateLocation, SIGNAL(finished(int)),
874 this, SLOT(updateLocationDialogFinished(int)));
876 m_updateLocation->show();
878 emit requestReverseGeo();
881 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
883 qWarning() << __PRETTY_FUNCTION__;
885 reply->ignoreSslErrors();
888 void MainWindow::startLocationSearch()
890 qDebug() << __PRETTY_FUNCTION__;
892 SearchDialog *searchDialog = new SearchDialog();
893 queueDialog(searchDialog);
896 void MainWindow::toggleFullScreen()
898 qDebug() << __PRETTY_FUNCTION__;
900 if(windowState() == Qt::WindowNoState)
906 void MainWindow::toggleProgressIndicator(bool value)
908 qDebug() << __PRETTY_FUNCTION__;
912 m_progressIndicatorCount++;
913 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
915 if(m_progressIndicatorCount > 0)
916 m_progressIndicatorCount--;
918 if(m_progressIndicatorCount == 0)
919 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
923 #endif // Q_WS_MAEMO_5
926 void MainWindow::updateItemVisibility(bool loggedIn)
928 qDebug() << __PRETTY_FUNCTION__;
930 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn);
933 void MainWindow::updateLocationDialogFinished(int reason)
935 qDebug() << __PRETTY_FUNCTION__;
939 if (m_updateLocation) {
940 disconnect(this, SIGNAL(reverseGeoReady(QString)),
941 m_updateLocation, SLOT(setAddress(QString)));
943 disconnect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
944 this, SIGNAL(statusUpdate(QString,bool)));
946 disconnect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
947 this, SLOT(backupUpdateLocationDialogData(QString,bool)));
949 disconnect(m_updateLocation, SIGNAL(finished(int)),
950 this, SLOT(updateLocationDialogFinished(int)));
952 m_updateLocation->deleteLater();
953 m_updateLocation = 0;