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 emit loginBrowserCreated(m_facebookLoginBrowser);
177 void MainWindow::buildFriendListPanel()
179 qDebug() << __PRETTY_FUNCTION__;
181 m_friendsListPanel = new FriendListPanel(this);
183 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
184 m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
186 connect(this, SIGNAL(locationItemClicked(QList<QString>)),
187 m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
189 connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
190 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
192 connect(this, SIGNAL(friendImageReady(User*)),
193 m_friendsListPanel, SLOT(friendImageReady(User*)));
195 connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
196 this, SIGNAL(routeTo(const GeoCoordinate&)));
198 connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)),
199 this, SIGNAL(requestContactDialog(const QString &)));
202 void MainWindow::buildFullScreenButton()
204 qDebug() << __PRETTY_FUNCTION__;
207 m_fullScreenButton = new FullScreenButton(this);
209 if (m_fullScreenButton) {
210 connect(m_fullScreenButton, SIGNAL(clicked()),
211 this, SLOT(toggleFullScreen()));
213 connect(qApp, SIGNAL(showFullScreenButton()),
214 m_fullScreenButton, SLOT(invoke()));
216 #endif // Q_WS_MAEMO_5
219 void MainWindow::buildIndicatorButtonPanel()
221 qDebug() << __PRETTY_FUNCTION__;
223 m_indicatorButtonPanel = new IndicatorButtonPanel(this);
225 connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
226 this, SIGNAL(autoCenteringTriggered(bool)));
228 connect(m_mapView, SIGNAL(viewResized(QSize)),
229 m_indicatorButtonPanel, SLOT(screenResized(QSize)));
231 connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
232 m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
234 connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
235 this, SIGNAL(draggingModeTriggered()));
238 void MainWindow::buildInformationBox(const QString &message, bool modal)
240 qDebug() << __PRETTY_FUNCTION__;
242 QString errorMessage = message;
246 QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
249 msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
250 // extra line changes are needed to make error notes broader
251 errorMessage.prepend("\n");
252 errorMessage.append("\n");
254 msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
256 QLabel *label = new QLabel(msgBox);
257 label->setAlignment(Qt::AlignCenter);
258 label->setText(errorMessage);
259 msgBox->setWidget(label);
261 QMessageBox *msgBox = new QMessageBox(this);
262 msgBox->button(QMessageBox::Ok);
263 msgBox->setText(errorMessage);
264 msgBox->setModal(modal);
270 void MainWindow::buildLocationSearchPanel()
272 qDebug() << __PRETTY_FUNCTION__;
274 m_locationSearchPanel = new LocationSearchPanel(this);
276 connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
277 m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
279 connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
280 this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
282 connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
283 this, SIGNAL(routeTo(const GeoCoordinate&)));
285 connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
286 this, SLOT(startLocationSearch()));
288 connect(this, SIGNAL(searchForLocation(QString)),
289 m_locationSearchPanel, SLOT(prependSearchHistory(QString)));
291 connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)),
292 this, SIGNAL(searchHistoryItemClicked(QString)));
295 void MainWindow::buildMap()
297 qDebug() << __PRETTY_FUNCTION__;
299 m_mapView = new MapView(this);
301 buildZoomButtonPanel();
304 buildFullScreenButton();
305 buildIndicatorButtonPanel();
308 connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
309 this, SIGNAL(mapViewScrolled(SceneCoordinate)));
311 connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
312 m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
314 connect(m_mapView, SIGNAL(viewResized(QSize)),
315 this, SIGNAL(mapViewResized(QSize)));
317 connect(m_mapView, SIGNAL(viewResized(QSize)),
318 this, SLOT(drawFullScreenButton(QSize)));
320 connect(m_mapView, SIGNAL(viewResized(QSize)),
321 this, SLOT(drawMapScale(QSize)));
323 connect(m_mapView, SIGNAL(viewResized(QSize)),
324 this, SLOT(moveCrosshair()));
326 connect(this, SIGNAL(zoomLevelChanged(int)),
327 m_mapView, SLOT(setZoomLevel(int)));
329 connect(m_mapView, SIGNAL(viewZoomFinished()),
330 this, SIGNAL(viewZoomFinished()));
332 connect(m_mapView, SIGNAL(zoomIn()),
333 this, SIGNAL(zoomIn()));
336 void MainWindow::buildMapScale()
338 m_mapScale = new MapScale(this);
339 connect(this, SIGNAL(newMapResolution(qreal)),
340 m_mapScale, SLOT(updateMapResolution(qreal)));
343 void MainWindow::buildOsmLicense()
345 qDebug() << __PRETTY_FUNCTION__;
347 m_osmLicense = new QLabel(this);
348 m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
349 m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
350 m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
351 m_osmLicense->setFont(QFont("Nokia Sans", 9));
352 m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
353 m_osmLicense->fontMetrics().height());
355 connect(m_mapView, SIGNAL(viewResized(QSize)),
356 this, SLOT(drawOsmLicense(QSize)));
359 void MainWindow::buildPanels()
361 qDebug() << __PRETTY_FUNCTION__;
363 buildUserInfoPanel();
364 buildFriendListPanel();
365 buildLocationSearchPanel();
368 m_tabbedPanel = new TabbedPanel(this);
370 //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
371 m_situareTabsIndexes.append(
372 m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
373 m_situareTabsIndexes.append(
374 m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
376 m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
377 m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
379 connect(m_mapView, SIGNAL(viewResized(QSize)),
380 m_tabbedPanel, SLOT(resizePanel(QSize)));
382 connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
383 m_tabbedPanel, SLOT(openPanel(QWidget*)));
385 connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
386 m_tabbedPanel, SLOT(openPanel(QWidget*)));
388 connect(m_tabbedPanel, SIGNAL(panelClosed()),
389 m_friendsListPanel, SLOT(anyPanelClosed()));
391 connect(m_tabbedPanel, SIGNAL(panelOpened()),
392 m_friendsListPanel, SLOT(anyPanelOpened()));
394 connect(m_tabbedPanel, SIGNAL(panelClosed()),
395 m_routingPanel, SLOT(clearListsSelections()));
397 connect(m_tabbedPanel, SIGNAL(panelClosed()),
398 m_mapView, SLOT(disableCenterShift()));
400 connect(m_tabbedPanel, SIGNAL(panelOpened()),
401 m_mapView, SLOT(enableCenterShift()));
403 connect(m_tabbedPanel, SIGNAL(panelClosed()),
404 m_userInfoPanel, SIGNAL(collapse()));
406 connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
407 m_userInfoPanel, SIGNAL(collapse()));
409 // signals for showing and hiding list item context buttons
410 connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)),
411 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
413 connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)),
414 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
416 connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)),
417 m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool)));
420 void MainWindow::buildRoutingPanel()
422 qDebug() << __PRETTY_FUNCTION__;
424 m_routingPanel = new RoutingPanel(this);
426 connect(m_routingPanel, SIGNAL(routeToCursor()),
427 this, SIGNAL(routeToCursor()));
429 connect(this, SIGNAL(routeParsed(Route&)),
430 m_routingPanel, SLOT(setRoute(Route&)));
432 connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
433 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
435 connect(m_routingPanel, SIGNAL(clearRoute()),
436 this, SIGNAL(clearRoute()));
439 void MainWindow::buildUserInfoPanel()
441 qDebug() << __PRETTY_FUNCTION__;
443 m_userInfoPanel = new UserInfoPanel(this);
445 connect(this, SIGNAL(userLocationReady(User*)),
446 m_userInfoPanel, SLOT(userDataReceived(User*)));
448 connect(this, SIGNAL(reverseGeoReady(QString)),
449 m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
451 connect(this, SIGNAL(clearUpdateLocationDialogData()),
452 m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
454 connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
455 this, SIGNAL(centerToCoordinates(GeoCoordinate)));
457 connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
458 this, SIGNAL(requestReverseGeo()));
460 connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
461 this, SIGNAL(statusUpdate(QString,bool)));
463 connect(m_userInfoPanel, SIGNAL(refreshUserData()),
464 this, SIGNAL(refreshUserData()));
466 connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
467 this, SLOT(buildInformationBox(QString, bool)));
470 void MainWindow::buildZoomButtonPanel()
472 qDebug() << __PRETTY_FUNCTION__;
474 m_zoomButtonPanel = new ZoomButtonPanel(this);
476 connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
477 this, SIGNAL(zoomIn()));
479 connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
480 this, SIGNAL(zoomOut()));
482 connect(this, SIGNAL(zoomLevelChanged(int)),
483 m_zoomButtonPanel, SLOT(resetButtons()));
485 connect(this, SIGNAL(maxZoomLevelReached()),
486 m_zoomButtonPanel, SLOT(disableZoomInButton()));
488 connect(this, SIGNAL(minZoomLevelReached()),
489 m_zoomButtonPanel, SLOT(disableZoomOutButton()));
491 connect(m_mapView, SIGNAL(viewResized(QSize)),
492 m_zoomButtonPanel, SLOT(screenResized(QSize)));
494 connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
495 this, SIGNAL(draggingModeTriggered()));
498 void MainWindow::createMenus()
500 qDebug() << __PRETTY_FUNCTION__;
503 m_loginAct = new QAction(tr("Login"), this);
504 connect(m_loginAct, SIGNAL(triggered()),
505 this, SIGNAL(loginActionPressed()));
508 m_toSettingsAct = new QAction(tr("Settings"), this);
509 connect(m_toSettingsAct, SIGNAL(triggered()),
510 this, SLOT(openSettingsDialog()));
513 m_gpsToggleAct = new QAction(tr("GPS"), this);
514 m_gpsToggleAct->setCheckable(true);
516 connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
517 this, SIGNAL(gpsTriggered(bool)));
519 // build the actual menu
520 m_viewMenu = menuBar()->addMenu(tr("Main"));
521 m_viewMenu->addAction(m_loginAct);
522 m_viewMenu->addAction(m_toSettingsAct);
523 m_viewMenu->addAction(m_gpsToggleAct);
524 m_viewMenu->setObjectName(tr("Menu"));
527 void MainWindow::destroyFacebookLoginBrowser()
529 qWarning() << __PRETTY_FUNCTION__;
531 m_facebookLoginBrowser->hide();
532 m_facebookLoginBrowser->disconnect();
533 m_facebookLoginBrowser->deleteLater();
534 m_facebookLoginBrowser = 0;
537 void MainWindow::dialogFinished(int status)
539 qDebug() << __PRETTY_FUNCTION__;
541 QDialog *dialog = m_queue.takeFirst();
542 SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
543 if ((searchDialog) && (status != 0))
544 emit searchForLocation(searchDialog->input());
546 dialog->deleteLater();
548 if(!m_error_queue.isEmpty() && m_errorShown == false) {
549 showErrorInformationBox();
551 if(!m_queue.isEmpty()) {
552 showInformationBox();
557 void MainWindow::drawFullScreenButton(const QSize &size)
559 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
561 if (m_fullScreenButton) {
562 m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
563 size.height() - m_fullScreenButton->size().height());
567 void MainWindow::drawMapScale(const QSize &size)
569 qDebug() << __PRETTY_FUNCTION__;
571 const int LEFT_SCALE_MARGIN = 10;
572 const int BOTTOM_SCALE_MARGIN = 2;
574 m_mapScale->move(LEFT_SCALE_MARGIN,
575 size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
578 void MainWindow::drawOsmLicense(const QSize &size)
580 qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
582 m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
584 size.height() - m_osmLicense->fontMetrics().height());
587 void MainWindow::errorDialogFinished(int status)
589 qDebug() << __PRETTY_FUNCTION__;
592 QDialog *dialog = m_error_queue.takeFirst();
594 dialog->deleteLater();
595 m_errorShown = false;
597 if(!m_error_queue.isEmpty())
598 showErrorInformationBox();
599 else if(!m_queue.isEmpty())
600 showInformationBox();
603 void MainWindow::gpsTimeout()
605 qDebug() << __PRETTY_FUNCTION__;
607 buildInformationBox(tr("GPS timeout"));
610 void MainWindow::grabZoomKeys(bool grab)
612 qDebug() << __PRETTY_FUNCTION__;
615 // Can't grab keys unless we have a window id
619 unsigned long val = (grab) ? 1 : 0;
620 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
624 XChangeProperty (QX11Info::display(),
630 reinterpret_cast<unsigned char *>(&val),
634 #endif // Q_WS_MAEMO_5
637 void MainWindow::keyPressEvent(QKeyEvent* event)
639 qDebug() << __PRETTY_FUNCTION__;
641 switch (event->key()) {
652 QWidget::keyPressEvent(event);
655 void MainWindow::loggedIn(bool logged)
658 qDebug() << __PRETTY_FUNCTION__;
663 m_loginAct->setText(tr("Logout"));
669 m_loginAct->setText(tr("Login"));
670 m_userInfoPanel->showUserInfo(false);
672 updateItemVisibility();
675 void MainWindow::loginFailed()
678 qDebug() << __PRETTY_FUNCTION__;
684 bool MainWindow::loginState()
686 qDebug() << __PRETTY_FUNCTION__;
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(DIRECTORY_NAME, FILE_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 ///< @todo remove old, duplicate saveCookies()
757 void MainWindow::saveCookies()
759 qDebug() << __PRETTY_FUNCTION__;
762 // m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
764 // QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
767 // for(int i=0;i<cookieList.count();i++) {
768 // QNetworkCookie cookie = cookieList.at(i);
769 // QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
770 // list.append(QString(byteArray));
772 // list.removeDuplicates();
774 // QSettings settings(DIRECTORY_NAME, FILE_NAME);
775 // settings.setValue(COOKIES, list);
778 void MainWindow::setCrosshairVisibility(bool visibility)
780 qDebug() << __PRETTY_FUNCTION__;
790 void MainWindow::setGPSButtonEnabled(bool enabled)
792 qDebug() << __PRETTY_FUNCTION__;
794 m_gpsToggleAct->setChecked(enabled);
797 void MainWindow::setIndicatorButtonEnabled(bool enabled)
799 qDebug() << __PRETTY_FUNCTION__;
801 m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
804 void MainWindow::setMapViewScene(QGraphicsScene *scene)
806 qDebug() << __PRETTY_FUNCTION__;
808 m_mapView->setScene(scene);
811 void MainWindow::settingsDialogAccepted()
813 qDebug() << __PRETTY_FUNCTION__;
815 readAutomaticLocationUpdateSettings();
818 void MainWindow::showContactDialog(const QString &guid)
820 qDebug() << __PRETTY_FUNCTION__;
822 #if defined(Q_WS_MAEMO_5) & defined(ARMEL)
823 OssoABookDialog::showContactDialog(guid);
826 buildInformationBox(tr("Contact dialog works only on phone!"), true);
830 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
832 qDebug() << __PRETTY_FUNCTION__;
834 m_automaticUpdateLocationDialog = new QMessageBox(QMessageBox::Question,
835 tr("Automatic location update"), text,
836 QMessageBox::Yes | QMessageBox::No |
837 QMessageBox::Cancel, this);
838 connect(m_automaticUpdateLocationDialog, SIGNAL(finished(int)),
839 this, SLOT(automaticUpdateDialogFinished(int)));
841 m_automaticUpdateLocationDialog->show();
844 void MainWindow::showErrorInformationBox()
846 qDebug() << __PRETTY_FUNCTION__;
848 if(m_error_queue.count()) {
850 QDialog *dialog = m_error_queue.first();
851 connect(dialog, SIGNAL(finished(int)),
852 this, SLOT(errorDialogFinished(int)));
857 void MainWindow::showInformationBox()
859 qDebug() << __PRETTY_FUNCTION__;
861 if(m_queue.count()) {
862 QDialog *dialog = m_queue.first();
863 connect(dialog, SIGNAL(finished(int)),
864 this, SLOT(dialogFinished(int)));
869 void MainWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
871 qWarning() << __PRETTY_FUNCTION__;
873 reply->ignoreSslErrors();
876 void MainWindow::startLocationSearch()
878 qDebug() << __PRETTY_FUNCTION__;
880 SearchDialog *searchDialog = new SearchDialog();
881 queueDialog(searchDialog);
884 void MainWindow::startLoginProcess()
886 qDebug() << __PRETTY_FUNCTION__;
888 LoginDialog *loginDialog = new LoginDialog();
890 emit fetchUsernameFromSettings();
892 loginDialog->clearTextFields();
894 if(!m_email.isEmpty())
895 loginDialog->setEmailField(m_email);
897 queueDialog(loginDialog);
900 void MainWindow::toggleFullScreen()
902 qDebug() << __PRETTY_FUNCTION__;
904 if(windowState() == Qt::WindowNoState)
910 void MainWindow::toggleProgressIndicator(bool value)
912 qDebug() << __PRETTY_FUNCTION__;
916 m_progressIndicatorCount++;
917 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
919 if(m_progressIndicatorCount > 0)
920 m_progressIndicatorCount--;
922 if(m_progressIndicatorCount == 0)
923 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
927 #endif // Q_WS_MAEMO_5
930 void MainWindow::updateItemVisibility()
932 qDebug() << __PRETTY_FUNCTION__;
934 m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn);
937 const QString MainWindow::username()
939 qDebug() << __PRETTY_FUNCTION__;