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 "facebookservice/facebookauthentication.h"
39 #include "friendlistpanel.h"
40 #include "fullscreenbutton.h"
41 #include "indicatorbuttonpanel.h"
42 #include "locationsearchpanel.h"
43 #include "logindialog.h"
44 #include "map/mapcommon.h"
45 #include "map/mapview.h"
47 #include "panelcommon.h"
48 #include "routingpanel.h"
49 #include "searchdialog.h"
50 #include "settingsdialog.h"
51 #include "situareservice/situarecommon.h"
52 #include "tabbedpanel.h"
53 #include "userinfopanel.h"
54 #include "zoombuttonpanel.h"
56 #include "mainwindow.h"
58 // These MUST BE HERE, compiling for Maemo fails if moved
60 #include <QtMaemo5/QMaemo5InformationBox>
61 #include <QtGui/QX11Info>
62 #include <X11/Xatom.h>
64 #endif // Q_WS_MAEMO_5
66 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
67 #include "ossoabookdialog.h"
70 MainWindow::MainWindow(QWidget *parent)
71 : QMainWindow(parent),
75 m_mapCenterHorizontalShifting(0),
76 m_progressIndicatorCount(0),
78 m_email(), ///< @todo WTF?!?!?!?
80 m_facebookLoginBrowser(0),
81 m_fullScreenButton(0),
82 m_indicatorButtonPanel(0),
85 qDebug() << __PRETTY_FUNCTION__;
89 // map view is the only widget which size & location is handled automatically by the system
90 // default functionality
91 setCentralWidget(m_mapView);
96 setWindowTitle(tr("Situare"));
98 // set stacking order of widgets (from top to bottom)
99 // m_tabbedPanel is the topmost one
100 if (m_fullScreenButton) {
101 m_fullScreenButton->stackUnder(m_tabbedPanel);
102 m_crosshair->stackUnder(m_fullScreenButton);
104 m_crosshair->stackUnder(m_tabbedPanel);
106 m_zoomButtonPanel->stackUnder(m_crosshair);
107 m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
108 m_osmLicense->stackUnder(m_indicatorButtonPanel);
109 m_mapScale->stackUnder(m_osmLicense);
110 m_mapView->stackUnder(m_mapScale);
114 // Set default screen size
115 resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
117 setAttribute(Qt::WA_Maemo5StackedWindow);
121 MainWindow::~MainWindow()
123 qDebug() << __PRETTY_FUNCTION__;
127 qDeleteAll(m_queue.begin(), m_queue.end());
130 qDeleteAll(m_error_queue.begin(), m_error_queue.end());
131 m_error_queue.clear();
134 void MainWindow::automaticUpdateDialogFinished(int result)
136 qDebug() << __PRETTY_FUNCTION__;
138 if (result == QMessageBox::Yes) {
139 readAutomaticLocationUpdateSettings();
141 QSettings settings(DIRECTORY_NAME, FILE_NAME);
142 settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
143 readAutomaticLocationUpdateSettings();
146 m_automaticUpdateLocationDialog->deleteLater();
149 void MainWindow::buildCrosshair()
151 qDebug() << __PRETTY_FUNCTION__;
153 m_crosshair = new QLabel(this);
154 QPixmap crosshairImage(":/res/images/sight.png");
155 m_crosshair->setPixmap(crosshairImage);
156 m_crosshair->setFixedSize(crosshairImage.size());
158 m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
160 connect(m_mapView, SIGNAL(viewResized(QSize)),
161 this, SLOT(moveCrosshair()));
163 connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
164 this, SLOT(mapCenterHorizontalShiftingChanged(int)));
167 void MainWindow::buildFacebookLoginBrowser()
169 qWarning() << __PRETTY_FUNCTION__;
171 if (!m_facebookLoginBrowser)
172 m_facebookLoginBrowser = new FacebookLoginBrowser(this);
174 m_facebookLoginBrowser->show();
176 emit loginBrowserCreated(m_facebookLoginBrowser);
179 void MainWindow::buildFriendListPanel()
181 qDebug() << __PRETTY_FUNCTION__;
183 m_friendsListPanel = new FriendListPanel(this);
185 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
186 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
188 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
189 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
191 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
192 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
194 connect(this, SIGNAL(friendImageReady(User*)),
195 m_friendsListPanel, SLOT(friendImageReady(User*)));
197 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
198 this, SIGNAL(routeTo(const GeoCoordinate&)));
200 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
201 this, SIGNAL(requestContactDialog(const QString &)));
204 void MainWindow::buildFullScreenButton()
206 qDebug() << __PRETTY_FUNCTION__;
209 m_fullScreenButton = new FullScreenButton(this);
211 if (m_fullScreenButton) {
212 connect(m_fullScreenButton, SIGNAL(clicked()),
213 this, SLOT(toggleFullScreen()));
215 connect(qApp, SIGNAL(showFullScreenButton()),
216 m_fullScreenButton, SLOT(invoke()));
218 #endif // Q_WS_MAEMO_5
221 void MainWindow::buildIndicatorButtonPanel()
223 qDebug() << __PRETTY_FUNCTION__;
225 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
227 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
228 this, SIGNAL(autoCenteringTriggered(bool)));
230 connect(m_mapView, SIGNAL(viewResized(QSize)),
231 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
233 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
234 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
236 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
237 this, SIGNAL(draggingModeTriggered()));
240 void MainWindow::buildInformationBox(const QString &message, bool modal)
242 qDebug() << __PRETTY_FUNCTION__;
244 QString errorMessage = message;
248 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
251 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
252 // extra line changes are needed to make error notes broader
253 errorMessage.prepend("\n");
254 errorMessage.append("\n");
256 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
258 QLabel *label = new QLabel(msgBox);
259 label->setAlignment(Qt::AlignCenter);
260 label->setText(errorMessage);
261 msgBox->setWidget(label);
263 QMessageBox *msgBox = new QMessageBox(this);
264 msgBox->button(QMessageBox::Ok);
265 msgBox->setText(errorMessage);
266 msgBox->setModal(modal);
272 void MainWindow::buildLocationSearchPanel()
274 qDebug() << __PRETTY_FUNCTION__;
276 m_locationSearchPanel = new LocationSearchPanel(this);
278 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
279 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
281 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
282 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
284 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
285 this, SIGNAL(routeTo(const GeoCoordinate&)));
287 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
288 this, SLOT(startLocationSearch()));
290 connect(this, SIGNAL(searchForLocation(QString)),
291 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
293 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
294 this, SIGNAL(searchHistoryItemClicked(QString)));
297 void MainWindow::buildMap()
299 qDebug() << __PRETTY_FUNCTION__;
301 m_mapView = new MapView(this);
303 buildZoomButtonPanel();
306 buildFullScreenButton();
307 buildIndicatorButtonPanel();
310 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
311 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
313 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
314 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
316 connect(m_mapView, SIGNAL(viewResized(QSize)),
317 this, SIGNAL(mapViewResized(QSize)));
319 connect(m_mapView, SIGNAL(viewResized(QSize)),
320 this, SLOT(drawFullScreenButton(QSize)));
322 connect(m_mapView, SIGNAL(viewResized(QSize)),
323 this, SLOT(drawMapScale(QSize)));
325 connect(m_mapView, SIGNAL(viewResized(QSize)),
326 this, SLOT(moveCrosshair()));
328 connect(this, SIGNAL(zoomLevelChanged(int)),
329 m_mapView, SLOT(setZoomLevel(int)));
331 connect(m_mapView, SIGNAL(viewZoomFinished()),
332 this, SIGNAL(viewZoomFinished()));
334 connect(m_mapView, SIGNAL(zoomIn()),
335 this, SIGNAL(zoomIn()));
338 void MainWindow::buildMapScale()
340 m_mapScale = new MapScale(this);
341 connect(this, SIGNAL(newMapResolution(qreal)),
342 m_mapScale, SLOT(updateMapResolution(qreal)));
345 void MainWindow::buildOsmLicense()
347 qDebug() << __PRETTY_FUNCTION__;
349 m_osmLicense = new QLabel(this);
350 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
351 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
352 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
353 m_osmLicense->setFont(QFont("Nokia Sans", 9));
354 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
355 m_osmLicense->fontMetrics().height());
357 connect(m_mapView, SIGNAL(viewResized(QSize)),
358 this, SLOT(drawOsmLicense(QSize)));
361 void MainWindow::buildPanels()
363 qDebug() << __PRETTY_FUNCTION__;
365 buildUserInfoPanel();
366 buildFriendListPanel();
367 buildLocationSearchPanel();
370 m_tabbedPanel = new TabbedPanel(this);
372 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
373 m_situareTabsIndexes.append(
374 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
375 m_situareTabsIndexes.append(
376 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
378 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
379 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
381 connect(m_mapView, SIGNAL(viewResized(QSize)),
382 m_tabbedPanel, SLOT(resizePanel(QSize)));
384 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
385 m_tabbedPanel, SLOT(openPanel(QWidget*)));
387 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
388 m_tabbedPanel, SLOT(openPanel(QWidget*)));
390 connect(m_tabbedPanel, SIGNAL(panelClosed()),
391 m_friendsListPanel, SLOT(anyPanelClosed()));
393 connect(m_tabbedPanel, SIGNAL(panelOpened()),
394 m_friendsListPanel, SLOT(anyPanelOpened()));
396 connect(m_tabbedPanel, SIGNAL(panelClosed()),
397 m_routingPanel, SLOT(clearListsSelections()));
399 connect(m_tabbedPanel, SIGNAL(panelClosed()),
400 m_mapView, SLOT(disableCenterShift()));
402 connect(m_tabbedPanel, SIGNAL(panelOpened()),
403 m_mapView, SLOT(enableCenterShift()));
405 connect(m_tabbedPanel, SIGNAL(panelClosed()),
406 m_userInfoPanel, SIGNAL(collapse()));
408 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
409 m_userInfoPanel, SIGNAL(collapse()));
411 // signals for showing and hiding list item context buttons
412 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
413 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
415 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
416 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
418 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
419 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
422 void MainWindow::buildRoutingPanel()
424 qDebug() << __PRETTY_FUNCTION__;
426 m_routingPanel = new RoutingPanel(this);
428 connect(m_routingPanel, SIGNAL(routeToCursor()),
429 this, SIGNAL(routeToCursor()));
431 connect(this, SIGNAL(routeParsed(Route&)),
432 m_routingPanel, SLOT(setRoute(Route&)));
434 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
435 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
437 connect(m_routingPanel, SIGNAL(clearRoute()),
438 this, SIGNAL(clearRoute()));
441 void MainWindow::buildUserInfoPanel()
443 qDebug() << __PRETTY_FUNCTION__;
445 m_userInfoPanel = new UserInfoPanel(this);
447 connect(this, SIGNAL(userLocationReady(User*)),
448 m_userInfoPanel, SLOT(userDataReceived(User*)));
450 connect(this, SIGNAL(reverseGeoReady(QString)),
451 m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
453 connect(this, SIGNAL(clearUpdateLocationDialogData()),
454 m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
456 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
457 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
459 connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
460 this, SIGNAL(requestReverseGeo()));
462 connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
463 this, SIGNAL(statusUpdate(QString,bool)));
465 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
466 this, SIGNAL(refreshUserData()));
468 connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
469 this, SLOT(buildInformationBox(QString, bool)));
472 void MainWindow::buildZoomButtonPanel()
474 qDebug() << __PRETTY_FUNCTION__;
476 m_zoomButtonPanel = new ZoomButtonPanel(this);
478 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
479 this, SIGNAL(zoomIn()));
481 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
482 this, SIGNAL(zoomOut()));
484 connect(this, SIGNAL(zoomLevelChanged(int)),
485 m_zoomButtonPanel, SLOT(resetButtons()));
487 connect(this, SIGNAL(maxZoomLevelReached()),
488 m_zoomButtonPanel, SLOT(disableZoomInButton()));
490 connect(this, SIGNAL(minZoomLevelReached()),
491 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
493 connect(m_mapView, SIGNAL(viewResized(QSize)),
494 m_zoomButtonPanel, SLOT(screenResized(QSize)));
496 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
497 this, SIGNAL(draggingModeTriggered()));
500 void MainWindow::createMenus()
502 qDebug() << __PRETTY_FUNCTION__;
505 m_loginAct = new QAction(tr("Login"), this);
506 connect(m_loginAct, SIGNAL(triggered()),
507 this, SIGNAL(loginActionPressed()));
510 m_toSettingsAct = new QAction(tr("Settings"), this);
511 connect(m_toSettingsAct, SIGNAL(triggered()),
512 this, SLOT(openSettingsDialog()));
515 m_gpsToggleAct = new QAction(tr("GPS"), this);
516 m_gpsToggleAct->setCheckable(true);
518 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
519 this, SIGNAL(gpsTriggered(bool)));
521 // build the actual menu
522 m_viewMenu = menuBar()->addMenu(tr("Main"));
523 m_viewMenu->addAction(m_loginAct);
524 m_viewMenu->addAction(m_toSettingsAct);
525 m_viewMenu->addAction(m_gpsToggleAct);
526 m_viewMenu->setObjectName(tr("Menu"));
529 void MainWindow::destroyFacebookLoginBrowser()
531 qWarning() << __PRETTY_FUNCTION__;
533 m_facebookLoginBrowser->hide();
534 m_facebookLoginBrowser->disconnect();
535 m_facebookLoginBrowser->deleteLater();
536 m_facebookLoginBrowser = 0;
539 void MainWindow::dialogFinished(int status)
541 qDebug() << __PRETTY_FUNCTION__;
543 QDialog *dialog = m_queue.takeFirst();
544 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
545 if ((searchDialog) && (status != 0))
546 emit searchForLocation(searchDialog->input());
548 dialog->deleteLater();
550 if(!m_error_queue.isEmpty() && m_errorShown == false) {
551 showErrorInformationBox();
553 if(!m_queue.isEmpty()) {
554 showInformationBox();
559 void MainWindow::drawFullScreenButton(const QSize &size)
561 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
563 if (m_fullScreenButton) {
564 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
565 size.height() - m_fullScreenButton->size().height());
569 void MainWindow::drawMapScale(const QSize &size)
571 qDebug() << __PRETTY_FUNCTION__;
573 const int LEFT_SCALE_MARGIN = 10;
574 const int BOTTOM_SCALE_MARGIN = 2;
576 m_mapScale->move(LEFT_SCALE_MARGIN,
577 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
580 void MainWindow::drawOsmLicense(const QSize &size)
582 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
584 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
586 size.height() - m_osmLicense->fontMetrics().height());
589 void MainWindow::errorDialogFinished(int status)
591 qDebug() << __PRETTY_FUNCTION__;
594 QDialog *dialog = m_error_queue.takeFirst();
596 dialog->deleteLater();
597 m_errorShown = false;
599 if(!m_error_queue.isEmpty())
600 showErrorInformationBox();
601 else if(!m_queue.isEmpty())
602 showInformationBox();
605 void MainWindow::gpsTimeout()
607 qDebug() << __PRETTY_FUNCTION__;
609 buildInformationBox(tr("GPS timeout"));
612 void MainWindow::grabZoomKeys(bool grab)
614 qDebug() << __PRETTY_FUNCTION__;
617 // Can't grab keys unless we have a window id
621 unsigned long val = (grab) ? 1 : 0;
622 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
626 XChangeProperty (QX11Info::display(),
632 reinterpret_cast<unsigned char *>(&val),
636 #endif // Q_WS_MAEMO_5
639 void MainWindow::keyPressEvent(QKeyEvent* event)
641 qDebug() << __PRETTY_FUNCTION__;
643 switch (event->key()) {
654 QWidget::keyPressEvent(event);
657 void MainWindow::loggedIn(bool logged)
660 qDebug() << __PRETTY_FUNCTION__;
665 m_loginAct->setText(tr("Logout"));
671 m_loginAct->setText(tr("Login"));
672 m_userInfoPanel->showUserInfo(false);
674 updateItemVisibility();
677 void MainWindow::loginFailed()
680 qDebug() << __PRETTY_FUNCTION__;
686 bool MainWindow::loginState()
688 qDebug() << __PRETTY_FUNCTION__;
693 void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
695 m_mapCenterHorizontalShifting = shifting;
699 void MainWindow::moveCrosshair()
701 qDebug() << __PRETTY_FUNCTION__;
704 int mapHeight = m_mapView->size().height();
705 int mapWidth = m_mapView->size().width();
706 m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2
707 - m_mapCenterHorizontalShifting,
708 mapHeight / 2 - m_crosshair->pixmap()->height() / 2);
712 void MainWindow::openSettingsDialog()
714 qDebug() << __PRETTY_FUNCTION__;
716 SettingsDialog *settingsDialog = new SettingsDialog(this);
717 settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
718 connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
720 settingsDialog->show();
723 void MainWindow::queueDialog(QDialog *dialog)
725 qDebug() << __PRETTY_FUNCTION__;
727 // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
728 if(dialog->isModal()) {
729 m_error_queue.append(dialog);
731 m_queue.append(dialog);
734 // show error dialog if there is only one error dialog in the queue and no error dialog is shown
735 if(m_error_queue.count() == 1 && m_errorShown == false)
736 showErrorInformationBox();
737 else if(m_queue.count() == 1 && m_errorShown == false)
738 showInformationBox();
741 void MainWindow::readAutomaticLocationUpdateSettings()
743 qDebug() << __PRETTY_FUNCTION__;
745 QSettings settings(DIRECTORY_NAME, FILE_NAME);
746 bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool();
747 QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime())
750 if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
752 emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
754 emit enableAutomaticLocationUpdate(false);
758 ///< @todo remove old, duplicate saveCookies()
759 void MainWindow::saveCookies()
761 qDebug() << __PRETTY_FUNCTION__;
764 // m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
766 // QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
769 // for(int i=0;i<cookieList.count();i++) {
770 // QNetworkCookie cookie = cookieList.at(i);
771 // QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
772 // list.append(QString(byteArray));
774 // list.removeDuplicates();
776 // QSettings settings(DIRECTORY_NAME, FILE_NAME);
777 // settings.setValue(COOKIES, list);
780 void MainWindow::setCrosshairVisibility(bool visibility)
782 qDebug() << __PRETTY_FUNCTION__;
792 void MainWindow::setGPSButtonEnabled(bool enabled)
794 qDebug() << __PRETTY_FUNCTION__;
796 m_gpsToggleAct->setChecked(enabled);
799 void MainWindow::setIndicatorButtonEnabled(bool enabled)
801 qDebug() << __PRETTY_FUNCTION__;
803 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
806 void MainWindow::setMapViewScene(QGraphicsScene *scene)
808 qDebug() << __PRETTY_FUNCTION__;
810 m_mapView->setScene(scene);
813 void MainWindow::settingsDialogAccepted()
815 qDebug() << __PRETTY_FUNCTION__;
817 readAutomaticLocationUpdateSettings();
820 void MainWindow::showContactDialog(const QString &guid)
822 qDebug() << __PRETTY_FUNCTION__;
824 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
825 OssoABookDialog::showContactDialog(guid);
828 buildInformationBox(tr("Contact dialog works only on phone!"), true);
832 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
834 qDebug() << __PRETTY_FUNCTION__;
836 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
837 tr("Automatic location update"), text,
838 QMessageBox::Yes | QMessageBox::No |
839 QMessageBox::Cancel, this);
840 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
841 this, SLOT(automaticUpdateDialogFinished(int)));
843 m_automaticUpdateLocationDialog->show();
846 void MainWindow::showErrorInformationBox()
848 qDebug() << __PRETTY_FUNCTION__;
850 if(m_error_queue.count()) {
852 QDialog *dialog = m_error_queue.first();
853 connect(dialog, SIGNAL(finished(int)),
854 this, SLOT(errorDialogFinished(int)));
859 void MainWindow::showInformationBox()
861 qDebug() << __PRETTY_FUNCTION__;
863 if(m_queue.count()) {
864 QDialog *dialog = m_queue.first();
865 connect(dialog, SIGNAL(finished(int)),
866 this, SLOT(dialogFinished(int)));
871 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
873 qWarning() << __PRETTY_FUNCTION__;
875 reply->ignoreSslErrors();
878 void MainWindow::startLocationSearch()
880 qDebug() << __PRETTY_FUNCTION__;
882 SearchDialog *searchDialog = new SearchDialog();
883 queueDialog(searchDialog);
886 void MainWindow::startLoginProcess()
888 qDebug() << __PRETTY_FUNCTION__;
890 LoginDialog *loginDialog = new LoginDialog();
892 emit fetchUsernameFromSettings();
894 loginDialog->clearTextFields();
896 if(!m_email.isEmpty())
897 loginDialog->setEmailField(m_email);
899 queueDialog(loginDialog);
902 void MainWindow::toggleFullScreen()
904 qDebug() << __PRETTY_FUNCTION__;
906 if(windowState() == Qt::WindowNoState)
912 void MainWindow::toggleProgressIndicator(bool value)
914 qDebug() << __PRETTY_FUNCTION__;
918 m_progressIndicatorCount++;
919 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
921 if(m_progressIndicatorCount > 0)
922 m_progressIndicatorCount--;
924 if(m_progressIndicatorCount == 0)
925 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
929 #endif // Q_WS_MAEMO_5
932 void MainWindow::updateItemVisibility()
934 qDebug() << __PRETTY_FUNCTION__;
936 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn);
939 const QString MainWindow::username()
941 qDebug() << __PRETTY_FUNCTION__;