m_errorShown(false),
m_loggedIn(false),
m_refresh(false),
+ m_mapCenterHorizontalShifting(0),
m_progressIndicatorCount(0),
- m_ownLocationCrosshair(0),
+ m_crosshair(0),
m_email(), ///< @todo WTF?!?!?!?
m_password(),
m_webView(0),
setWindowTitle(tr("Situare"));
// set stacking order of widgets (from top to bottom)
- // if the fullscreen button exists, then it is the topmost one, otherwise the tabbed panel is
+ // m_tabbedPanel is the topmost one
if (m_fullScreenButton) {
- m_tabbedPanel->stackUnder(m_fullScreenButton);
+ m_fullScreenButton->stackUnder(m_tabbedPanel);
+ m_crosshair->stackUnder(m_fullScreenButton);
+ } else {
+ m_crosshair->stackUnder(m_tabbedPanel);
}
- m_ownLocationCrosshair->stackUnder(m_tabbedPanel);
- m_zoomButtonPanel->stackUnder(m_ownLocationCrosshair);
+ m_zoomButtonPanel->stackUnder(m_crosshair);
m_indicatorButtonPanel->stackUnder(m_zoomButtonPanel);
m_osmLicense->stackUnder(m_indicatorButtonPanel);
m_mapScale->stackUnder(m_osmLicense);
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()
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__;
queueDialog(msgBox);
}
-void MainWindow::buildManualLocationCrosshair()
-{
- 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);
-
- connect(m_mapView, SIGNAL(viewResized(QSize)),
- this, SLOT(drawOwnLocationCrosshair(QSize)));
-}
-
void MainWindow::buildMap()
{
qDebug() << __PRETTY_FUNCTION__;
buildZoomButtonPanel();
buildOsmLicense();
- buildManualLocationCrosshair();
+ buildCrosshair();
buildFullScreenButton();
buildIndicatorButtonPanel();
buildMapScale();
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_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()
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(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(m_routingPanel, SIGNAL(requestSearchLocation()),
this, SLOT(startLocationSearch()));
+
+ connect(m_routingPanel, SIGNAL(clearRoute()),
+ this, SIGNAL(clearRoute()));
}
void MainWindow::buildUserInfoPanel()
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::setCrosshairVisibility(bool visibility)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (visibility) {
+ m_crosshair->show();
+ moveCrosshair();
+ } else {
+ m_crosshair->hide();
+ }
+}
+
void MainWindow::setGPSButtonEnabled(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
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__;
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__;
queueDialog(loginDialog);
}
+void MainWindow::toggleFullScreen()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(windowState() == Qt::WindowNoState)
+ showFullScreen();
+ else
+ showNormal();
+}
+
void MainWindow::toggleProgressIndicator(bool value)
{
qDebug() << __PRETTY_FUNCTION__;