Henri Lampela - henri.lampela@ixonos.com
Kaj Wallin - kaj.wallin@ixonos.com
- Jussi Laitinen jussi.laitinen@ixonos.com
+ Jussi Laitinen - jussi.laitinen@ixonos.com
Sami Rämö - sami.ramo@ixonos.com
Ville Tiensuu - ville.tiensuu@ixonos.com
+ Katri Kaikkonen - katri.kaikkonen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
USA.
*/
-#include <QtGui>
-#include <QtWebKit>
+#include <QAction>
+#include <QApplication>
+#include <QMenuBar>
+#include <QMessageBox>
#include <QtAlgorithms>
+#include <QtWebKit>
-#include "common.h"
+///< @todo sort
#include "facebookservice/facebookauthentication.h"
+#include "map/mapcommon.h"
+#include "map/mapview.h"
+#include "common.h"
+#include "error.h"
#include "friendlistpanel.h"
+#include "fullscreenbutton.h"
+#include "indicatorbuttonpanel.h"
+#include "locationsearchpanel.h"
#include "logindialog.h"
-#include "map/mapview.h"
+#include "mapscale.h"
+#include "panelcommon.h"
+#include "routingpanel.h"
+#include "tabbedpanel.h"
+#include "searchdialog.h"
#include "settingsdialog.h"
#include "userinfopanel.h"
#include "zoombuttonpanel.h"
-#include "mapscale.h"
#include "mainwindow.h"
#include <X11/Xlib.h>
#endif // Q_WS_MAEMO_5
-// values for setting screen size in desktop matching N900 screen size
-const int N900_APP_WIDTH = 800;
-const int N900_APP_HEIGHT = 449;
-
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
- m_drawOwnLocationCrosshair(false),
- m_errorShown(false),
- m_loggedIn(false),
- m_refresh(false),
- m_ownLocationCrosshair(0),
- m_email(),
- m_password(),
- m_fullScreenButton(0),
- m_webView(0),
- m_mapScale(0),
- m_cookieJar(0)
+ m_errorShown(false),
+ m_loggedIn(false),
+ m_refresh(false),
+ m_mapCenterHorizontalShifting(0),
+ m_progressIndicatorCount(0),
+ m_crosshair(0),
+ m_email(), ///< @todo WTF?!?!?!?
+ m_password(),
+ m_webView(0),
+ m_fullScreenButton(0),
+ m_indicatorButtonPanel(0),
+ m_mapScale(0),
+ m_cookieJar(0)
{
qDebug() << __PRETTY_FUNCTION__;
buildMap();
- // build main layout
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(m_mapView);
- layout->setMargin(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);
- buildFriendListPanel();
- buildUserInfoPanel();
+ buildPanels();
createMenus();
setWindowTitle(tr("Situare"));
- // set stacking order of widgets
- m_zoomButtonPanel->stackUnder(m_userPanel);
- 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_mapScale->stackUnder(m_ownLocationCrosshair);
+ 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);
- this->toggleProgressIndicator(true);
-
grabZoomKeys(true);
- // set screen size in desktop matching N900 screen size
- resize(N900_APP_WIDTH, N900_APP_HEIGHT);
+ // Set default screen size
+ resize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow);
#endif
if (result == QMessageBox::Yes) {
readAutomaticLocationUpdateSettings();
- } else if (result == QMessageBox::No) {
+ } else {
QSettings settings(DIRECTORY_NAME, FILE_NAME);
settings.setValue(SETTINGS_AUTOMATIC_UPDATE_ENABLED, false);
readAutomaticLocationUpdateSettings();
m_automaticUpdateLocationDialog->deleteLater();
}
-void MainWindow::buildFullScreenButton()
+void MainWindow::buildCrosshair()
{
qDebug() << __PRETTY_FUNCTION__;
-#ifdef Q_WS_MAEMO_5
- m_fullScreenButton = new QToolButton(this);
- m_fullScreenButton->setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
- m_fullScreenButton->setFixedSize(m_fullScreenButton->sizeHint());
- connect(m_fullScreenButton, SIGNAL(clicked()),
- this, SLOT(toggleFullScreen()));
-#endif // Q_WS_MAEMO_5
+ 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);
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ this, SLOT(moveCrosshair()));
+
+ connect(m_mapView, SIGNAL(horizontalShiftingChanged(int)),
+ this, SLOT(mapCenterHorizontalShiftingChanged(int)));
}
void MainWindow::buildFriendListPanel()
qDebug() << __PRETTY_FUNCTION__;
m_friendsListPanel = new FriendListPanel(this);
- m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
-
- m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
- connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
- this, SIGNAL(findFriend(QPointF)));
-
- connect(m_mapView, SIGNAL(viewResized(QSize)),
- m_friendsListPanel, SLOT(screenResized(QSize)));
-
connect(this, SIGNAL(locationItemClicked(QList<QString>)),
m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
+ connect(m_friendsListPanel, 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&)));
+}
+
+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()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_indicatorButtonPanel = new IndicatorButtonPanel(this);
+
+ connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
+ this, SIGNAL(autoCenteringTriggered(bool)));
+
connect(m_mapView, SIGNAL(viewResized(QSize)),
- m_friendsListPanelSidebar, SLOT(reDrawSidebar(QSize)));
+ m_indicatorButtonPanel, SLOT(screenResized(QSize)));
+
+ connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
+ m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
+
+ connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
+ this, SIGNAL(draggingModeTriggered()));
}
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<Location>&)),
+ m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
+
+ 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()));
}
void MainWindow::buildMap()
buildZoomButtonPanel();
buildOsmLicense();
- buildManualLocationCrosshair();
+ buildCrosshair();
buildFullScreenButton();
+ buildIndicatorButtonPanel();
buildMapScale();
- connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
- this, SIGNAL(mapViewScrolled(QPoint)));
+ connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
+ this, SIGNAL(mapViewScrolled(SceneCoordinate)));
- connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
- m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
+ connect(this, SIGNAL(centerToSceneCoordinates(SceneCoordinate)),
+ m_mapView, SLOT(centerToSceneCoordinates(SceneCoordinate)));
connect(m_mapView, SIGNAL(viewResized(QSize)),
this, SIGNAL(mapViewResized(QSize)));
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)));
connect(m_mapView, SIGNAL(viewZoomFinished()),
this, SIGNAL(viewZoomFinished()));
+
+ connect(m_mapView, SIGNAL(zoomIn()),
+ this, SIGNAL(zoomIn()));
}
void MainWindow::buildMapScale()
this, SLOT(drawOsmLicense(QSize)));
}
-void MainWindow::buildUserInfoPanel()
+void MainWindow::buildPanels()
{
qDebug() << __PRETTY_FUNCTION__;
- m_userPanel = new UserInfoPanel(this);
- m_userPanelSidebar = new PanelSideBar(this, LEFT);
+ buildUserInfoPanel();
+ buildFriendListPanel();
+ buildLocationSearchPanel();
+ buildRoutingPanel();
- m_userPanelSidebar->stackUnder(m_friendsListPanel);
- m_userPanel->stackUnder(m_userPanelSidebar);
+ 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"));
+ m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/search.png"));
+ m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
- connect(m_userPanel, SIGNAL(findUser(QPointF)),
- this, SIGNAL(findUser(QPointF)));
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ m_tabbedPanel, SLOT(resizePanel(QSize)));
- connect(this, SIGNAL(userLocationReady(User*)),
- m_userPanel, SLOT(userDataReceived(User*)));
+ connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
+ m_tabbedPanel, SLOT(openPanel(QWidget*)));
- connect(m_userPanel, SIGNAL(requestReverseGeo()),
- this, SIGNAL(requestReverseGeo()));
+ connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
+ m_tabbedPanel, SLOT(openPanel(QWidget*)));
- connect(this, SIGNAL(reverseGeoReady(QString)),
- m_userPanel, SIGNAL(reverseGeoReady(QString)));
+ connect(m_tabbedPanel, SIGNAL(panelClosed()),
+ m_friendsListPanel, SLOT(anyPanelClosed()));
- connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
- this, SIGNAL(statusUpdate(QString,bool)));
+ connect(m_tabbedPanel, SIGNAL(panelOpened()),
+ m_friendsListPanel, SLOT(anyPanelOpened()));
- connect(m_userPanel, SIGNAL(refreshUserData()),
- this, SIGNAL(refreshUserData()));
+ connect(m_tabbedPanel, SIGNAL(panelClosed()),
+ m_routingPanel, SLOT(clearListsSelections()));
- connect(m_mapView, SIGNAL(viewResized(QSize)),
- m_userPanel, SLOT(screenResized(QSize)));
+ connect(m_tabbedPanel, SIGNAL(panelClosed()),
+ m_mapView, SLOT(disableCenterShift()));
+
+ connect(m_tabbedPanel, SIGNAL(panelOpened()),
+ m_mapView, SLOT(enableCenterShift()));
+
+ connect(m_tabbedPanel, SIGNAL(panelClosed()),
+ m_userInfoPanel, SIGNAL(collapse()));
+
+ connect(m_tabbedPanel, SIGNAL(currentChanged(int)),
+ m_userInfoPanel, SIGNAL(collapse()));
+}
+
+void MainWindow::buildRoutingPanel()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_routingPanel = new RoutingPanel(this);
+
+ connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
+ m_routingPanel, SLOT(populateLocationListView(const QList<Location>&)));
+
+ connect(m_routingPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+ this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+
+ connect(m_routingPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
+ this, SIGNAL(routeTo(const GeoCoordinate&)));
+
+ connect(this, SIGNAL(routeParsed(Route&)),
+ m_routingPanel, SLOT(setRoute(Route&)));
+
+ connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
+ this, SIGNAL(centerToCoordinates(GeoCoordinate)));
+
+ connect(m_routingPanel, SIGNAL(requestSearchLocation()),
+ this, SLOT(startLocationSearch()));
+
+ 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(this, SIGNAL(reverseGeoReady(QString)),
+ m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
connect(this, SIGNAL(clearUpdateLocationDialogData()),
- m_userPanel, SIGNAL(clearUpdateLocationDialogData()));
+ m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
+
+ connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
+ this, SIGNAL(centerToCoordinates(GeoCoordinate)));
+
+ connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
+ this, SIGNAL(requestReverseGeo()));
+
+ connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
+ this, SIGNAL(statusUpdate(QString,bool)));
- connect(this, SIGNAL(messageSendingFailed(int)),
- m_userPanel, SIGNAL(messageSendingFailed(int)));
+ connect(m_userInfoPanel, SIGNAL(refreshUserData()),
+ this, SIGNAL(refreshUserData()));
- connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
+ connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
this, SLOT(buildInformationBox(QString, bool)));
}
connect(m_mapView, SIGNAL(viewResized(QSize)),
m_zoomButtonPanel, SLOT(screenResized(QSize)));
+
+ connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
+ this, SIGNAL(draggingModeTriggered()));
}
void MainWindow::clearCookieJar()
connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
this, SIGNAL(gpsTriggered(bool)));
- // automatic centering
- m_autoCenteringAct = new QAction(tr("Auto centering"), this);
- m_autoCenteringAct->setCheckable(true);
- connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
- this, SIGNAL(autoCenteringTriggered(bool)));
-
// 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_autoCenteringAct);
m_viewMenu->setObjectName(tr("Menu"));
}
QDialog *dialog = m_queue.takeFirst();
LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
+ SearchDialog *searchDialog = qobject_cast<SearchDialog *>(dialog);
if(loginDialog) {
if(status != 0) {
buildWebView();
} else {
emit cancelLoginProcess();
}
+ } else if(searchDialog) {
+ if(status != 0) {
+ emit searchForLocation(searchDialog->input());
+ }
}
dialog->deleteLater();
{
qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
- if(m_fullScreenButton) {
- m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
- - PANEL_PEEK_AMOUNT,
+ if (m_fullScreenButton) {
+ m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
size.height() - m_fullScreenButton->size().height());
}
}
void MainWindow::drawMapScale(const QSize &size)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
const int LEFT_SCALE_MARGIN = 10;
const int BOTTOM_SCALE_MARGIN = 2;
- qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
- m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
+ m_mapScale->move(LEFT_SCALE_MARGIN,
size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
}
qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
- - PANEL_PEEK_AMOUNT,
+ - PANEL_BAR_WIDTH,
size.height() - m_osmLicense->fontMetrics().height());
}
-void MainWindow::drawOwnLocationCrosshair(const QSize &size)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if (m_drawOwnLocationCrosshair && 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__;
m_cookieJar->setAllCookies(cookieList);
m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
-
}
}
m_loginAct->setText(tr("Login"));
}
- updateItemVisibility(m_loggedIn);
+ updateItemVisibility();
}
void MainWindow::loginFailed()
qDebug() << __PRETTY_FUNCTION__;
clearCookieJar();
+ startLoginProcess();
+}
- toggleProgressIndicator(false);
+bool MainWindow::loginState()
+{
+ qDebug() << __PRETTY_FUNCTION__;
- startLoginProcess();
+ 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);
}
-void MainWindow::openSettingsDialog()
+void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
{
- qDebug() << __PRETTY_FUNCTION__;
+ m_mapCenterHorizontalShifting = shifting;
+ moveCrosshair();
+}
- SettingsDialog *settingsDialog = new SettingsDialog(this);
- settingsDialog->enableSituareSettings(m_loggedIn);
- connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
+void MainWindow::moveCrosshair()
+{
+ qDebug() << __PRETTY_FUNCTION__;
- settingsDialog->show();
+ 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::readAutomaticLocationUpdateSettings()
+void MainWindow::openSettingsDialog()
{
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();
+ SettingsDialog *settingsDialog = new SettingsDialog(this);
+ settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
+ connect(settingsDialog, SIGNAL(accepted()), this, SLOT(settingsDialogAccepted()));
- if (automaticUpdateEnabled && automaticUpdateInterval.isValid()) {
- QTime time;
- emit enableAutomaticLocationUpdate(true, time.msecsTo(automaticUpdateInterval));
- } else {
- emit enableAutomaticLocationUpdate(false);
- }
+ settingsDialog->show();
}
void MainWindow::queueDialog(QDialog *dialog)
showInformationBox();
}
+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::saveCookies()
{
qDebug() << __PRETTY_FUNCTION__;
settings.setValue(COOKIES, list);
}
-void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
+void MainWindow::setCrosshairVisibility(bool visibility)
{
qDebug() << __PRETTY_FUNCTION__;
- m_autoCenteringAct->setChecked(enabled);
+ if (visibility) {
+ m_crosshair->show();
+ moveCrosshair();
+ } else {
+ m_crosshair->hide();
+ }
}
void MainWindow::setGPSButtonEnabled(bool enabled)
qDebug() << __PRETTY_FUNCTION__;
m_gpsToggleAct->setChecked(enabled);
-
- setOwnLocationCrosshairVisibility(!enabled);
-
- m_autoCenteringAct->setVisible(enabled);
}
-void MainWindow::setMapViewScene(QGraphicsScene *scene)
+void MainWindow::setIndicatorButtonEnabled(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
- m_mapView->setScene(scene);
+ m_indicatorButtonPanel->setIndicatorButtonEnabled(enabled);
}
-void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
+void MainWindow::setMapViewScene(QGraphicsScene *scene)
{
qDebug() << __PRETTY_FUNCTION__;
- if (visibility && m_loggedIn) {
- m_ownLocationCrosshair->show();
- m_drawOwnLocationCrosshair = true;
- drawOwnLocationCrosshair(QSize(m_viewPortWidth, m_viewPortHeight));
- } else {
- m_ownLocationCrosshair->hide();
- m_drawOwnLocationCrosshair = false;
- }
+ m_mapView->setScene(scene);
}
void MainWindow::settingsDialogAccepted()
m_email = username;
}
-void MainWindow::setViewPortSize(const QSize &size)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_viewPortWidth = size.width();
- m_viewPortHeight = size.height();
-}
-
void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
{
qDebug() << __PRETTY_FUNCTION__;
m_automaticUpdateLocationDialog->show();
}
-void MainWindow::toggleFullScreen()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if(windowState() == Qt::WindowNoState)
- showFullScreen();
- else
- showNormal();
-}
-
void MainWindow::showErrorInformationBox()
{
qDebug() << __PRETTY_FUNCTION__;
}
}
+void MainWindow::showPanels()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+///< @todo check how this is called and can this method be removed
+
+// if(m_loggedIn) {
+// if(!m_friendsListPanel->isVisible()) {
+// m_friendsListPanel->show();
+// m_friendsListPanelSidebar->show();
+// }
+
+// if(!m_userPanel->isVisible()) {
+// m_userPanel->show();
+// m_userPanelSidebar->show();
+// }
+// }
+}
+
+void MainWindow::startLocationSearch()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ SearchDialog *searchDialog = new SearchDialog();
+ queueDialog(searchDialog);
+}
+
void MainWindow::startLoginProcess()
{
qDebug() << __PRETTY_FUNCTION__;
queueDialog(loginDialog);
}
+void MainWindow::toggleFullScreen()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(windowState() == Qt::WindowNoState)
+ showFullScreen();
+ else
+ showNormal();
+}
+
void MainWindow::toggleProgressIndicator(bool value)
{
qDebug() << __PRETTY_FUNCTION__;
#ifdef Q_WS_MAEMO_5
- setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
+ if(value) {
+ m_progressIndicatorCount++;
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+ } else {
+ if(m_progressIndicatorCount > 0)
+ m_progressIndicatorCount--;
+
+ if(m_progressIndicatorCount == 0)
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ }
#else
Q_UNUSED(value);
#endif // Q_WS_MAEMO_5
}
-void MainWindow::updateItemVisibility(bool show)
+void MainWindow::updateItemVisibility()
{
qDebug() << __PRETTY_FUNCTION__;
-
- if(show) {
- m_friendsListPanel->show();
- m_friendsListPanelSidebar->show();
- m_userPanel->show();
- m_userPanelSidebar->show();
- if(!m_gpsToggleAct->isChecked())
- setOwnLocationCrosshairVisibility(show);
- } else {
- m_friendsListPanel->closePanel();
- m_friendsListPanel->hide();
- m_friendsListPanelSidebar->hide();
- m_userPanel->closePanel();
- m_userPanel->hide();
- m_userPanelSidebar->hide();
- setOwnLocationCrosshairVisibility(false);
- }
+///< @todo can this be removed?
+
+// 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;
}
// 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(reply->error());
- toggleProgressIndicator(false);
+ emit error(ErrorContext::NETWORK, reply->error());
}
}
-