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>
+///< @todo sort
#include "facebookservice/facebookauthentication.h"
#include "map/mapcommon.h"
#include "map/mapview.h"
#include "error.h"
#include "friendlistpanel.h"
#include "fullscreenbutton.h"
-#include "indicatorbutton.h"
+#include "indicatorbuttonpanel.h"
+#include "locationsearchpanel.h"
#include "logindialog.h"
#include "mapscale.h"
#include "panelcommon.h"
+#include "routingpanel.h"
#include "tabbedpanel.h"
#include "searchdialog.h"
#include "settingsdialog.h"
m_errorShown(false),
m_loggedIn(false),
m_refresh(false),
+ m_mapCenterHorizontalShifting(0),
m_progressIndicatorCount(0),
- m_ownLocationCrosshair(0),
- m_email(),
+ m_crosshair(0),
+ m_email(), ///< @todo WTF?!?!?!?
m_password(),
m_webView(0),
m_fullScreenButton(0),
- m_indicatorButton(0),
+ m_indicatorButtonPanel(0),
m_mapScale(0),
m_cookieJar(0)
{
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_indicatorButton->stackUnder(m_ownLocationCrosshair);
- m_mapScale->stackUnder(m_indicatorButton);
+ 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);
m_automaticUpdateLocationDialog->deleteLater();
}
-void MainWindow::buildFullScreenButton()
+void MainWindow::buildCrosshair()
{
qDebug() << __PRETTY_FUNCTION__;
-#ifdef Q_WS_MAEMO_5
- m_fullScreenButton = new FullScreenButton(this);
- 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()
m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
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&)));
+}
+
+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::buildIndicatorButton()
+void MainWindow::buildIndicatorButtonPanel()
{
qDebug() << __PRETTY_FUNCTION__;
- m_indicatorButton = new IndicatorButton(this);
+ m_indicatorButtonPanel = new IndicatorButtonPanel(this);
- connect(m_indicatorButton, SIGNAL(autoCenteringTriggered(bool)),
+ connect(m_indicatorButtonPanel, SIGNAL(autoCenteringTriggered(bool)),
this, SIGNAL(autoCenteringTriggered(bool)));
connect(m_mapView, SIGNAL(viewResized(QSize)),
- m_indicatorButton, SLOT(screenResized(QSize)));
+ m_indicatorButtonPanel, SLOT(screenResized(QSize)));
+
+ connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
+ m_indicatorButtonPanel, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)));
- connect(m_indicatorButton, SIGNAL(draggingModeTriggered()),
+ connect(m_indicatorButtonPanel, SIGNAL(draggingModeTriggered()),
this, SIGNAL(draggingModeTriggered()));
}
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();
- buildIndicatorButton();
+ buildIndicatorButtonPanel();
buildMapScale();
connect(m_mapView, SIGNAL(viewScrolled(SceneCoordinate)),
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)));
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"));
+ m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/search.png"));
+ m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
connect(m_mapView, SIGNAL(viewResized(QSize)),
m_tabbedPanel, SLOT(resizePanel(QSize)));
+
+ connect(m_friendsListPanel, SIGNAL(openPanelRequested(QWidget*)),
+ m_tabbedPanel, SLOT(openPanel(QWidget*)));
+
+ connect(m_routingPanel, SIGNAL(openPanelRequested(QWidget*)),
+ m_tabbedPanel, SLOT(openPanel(QWidget*)));
+
+ connect(m_tabbedPanel, SIGNAL(panelClosed()),
+ m_friendsListPanel, SLOT(anyPanelClosed()));
+
+ connect(m_tabbedPanel, SIGNAL(panelOpened()),
+ m_friendsListPanel, SLOT(anyPanelOpened()));
+
+ connect(m_tabbedPanel, SIGNAL(panelClosed()),
+ m_routingPanel, SLOT(clearListsSelections()));
+
+ 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()
m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
- this, SIGNAL(findUser(GeoCoordinate)));
+ this, SIGNAL(centerToCoordinates(GeoCoordinate)));
connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
this, SIGNAL(requestReverseGeo()));
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"));
}
{
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)
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);
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__;
}
-void MainWindow::openSettingsDialog()
+void MainWindow::mapCenterHorizontalShiftingChanged(int shifting)
{
- qDebug() << __PRETTY_FUNCTION__;
+ m_mapCenterHorizontalShifting = shifting;
+ moveCrosshair();
+}
- SettingsDialog *settingsDialog = new SettingsDialog(this);
- settingsDialog->enableSituareSettings((m_loggedIn && m_gpsToggleAct->isChecked()));
- 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::setGPSButtonEnabled(bool enabled)
+void MainWindow::setCrosshairVisibility(bool visibility)
{
qDebug() << __PRETTY_FUNCTION__;
- m_gpsToggleAct->setChecked(enabled);
+ if (visibility) {
+ m_crosshair->show();
+ moveCrosshair();
+ } else {
+ m_crosshair->hide();
+ }
}
-void MainWindow::setIndicatorButtonEnabled(bool enabled)
+void MainWindow::setGPSButtonEnabled(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
- m_indicatorButton->setChecked(enabled);
-
+ m_gpsToggleAct->setChecked(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_ownLocationCrosshair->show();
- drawOwnLocationCrosshair(m_viewPortSize);
- } else {
- m_ownLocationCrosshair->hide();
- }
+ m_mapView->setScene(scene);
}
void MainWindow::settingsDialogAccepted()
m_email = username;
}
-void MainWindow::setViewPortSize(const QSize &size)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- m_viewPortSize = size;
-}
-
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__;
{
qDebug() << __PRETTY_FUNCTION__;
- drawFullScreenButton(m_viewPortSize);
+///< @todo check how this is called and can this method be removed
// if(m_loggedIn) {
// if(!m_friendsListPanel->isVisible()) {
queueDialog(loginDialog);
}
+void MainWindow::toggleFullScreen()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(windowState() == Qt::WindowNoState)
+ showFullScreen();
+ else
+ showNormal();
+}
+
void MainWindow::toggleProgressIndicator(bool value)
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
+///< @todo can this be removed?
+
// if(!m_loggedIn) {
// m_friendsListPanel->closePanel();
// m_friendsListPanel->hide();