X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fui%2Fmainwindow.cpp;h=8c93369cb6b694cb60e20ec552ef843c6fc1279a;hb=bc319a7c2e5b4b6c918f567299e0f224e0e11bc0;hp=b46fd44b5175042eeb7021ee9fcbca47297f1a50;hpb=9e9f8114f23c57386153e409c7edc28633bebe77;p=situare diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index b46fd44..8c93369 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -24,27 +24,31 @@ USA. */ +#include +#include + #include #include #include #include -#include -#include -#include "facebookservice/facebookauthentication.h" -#include "map/mapcommon.h" -#include "map/mapview.h" #include "common.h" +#include "engine/updatelocation.h" #include "error.h" #include "friendlistpanel.h" #include "fullscreenbutton.h" #include "indicatorbuttonpanel.h" -#include "logindialog.h" +#include "locationsearchpanel.h" +#include "map/mapcommon.h" +#include "map/mapview.h" #include "mapscale.h" #include "panelcommon.h" -#include "tabbedpanel.h" +#include "routingpanel.h" #include "searchdialog.h" #include "settingsdialog.h" +#include "situareservice/situarecommon.h" +#include "tabbedpanel.h" +#include "updatelocation/updatelocationdialog.h" #include "userinfopanel.h" #include "zoombuttonpanel.h" @@ -58,50 +62,49 @@ #include #endif // Q_WS_MAEMO_5 +#if defined(Q_WS_MAEMO_5) & defined(ARMEL) +#include "ossoabookdialog.h" +#endif + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_errorShown(false), m_loggedIn(false), m_refresh(false), + m_mapCenterHorizontalShifting(0), m_progressIndicatorCount(0), - m_ownLocationCrosshair(0), - m_email(), - m_password(), - m_webView(0), + m_loginDialog(0), + m_crosshair(0), m_fullScreenButton(0), m_indicatorButtonPanel(0), m_mapScale(0), - m_cookieJar(0) + m_updateLocationController(0) { qDebug() << __PRETTY_FUNCTION__; buildMap(); - // build main layout - QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(m_mapView); - layout->setMargin(0); - layout->setSpacing(0); - - setCentralWidget(new QWidget()); - centralWidget()->setLayout(layout); + // map view is the only widget which size & location is handled automatically by the system + // default functionality + setCentralWidget(m_mapView); buildPanels(); createMenus(); setWindowTitle(tr("Situare")); - // set stacking order of widgets - m_zoomButtonPanel->stackUnder(m_tabbedPanel); - if(m_fullScreenButton) { - m_fullScreenButton->stackUnder(m_zoomButtonPanel); - m_osmLicense->stackUnder(m_fullScreenButton); + // set stacking order of widgets (from top to bottom) + // m_tabbedPanel is the topmost one + if (m_fullScreenButton) { + m_fullScreenButton->stackUnder(m_tabbedPanel); + m_crosshair->stackUnder(m_fullScreenButton); } else { - m_osmLicense->stackUnder(m_zoomButtonPanel); + m_crosshair->stackUnder(m_tabbedPanel); } - m_ownLocationCrosshair->stackUnder(m_osmLicense); - m_indicatorButtonPanel->stackUnder(m_ownLocationCrosshair); - m_mapScale->stackUnder(m_indicatorButtonPanel); + m_zoomButtonPanel->stackUnder(m_crosshair); + m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel); + m_osmLicense->stackUnder(m_indicatorButtonPanel); + m_mapScale->stackUnder(m_osmLicense); m_mapView->stackUnder(m_mapScale); grabZoomKeys(true); @@ -119,9 +122,6 @@ MainWindow::~MainWindow() grabZoomKeys(false); - if(m_webView) - delete m_webView; - qDeleteAll(m_queue.begin(), m_queue.end()); m_queue.clear(); @@ -136,7 +136,7 @@ void MainWindow::automaticUpdateDialogFinished(int result) if (result == QMessageBox::Yes) { readAutomaticLocationUpdateSettings(); } else { - QSettings settings(DIRECTORY_NAME, FILE_NAME); + QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME); settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false); readAutomaticLocationUpdateSettings(); } @@ -144,21 +144,22 @@ void MainWindow::automaticUpdateDialogFinished(int result) m_automaticUpdateLocationDialog->deleteLater(); } -void MainWindow::buildFullScreenButton() +void MainWindow::buildCrosshair() { qDebug() << __PRETTY_FUNCTION__; -#ifdef Q_WS_MAEMO_5 - m_fullScreenButton = new FullScreenButton(this); + m_crosshair = new QLabel(this); + QPixmap crosshairImage(":/res/images/sight.png"); + m_crosshair->setPixmap(crosshairImage); + m_crosshair->setFixedSize(crosshairImage.size()); + m_crosshair->hide(); + m_crosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true); - if (m_fullScreenButton) { - connect(m_fullScreenButton, SIGNAL(clicked()), - this, SLOT(toggleFullScreen())); + connect(m_mapView, SIGNAL(viewResized(QSize)), + this, SLOT(moveCrosshair())); - connect(qApp, SIGNAL(showFullScreenButton()), - m_fullScreenButton, SLOT(invoke())); - } -#endif // Q_WS_MAEMO_5 + connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)), + this, SLOT(mapCenterHorizontalShiftingChanged(int))); } void MainWindow::buildFriendListPanel() @@ -174,10 +175,33 @@ void MainWindow::buildFriendListPanel() m_friendsListPanel, SLOT(showFriendsInList(QList))); connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)), - this, SIGNAL(findFriend(GeoCoordinate))); + this, SIGNAL(centerToCoordinates(GeoCoordinate))); connect(this, SIGNAL(friendImageReady(User*)), m_friendsListPanel, SLOT(friendImageReady(User*))); + + connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)), + this, SIGNAL(routeTo(const GeoCoordinate&))); + + connect(m_friendsListPanel, SIGNAL(requestContactDialog(const QString &)), + this, SIGNAL(requestContactDialog(const QString &))); +} + +void MainWindow::buildFullScreenButton() +{ + qDebug() << __PRETTY_FUNCTION__; + +#ifdef Q_WS_MAEMO_5 + m_fullScreenButton = new FullScreenButton(this); + + if (m_fullScreenButton) { + connect(m_fullScreenButton, SIGNAL(clicked()), + this, SLOT(toggleFullScreen())); + + connect(qApp, SIGNAL(showFullScreenButton()), + m_fullScreenButton, SLOT(invoke())); + } +#endif // Q_WS_MAEMO_5 } void MainWindow::buildIndicatorButtonPanel() @@ -231,19 +255,48 @@ void MainWindow::buildInformationBox(const QString &message, bool modal) queueDialog(msgBox); } -void MainWindow::buildManualLocationCrosshair() +void MainWindow::buildLocationSearchPanel() { qDebug() << __PRETTY_FUNCTION__; - m_ownLocationCrosshair = new QLabel(this); - QPixmap crosshairImage(":/res/images/sight.png"); - m_ownLocationCrosshair->setPixmap(crosshairImage); - m_ownLocationCrosshair->setFixedSize(crosshairImage.size()); - m_ownLocationCrosshair->hide(); - m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true); + m_locationSearchPanel = new LocationSearchPanel(this); - connect(m_mapView, SIGNAL(viewResized(QSize)), - this, SLOT(drawOwnLocationCrosshair(QSize))); + connect(this, SIGNAL(locationDataParsed(const QList&)), + m_locationSearchPanel, SLOT(populateLocationListView(const QList&))); + + connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)), + this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&))); + + connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)), + this, SIGNAL(routeTo(const GeoCoordinate&))); + + connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()), + this, SLOT(startLocationSearch())); + + connect(this, SIGNAL(searchForLocation(QString)), + m_locationSearchPanel, SLOT(prependSearchHistory(QString))); + + connect(m_locationSearchPanel, SIGNAL(searchHistoryItemClicked(QString)), + this, SIGNAL(searchHistoryItemClicked(QString))); +} + +void MainWindow::buildLoginDialog(QWebView *browser) +{ + qDebug() << __PRETTY_FUNCTION__; + + if (!m_loginDialog) { + m_loginDialog = new QDialog(this); + if (m_loginDialog) { + m_loginDialog->setWindowTitle(tr("Login")); + m_loginDialog->setLayout(new QVBoxLayout()); + m_loginDialog->layout()->addWidget(browser); + m_loginDialog->layout()->setContentsMargins(QMargins()); // zero margins + connect(m_loginDialog, SIGNAL(rejected()), this, SLOT(destroyLoginDialog())); + } + } + + if (m_loginDialog) + m_loginDialog->show(); } void MainWindow::buildMap() @@ -254,7 +307,7 @@ void MainWindow::buildMap() buildZoomButtonPanel(); buildOsmLicense(); - buildManualLocationCrosshair(); + buildCrosshair(); buildFullScreenButton(); buildIndicatorButtonPanel(); buildMapScale(); @@ -275,7 +328,7 @@ void MainWindow::buildMap() this, SLOT(drawMapScale(QSize))); connect(m_mapView, SIGNAL(viewResized(QSize)), - this, SLOT(setViewPortSize(QSize))); + this, SLOT(moveCrosshair())); connect(this, SIGNAL(zoomLevelChanged(int)), m_mapView, SLOT(setZoomLevel(int))); @@ -316,70 +369,97 @@ void MainWindow::buildPanels() buildUserInfoPanel(); buildFriendListPanel(); + buildLocationSearchPanel(); + buildRoutingPanel(); m_tabbedPanel = new TabbedPanel(this); - m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")); - m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")); - connect(m_tabbedPanel, SIGNAL(tabChanged()), - m_friendsListPanel, SLOT(clearFriendListFilter())); + //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out + m_situareTabsIndexes.append( + m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png"))); + m_situareTabsIndexes.append( + m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png"))); + + m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png")); + m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png")); connect(m_mapView, SIGNAL(viewResized(QSize)), m_tabbedPanel, SLOT(resizePanel(QSize))); -} -void MainWindow::buildUserInfoPanel() -{ - qDebug() << __PRETTY_FUNCTION__; + connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)), + m_tabbedPanel, SLOT(openPanel(QWidget*))); - m_userInfoPanel = new UserInfoPanel(this); + connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)), + m_tabbedPanel, SLOT(openPanel(QWidget*))); - connect(this, SIGNAL(userLocationReady(User*)), - m_userInfoPanel, SLOT(userDataReceived(User*))); + connect(m_tabbedPanel, SIGNAL(panelClosed()), + m_friendsListPanel, SLOT(anyPanelClosed())); - connect(this, SIGNAL(reverseGeoReady(QString)), - m_userInfoPanel, SIGNAL(reverseGeoReady(QString))); + connect(m_tabbedPanel, SIGNAL(panelOpened()), + m_friendsListPanel, SLOT(anyPanelOpened())); - connect(this, SIGNAL(clearUpdateLocationDialogData()), - m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData())); + connect(m_tabbedPanel, SIGNAL(panelClosed()), + m_routingPanel, SLOT(clearListsSelections())); - connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)), - this, SIGNAL(findUser(GeoCoordinate))); + connect(m_tabbedPanel, SIGNAL(panelClosed()), + m_mapView, SLOT(disableCenterShift())); - connect(m_userInfoPanel, SIGNAL(requestReverseGeo()), - this, SIGNAL(requestReverseGeo())); + connect(m_tabbedPanel, SIGNAL(panelOpened()), + m_mapView, SLOT(enableCenterShift())); - connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)), - this, SIGNAL(statusUpdate(QString,bool))); + connect(m_tabbedPanel, SIGNAL(panelClosed()), + m_userInfoPanel, SIGNAL(collapse())); - connect(m_userInfoPanel, SIGNAL(refreshUserData()), - this, SIGNAL(refreshUserData())); + connect(m_tabbedPanel, SIGNAL(currentChanged(int)), + m_userInfoPanel, SIGNAL(collapse())); + + // signals for showing and hiding list item context buttons + connect(m_friendsListPanel, SIGNAL(listItemSelectionChanged(bool)), + m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool))); + + connect(m_locationSearchPanel, SIGNAL(listItemSelectionChanged(bool)), + m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool))); - connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)), - this, SLOT(buildInformationBox(QString, bool))); + connect(m_routingPanel, SIGNAL(listItemSelectionChanged(bool)), + m_tabbedPanel, SIGNAL(listItemSelectionChanged(bool))); } -void MainWindow::buildWebView() +void MainWindow::buildRoutingPanel() { qDebug() << __PRETTY_FUNCTION__; - if(!m_webView) { - m_webView = new QWebView; + m_routingPanel = new RoutingPanel(this); - if(!m_cookieJar) - m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this)); + connect(m_routingPanel, SIGNAL(routeToCursor()), + this, SIGNAL(routeToCursor())); - m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar); + connect(this, SIGNAL(routeParsed(Route&)), + m_routingPanel, SLOT(setRoute(Route&))); - connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)), - this, SLOT(webViewRequestFinished(QNetworkReply*))); - connect(m_webView, SIGNAL(urlChanged(const QUrl &)), - this, SIGNAL(updateCredentials(QUrl))); - connect(m_webView, SIGNAL(loadFinished(bool)), - this, SLOT(loadDone(bool))); + connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)), + this, SIGNAL(centerToCoordinates(GeoCoordinate))); - m_webView->hide(); - } + connect(m_routingPanel, SIGNAL(clearRoute()), + this, SIGNAL(clearRoute())); +} + +void MainWindow::buildUserInfoPanel() +{ + qDebug() << __PRETTY_FUNCTION__; + + m_userInfoPanel = new UserInfoPanel(this); + + connect(this, SIGNAL(userLocationReady(User*)), + m_userInfoPanel, SLOT(userDataReceived(User*))); + + connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)), + this, SIGNAL(centerToCoordinates(GeoCoordinate))); + + connect(m_userInfoPanel, SIGNAL(refreshUserData()), + this, SIGNAL(refreshUserData())); + + connect(m_userInfoPanel, SIGNAL(updateLocationMessageButtonClicked()), + this, SLOT(showUpdateLocationDialog())); } void MainWindow::buildZoomButtonPanel() @@ -410,24 +490,6 @@ void MainWindow::buildZoomButtonPanel() this, SIGNAL(draggingModeTriggered())); } -void MainWindow::clearCookieJar() -{ - qDebug() << __PRETTY_FUNCTION__; - - buildWebView(); - - m_webView->stop(); - - if(!m_cookieJar) { - m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this)); - } - QList emptyList; - emptyList.clear(); - - m_cookieJar->setAllCookies(emptyList); - m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar); -} - void MainWindow::createMenus() { qDebug() << __PRETTY_FUNCTION__; @@ -449,53 +511,33 @@ void MainWindow::createMenus() connect(m_gpsToggleAct, SIGNAL(triggered(bool)), this, SIGNAL(gpsTriggered(bool))); - /// @todo remove when not needed! - m_searchLocationAct = new QAction(tr("Location search"), this); - connect(m_searchLocationAct, SIGNAL(triggered()), - this, SLOT(startLocationSearch())); - // build the actual menu m_viewMenu = menuBar()->addMenu(tr("Main")); m_viewMenu->addAction(m_loginAct); m_viewMenu->addAction(m_toSettingsAct); m_viewMenu->addAction(m_gpsToggleAct); - m_viewMenu->addAction(m_searchLocationAct); /// @todo remove when not needed! m_viewMenu->setObjectName(tr("Menu")); } +void MainWindow::destroyLoginDialog() +{ + qDebug() << __PRETTY_FUNCTION__; + + if (m_loginDialog) { + m_loginDialog->hide(); + m_loginDialog->deleteLater(); + m_loginDialog = 0; + } +} + void MainWindow::dialogFinished(int status) { qDebug() << __PRETTY_FUNCTION__; QDialog *dialog = m_queue.takeFirst(); - LoginDialog *loginDialog = qobject_cast(dialog); SearchDialog *searchDialog = qobject_cast(dialog); - if(loginDialog) { - if(status != 0) { - buildWebView(); - loginDialog->userInput(m_email, m_password); - - QStringList urlParts; - urlParts.append(FACEBOOK_LOGINBASE); - urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY); - urlParts.append(INTERVAL1); - urlParts.append(SITUARE_LOGIN_SUCCESS); - urlParts.append(INTERVAL2); - urlParts.append(SITUARE_LOGIN_FAILURE); - urlParts.append(FACEBOOK_LOGIN_ENDING); - - emit saveUsername(m_email); - m_refresh = true; - m_webView->load(QUrl(urlParts.join(EMPTY))); - toggleProgressIndicator(true); - } else { - emit cancelLoginProcess(); - } - } else if(searchDialog) { - if(status != 0) { - emit searchForLocation(searchDialog->input()); - } - } + if ((searchDialog) && (status != 0)) + emit searchForLocation(searchDialog->input()); dialog->deleteLater(); @@ -512,9 +554,10 @@ void MainWindow::drawFullScreenButton(const QSize &size) { qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height(); - if(m_fullScreenButton) + if (m_fullScreenButton) { m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(), size.height() - m_fullScreenButton->size().height()); + } } void MainWindow::drawMapScale(const QSize &size) @@ -523,7 +566,6 @@ void MainWindow::drawMapScale(const QSize &size) const int LEFT_SCALE_MARGIN = 10; const int BOTTOM_SCALE_MARGIN = 2; -// qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height(); m_mapScale->move(LEFT_SCALE_MARGIN, size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN); @@ -538,16 +580,6 @@ void MainWindow::drawOsmLicense(const QSize &size) size.height() - m_osmLicense->fontMetrics().height()); } -void MainWindow::drawOwnLocationCrosshair(const QSize &size) -{ - qDebug() << __PRETTY_FUNCTION__; - - if (m_ownLocationCrosshair != 0) { - m_ownLocationCrosshair->move(size.width()/2 - m_ownLocationCrosshair->pixmap()->width()/2, - size.height()/2 - m_ownLocationCrosshair->pixmap()->height()/2); - } -} - void MainWindow::errorDialogFinished(int status) { qDebug() << __PRETTY_FUNCTION__; @@ -616,72 +648,6 @@ void MainWindow::keyPressEvent(QKeyEvent* event) QWidget::keyPressEvent(event); } -void MainWindow::loadCookies() -{ - qDebug() << __PRETTY_FUNCTION__; - - QSettings settings(DIRECTORY_NAME, FILE_NAME); - - QStringList list = settings.value(COOKIES, EMPTY).toStringList(); - - if(!list.isEmpty()) { - QList cookieList; - for(int i=0;isetAllCookies(cookieList); - m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar); - } -} - -void MainWindow::loadDone(bool done) -{ - qDebug() << __PRETTY_FUNCTION__; - - // for the first time the login page is opened, we need to refresh it to get cookies working - if(m_refresh) { - m_webView->reload(); - m_refresh = false; - } - - if (done) - { - QWebFrame* frame = m_webView->page()->currentFrame(); - if (frame!=NULL) - { - // set email box - QWebElementCollection emailCollection = frame->findAllElements("input[name=email]"); - - foreach (QWebElement element, emailCollection) { - element.setAttribute("value", m_email.toAscii()); - } - // set password box - QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]"); - foreach (QWebElement element, passwordCollection) { - element.setAttribute("value", m_password.toAscii()); - } - // find connect button - QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]"); - foreach (QWebElement element, buttonCollection) - { - QPoint pos(element.geometry().center()); - - // send a mouse click event to the web page - QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, - Qt::NoModifier); - QApplication::sendEvent(m_webView->page(), &event0); - QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, - Qt::NoModifier); - QApplication::sendEvent(m_webView->page(), &event1); - } - } - } -} - void MainWindow::loggedIn(bool logged) { qDebug() << __PRETTY_FUNCTION__; @@ -691,50 +657,30 @@ void MainWindow::loggedIn(bool logged) if(logged) { m_loginAct->setText(tr("Logout")); } else { - clearCookieJar(); - m_email.clear(); - m_password.clear(); - m_loginAct->setText(tr("Login")); + m_userInfoPanel->showUserInfo(false); + m_updateLocationController->clear(); } - updateItemVisibility(); + updateItemVisibility(logged); } -void MainWindow::loginFailed() +void MainWindow::mapCenterHorizontalShiftingChanged(int shifting) { - qDebug() << __PRETTY_FUNCTION__; - - clearCookieJar(); - startLoginProcess(); + m_mapCenterHorizontalShifting = shifting; + moveCrosshair(); } -bool MainWindow::loginState() +void MainWindow::moveCrosshair() { qDebug() << __PRETTY_FUNCTION__; - return m_loggedIn; -} - -void MainWindow::loginUsingCookies() -{ - qDebug() << __PRETTY_FUNCTION__; - - toggleProgressIndicator(true); - - buildWebView(); - loadCookies(); - - QStringList urlParts; - urlParts.append(FACEBOOK_LOGINBASE); - urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY); - urlParts.append(INTERVAL1); - urlParts.append(SITUARE_LOGIN_SUCCESS); - urlParts.append(INTERVAL2); - urlParts.append(SITUARE_LOGIN_FAILURE); - urlParts.append(FACEBOOK_LOGIN_ENDING); - - m_webView->load(QUrl(urlParts.join(EMPTY))); - + if (m_crosshair) { + int mapHeight = m_mapView->size().height(); + int mapWidth = m_mapView->size().width(); + m_crosshair->move(mapWidth / 2 - m_crosshair->pixmap()->width() / 2 + - m_mapCenterHorizontalShifting, + mapHeight / 2 - m_crosshair->pixmap()->height() / 2); + } } void MainWindow::openSettingsDialog() @@ -748,23 +694,6 @@ void MainWindow::openSettingsDialog() settingsDialog->show(); } -void MainWindow::readAutomaticLocationUpdateSettings() -{ - qDebug() << __PRETTY_FUNCTION__; - - QSettings settings(DIRECTORY_NAME, FILE_NAME); - bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool(); - QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime()) - .toTime(); - - if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) { - QTime time; - emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval)); - } else { - emit enableAutomaticLocationUpdate(false); - } -} - void MainWindow::queueDialog(QDialog *dialog) { qDebug() << __PRETTY_FUNCTION__; @@ -783,25 +712,33 @@ void MainWindow::queueDialog(QDialog *dialog) showInformationBox(); } -void MainWindow::saveCookies() +void MainWindow::readAutomaticLocationUpdateSettings() { qDebug() << __PRETTY_FUNCTION__; - if(!m_cookieJar) - m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this)); - - QList cookieList = m_cookieJar->allCookies(); - QStringList list; + QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME); + bool automaticUpdateEnabled = settings.value(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false).toBool(); + QTime automaticUpdateInterval = settings.value(SETTINGS_AUTOMATIC_UPDATE_INTERVAL, QTime()) + .toTime(); - for(int i=0;ishow(); + moveCrosshair(); + } else { + m_crosshair->hide(); + } } void MainWindow::setGPSButtonEnabled(bool enabled) @@ -825,18 +762,6 @@ void MainWindow::setMapViewScene(QGraphicsScene *scene) m_mapView->setScene(scene); } -void MainWindow::setOwnLocationCrosshairVisibility(bool visibility) -{ - qDebug() << __PRETTY_FUNCTION__; - - if (visibility) { - m_ownLocationCrosshair->show(); - drawOwnLocationCrosshair(m_viewPortSize); - } else { - m_ownLocationCrosshair->hide(); - } -} - void MainWindow::settingsDialogAccepted() { qDebug() << __PRETTY_FUNCTION__; @@ -844,18 +769,16 @@ void MainWindow::settingsDialogAccepted() readAutomaticLocationUpdateSettings(); } -void MainWindow::setUsername(const QString &username) -{ - qDebug() << __PRETTY_FUNCTION__; - - m_email = username; -} - -void MainWindow::setViewPortSize(const QSize &size) +void MainWindow::showContactDialog(const QString &guid) { qDebug() << __PRETTY_FUNCTION__; - m_viewPortSize = size; +#if defined(Q_WS_MAEMO_5) & defined(ARMEL) + OssoABookDialog::showContactDialog(guid); +#else + Q_UNUSED(guid); + buildInformationBox(tr("Contact dialog works only on phone!"), true); +#endif } void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text) @@ -872,16 +795,6 @@ void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text) m_automaticUpdateLocationDialog->show(); } -void MainWindow::toggleFullScreen() -{ - qDebug() << __PRETTY_FUNCTION__; - - if(windowState() == Qt::WindowNoState) - showFullScreen(); - else - showNormal(); -} - void MainWindow::showErrorInformationBox() { qDebug() << __PRETTY_FUNCTION__; @@ -907,23 +820,37 @@ void MainWindow::showInformationBox() } } -void MainWindow::showPanels() +void MainWindow::showUpdateLocationDialog() { qDebug() << __PRETTY_FUNCTION__; - drawFullScreenButton(m_viewPortSize); + if (!m_updateLocationController) { + m_updateLocationController = new UpdateLocation(this); + if (!m_updateLocationController) + return; + else + connect(this, SIGNAL(updateWasSuccessful()), m_updateLocationController, SLOT(clear())); + connect(m_updateLocationController, SIGNAL(locationUpdate(QString,bool)), + this, SIGNAL(locationUpdate(QString,bool))); + } + + UpdateLocationDialog *updateLocationDialog + = new UpdateLocationDialog(m_updateLocationController, this); + + connect(this, SIGNAL(reverseGeoReady(QString)), + updateLocationDialog, SLOT(setAddress(QString))); -// if(m_loggedIn) { -// if(!m_friendsListPanel->isVisible()) { -// m_friendsListPanel->show(); -// m_friendsListPanelSidebar->show(); -// } + updateLocationDialog->show(); -// if(!m_userPanel->isVisible()) { -// m_userPanel->show(); -// m_userPanelSidebar->show(); -// } -// } + emit requestReverseGeo(); +} + +void MainWindow::sslErrors(QNetworkReply *reply, const QList &errors) +{ + qDebug() << __PRETTY_FUNCTION__; + + Q_UNUSED(errors) + reply->ignoreSslErrors(); } void MainWindow::startLocationSearch() @@ -934,20 +861,14 @@ void MainWindow::startLocationSearch() queueDialog(searchDialog); } -void MainWindow::startLoginProcess() +void MainWindow::toggleFullScreen() { qDebug() << __PRETTY_FUNCTION__; - LoginDialog *loginDialog = new LoginDialog(); - - emit fetchUsernameFromSettings(); - - loginDialog->clearTextFields(); - - if(!m_email.isEmpty()) - loginDialog->setEmailField(m_email); - - queueDialog(loginDialog); + if(windowState() == Qt::WindowNoState) + showFullScreen(); + else + showNormal(); } void MainWindow::toggleProgressIndicator(bool value) @@ -970,36 +891,9 @@ void MainWindow::toggleProgressIndicator(bool value) #endif // Q_WS_MAEMO_5 } -void MainWindow::updateItemVisibility() +void MainWindow::updateItemVisibility(bool loggedIn) { qDebug() << __PRETTY_FUNCTION__; -// if(!m_loggedIn) { -// m_friendsListPanel->closePanel(); -// m_friendsListPanel->hide(); -// m_friendsListPanelSidebar->hide(); - -// m_userPanel->closePanel(); -// m_userPanel->hide(); -// m_userPanelSidebar->hide(); -// } -} - -const QString MainWindow::username() -{ - qDebug() << __PRETTY_FUNCTION__; - - return m_email; -} - -void MainWindow::webViewRequestFinished(QNetworkReply *reply) -{ - qDebug() << __PRETTY_FUNCTION__; - - // omit QNetworkReply::OperationCanceledError due to it's nature to be called when ever - // qwebview starts to load a new page while the current page loading is not finished - if(reply->error() != QNetworkReply::OperationCanceledError && - reply->error() != QNetworkReply::NoError) { - emit error(ErrorContext::NETWORK, reply->error()); - } + m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn); }