m_ui->setIndicatorButtonEnabled(enabled);
m_mapEngine->setAutoCentering(enabled);
- m_ui->setOwnLocationCrosshairVisibility(!enabled);
+ m_ui->setCrosshairVisibility(!enabled);
if (enabled) {
setGPS(true);
#include "mapscroller.h"
+/////////////////////////////////////////////////////////////////////////////
// scene coordinate interpolator function is not part of this class namespace
+/////////////////////////////////////////////////////////////////////////////
QVariant sceneCoordinateInterpolator(const SceneCoordinate &start,
const SceneCoordinate &end,
qreal progress);
emit coordinateUpdated(value.value<SceneCoordinate>());
}
+/////////////////////////////////////////////////////////////////////////////
// scene coordinate interpolator function is not part of this class namespace
+/////////////////////////////////////////////////////////////////////////////
QVariant sceneCoordinateInterpolator(const SceneCoordinate &start,
const SceneCoordinate &end,
qreal progress)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
return SceneCoordinate(start + progress * (end - start));
}
#include "coordinates/scenecoordinate.h"
#include "mapcommon.h"
#include "mapscroller.h"
+#include "ui/panelcommon.h"
#include "mapview.h"
m_scrollAndZoomAnimation->addAnimation(m_zoomAnimation);
connect(m_scrollAndZoomAnimation, SIGNAL(finished()),
this, SLOT(doubleTapZoomFinished()));
+
+ m_centerShiftAnimation = new QPropertyAnimation(this, "viewShift", this);
+ if (m_centerShiftAnimation) {
+ m_centerShiftAnimation->setStartValue(0.0);
+ m_centerShiftAnimation->setDuration(ZOOM_TIME_MS);
+ }
+}
+
+MapView::~MapView()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_scrollAndZoomAnimation->removeAnimation(m_scroller);
+ delete m_scrollAndZoomAnimation;
+}
+
+QPointF MapView::center() const
+{
+ return mapToScene(m_viewCenterPoint) - m_centerHorizontalShiftPoint;
}
void MapView::centerToSceneCoordinates(const SceneCoordinate &coordinate)
{
qDebug() << __PRETTY_FUNCTION__ << "coordinate" << coordinate;
- centerOn(coordinate.toPointF());
+ QPointF target = coordinate.toPointF();
+ m_lastSetScenePosition = coordinate;
+
+ target += m_centerHorizontalShiftPoint;
+
+ centerOn(target);
+}
+
+void MapView::disableCenterShift()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_centerShiftAnimation) {
+ m_centerShiftAnimation->setDirection(QAbstractAnimation::Backward);
+ m_centerShiftAnimation->start();
+ }
}
void MapView::doubleTapZoomFinished()
emit zoomIn();
}
+void MapView::enableCenterShift()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_centerShiftAnimation) {
+ m_centerShiftAnimation->setDirection(QAbstractAnimation::Forward);
+ m_centerShiftAnimation->start();
+ }
+}
+
void MapView::mouseDoubleClickEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
if (m_zoomLevel + 1 <= OSM_MAX_ZOOM_LEVEL) {
QPoint pressPosition = mapToScene(event->pos()).toPoint();
QPoint viewCenterPosition = mapToScene(width() / 2 - 1, height() / 2 - 1).toPoint();
- QPoint zoomPosition = viewCenterPosition - ((viewCenterPosition - pressPosition) / 2);
+ QPoint zoomPosition = viewCenterPosition - ((viewCenterPosition - pressPosition) / 2)
+ - m_centerHorizontalShiftPoint.toPoint() / 2;
m_scrollAndZoomAnimation->stop();
m_doubleTapZoomRunning = true;
m_scroller->setEasingCurve(QEasingCurve::Linear);
m_scroller->setDuration(ZOOM_TIME_MS);
- m_scroller->setStartValue(SceneCoordinate(m_scenePosition.x(), m_scenePosition.y()));
+ QPointF centerPoint = center();
+ m_scroller->setStartValue(SceneCoordinate(centerPoint.x(), centerPoint.y()));
m_scroller->setEndValue(SceneCoordinate(zoomPosition.x(), zoomPosition.y()));
m_zoomAnimation->setEasingCurve(QEasingCurve::InQuad);
m_zoomAnimation->setDuration(ZOOM_TIME_MS);
m_zoomAnimation->setStartValue(viewScale());
- m_zoomAnimation->setEndValue(pow(2, m_zoomLevel+1 - OSM_MAX_ZOOM_LEVEL));
+ m_zoomAnimation->setEndValue(pow(2, m_zoomLevel + 1 - OSM_MAX_ZOOM_LEVEL));
m_scrollAndZoomAnimation->start();
}
if (m_doubleTapZoomRunning)
return;
- m_scenePosition += m_mouseLastScenePosition - mapToScene(event->pos()).toPoint();
+ m_internalScenePosition += m_lastMouseEventScenePosition - mapToScene(event->pos()).toPoint();
if (m_index >= VALUES)
m_index = 0;
- m_dragMovement[m_index] = m_mouseLastViewPosition - event->pos();
+ m_dragMovement[m_index] = m_lastMouseEventViewPosition - event->pos();
m_dragTime[m_index] = m_time.elapsed();
m_time.start();
m_index++;
- emit viewScrolled(SceneCoordinate(m_scenePosition.x(), m_scenePosition.y()));
+ QPointF viewCenterPoint = m_internalScenePosition - m_centerHorizontalShiftPoint;
- m_mouseLastScenePosition = mapToScene(event->pos()).toPoint();
- m_mouseLastViewPosition = event->pos();
+ emit viewScrolled(SceneCoordinate(viewCenterPoint.x(), viewCenterPoint.y()));
+
+ m_lastMouseEventScenePosition = mapToScene(event->pos()).toPoint();
+ m_lastMouseEventViewPosition = event->pos();
}
void MapView::mousePressEvent(QMouseEvent *event)
QGraphicsView::mousePressEvent(event);
- m_mouseLastScenePosition = mapToScene(event->pos()).toPoint();
- m_mouseLastViewPosition = event->pos();
- m_scenePosition = mapToScene(width() / 2 - 1, height() / 2 - 1).toPoint();
+ m_lastMouseEventScenePosition = mapToScene(event->pos()).toPoint();
+ m_lastMouseEventViewPosition = event->pos();
+ m_internalScenePosition = mapToScene(width() / 2 - 1, height() / 2 - 1).toPoint();
for (int i = 0; i < VALUES; i++) {
m_dragMovement[i] = QPoint();
m_scroller->setEasingCurve(QEasingCurve::OutCirc);
m_scroller->setDuration(KINETIC_SCROLL_TIME_MS);
- m_scroller->setStartValue(SceneCoordinate(m_scenePosition.x(), m_scenePosition.y()));
- QPointF endValue = QPointF(m_scenePosition) + effectSceneDistance;
+ QPointF centerPoint = center();
+ m_scroller->setStartValue(SceneCoordinate(centerPoint.x(), centerPoint.y()));
+ QPointF endValue = centerPoint + effectSceneDistance;
m_scroller->setEndValue(SceneCoordinate(endValue.x(), endValue.y()));
m_scroller->start();
}
m_kineticMaxViewDistance = qMax(width(), height()) * KINETIC_MAX_VIEW_DISTANCE_FACTOR;
+ m_viewCenterPoint.setX(event->size().width() / 2);
+ m_viewCenterPoint.setY(event->size().height() / 2);
+
emit viewResized(event->size());
+
+ if (m_centerShiftAnimation) {
+ int mapVisibleWidth = event->size().width() - PANEL_WIDTH - PANEL_BAR_WIDTH;
+ int shiftFromMiddle = m_viewCenterPoint.x() - (mapVisibleWidth / 2);
+ m_centerShiftAnimation->setEndValue(shiftFromMiddle);
+ updateCenterShift();
+ }
}
void MapView::setViewScale(qreal viewScale)
QTransform transform;
transform.scale(viewScale, viewScale);
setTransform(transform);
+
+ updateCenterShift();
+}
+
+void MapView::setViewShift(qreal viewShift)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_centerHorizontalShiftViewPixels = viewShift;
+ emit horizontalShiftingChanged(m_centerHorizontalShiftViewPixels);
+
+ updateCenterShift();
}
void MapView::setZoomLevel(int zoomLevel)
}
}
-qreal MapView::viewScale()
+void MapView::updateCenterShift()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_centerHorizontalShiftPoint = QPointF(m_centerHorizontalShiftViewPixels * (1.0 / viewScale()),
+ 0);
+
+ centerToSceneCoordinates(m_lastSetScenePosition);
+}
+
+qreal MapView::viewScale() const
{
qDebug() << __PRETTY_FUNCTION__;
return transform().m11();
}
-MapView::~MapView()
+qreal MapView::viewShift() const
{
qDebug() << __PRETTY_FUNCTION__;
- m_scrollAndZoomAnimation->removeAnimation(m_scroller);
- delete m_scrollAndZoomAnimation;
+ return m_centerHorizontalShiftViewPixels;
}
#include <QGraphicsView>
#include <QTime>
-class QPropertyAnimation;
+#include "coordinates/scenecoordinate.h"
+
class QParallelAnimationGroup;
+class QPropertyAnimation;
class MapScroller;
-class SceneCoordinate;
-
#define VALUES 4
/**
*/
Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
+ /**
+ * @brief View shifting
+ *
+ * @property viewShift
+ */
+ Q_PROPERTY(qreal viewShift READ viewShift WRITE setViewShift)
+
public:
/**
* @brief Constructor
/**
* @brief Slot for centering view to new location
*
+ * Does also shift the center point horizontally, if required.
+ *
* @param coordinate Scene coordinates of the new center point
*/
void centerToSceneCoordinates(const SceneCoordinate &coordinate);
private slots:
/**
+ * @brief Disables shifting of the center point
+ */
+ void disableCenterShift();
+
+ /**
* @brief Double tap zoom finished.
*
* Disables double tap zoom flag and emits zoomIn signal.
*/
void doubleTapZoomFinished();
+ /**
+ * @brief Enables shifting of the center point
+ */
+ void enableCenterShift();
+
private:
/**
+ * @brief Returns the point which is considered by user as the visible center point
+ *
+ * Differs from view's center point when panel is open and view center point is shifted.
+ *
+ * @returns Center point
+ */
+ QPointF center() const;
+
+ /**
* @brief Set new view scale
*
* @param viewScale New scaling factor
void setViewScale(qreal viewScale);
/**
+ * @brief Set new view shifting
+ *
+ * @param viewShift New shifting amount
+ */
+ void setViewShift(qreal viewShift);
+
+ /**
+ * @brief Update center shifting value
+ */
+ void updateCenterShift();
+
+ /**
* @brief Get current view scale
*
* @return Current view scaling factor
*/
- qreal viewScale();
+ qreal viewScale() const;
+
+ /**
+ * @brief Get current view shifting
+ *
+ * @return Current view shifting amount
+ */
+ qreal viewShift() const;
/*******************************************************************************
* SIGNALS
******************************************************************************/
signals:
/**
+ * @brief Emitted when map center point shiftin is changed
+ *
+ * @param shifting New shifting value
+ */
+ void horizontalShiftingChanged(int shifting);
+
+ /**
* @brief Signal for view resize events.
*
* Signal is emitted when view has been resized.
* DATA MEMBERS
******************************************************************************/
private:
- bool m_doubleTapZoomRunning; ///< Double tap zoom running flag
+ bool m_doubleTapZoomRunning; ///< Double tap zoom running flag
- int m_dragTime[VALUES]; ///< Table of mouse event durations
- int m_index; ///< Index of mouse event values tables
- int m_zoomLevel; ///< Current zoom level
+ int m_dragTime[VALUES]; ///< Table of mouse event durations
+ int m_index; ///< Current index of mouse event values table
+ int m_zoomLevel; ///< Current zoom level
- qreal m_kineticMaxViewDistance; ///< Maximum kinetic scroll distance in view pixels
-
- QPoint m_dragMovement[VALUES]; ///< Table of mouse event distances
- QPoint m_mouseLastScenePosition; ///< Previous mouse event position in the scene
- QPoint m_mouseLastViewPosition; ///< Previous mouse event position in the view
- QPoint m_scenePosition; ///< New center position
+ qreal m_centerHorizontalShiftViewPixels; ///< Center point horizontal shift in the view
+ qreal m_kineticMaxViewDistance; ///< Maximum kinetic scroll distance in view pixels
QParallelAnimationGroup *m_scrollAndZoomAnimation; ///< Double click zoom animation
- QPropertyAnimation *m_zoomAnimation; ///< Zoom animation
- QTime m_time; ///< Elapsed times in mouse events
+ QPoint m_dragMovement[VALUES]; ///< Table of mouse event distances
+ QPoint m_internalScenePosition; ///< New center position (used for dragging)
+ QPoint m_lastMouseEventScenePosition; ///< Previous mouse event position in the scene
+ QPoint m_lastMouseEventViewPosition; ///< Previous mouse event position in the view
+ QPoint m_viewCenterPoint; ///< Center point of the MapView
+
+ QPointF m_centerHorizontalShiftPoint; ///< Current amount of center point shifting
+
+ QPropertyAnimation *m_zoomAnimation; ///< Zoom animation
+
+ QTime m_time; ///< Elapsed time between mouse events
+
+ QPropertyAnimation *m_centerShiftAnimation; ///< Animation for shifting the center point
- MapScroller *m_scroller; ///< Kinetic scroller
+ MapScroller *m_scroller; ///< Kinetic scroller
+ SceneCoordinate m_lastSetScenePosition; ///< Last center point coordinate set by MapEngine
};
#endif // MAPVIEW_H
setData(SUBITEM_STORE_INDEX, qVariantFromValue((void *) m_subItemStoreList));
}
+ExtendedListItem::~ExtendedListItem()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ clearSubItems();
+ delete m_subItemStoreList;
+}
+
void ExtendedListItem::addSubItem(const QString &text, const QPixmap &icon)
{
qDebug() << __PRETTY_FUNCTION__;
return textRect;
}
-void ExtendedListItem::clearSubItems()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- qDeleteAll(m_subItemStoreList->begin(), m_subItemStoreList->end());
- m_subItemStoreList->clear();
-
- m_expandedHeight = ITEM_MIN_HEIGHT;
- m_normalHeight = ITEM_MIN_HEIGHT;
-}
-
QRect ExtendedListItem::calculateExpandedTextRect(const QString &text)
{
qDebug() << __PRETTY_FUNCTION__;
return expandedTextRect;
}
-void ExtendedListItem::setSubitemTextWidth(int width)
+void ExtendedListItem::clearSubItems()
{
qDebug() << __PRETTY_FUNCTION__;
- m_subItemTextWidth = width;
+ qDeleteAll(m_subItemStoreList->begin(), m_subItemStoreList->end());
+ m_subItemStoreList->clear();
+
+ m_expandedHeight = ITEM_MIN_HEIGHT;
+ m_normalHeight = ITEM_MIN_HEIGHT;
}
-bool ExtendedListItem::toggleSelection()
+void ExtendedListItem::setSubitemTextWidth(int width)
{
qDebug() << __PRETTY_FUNCTION__;
- setSelected(!m_selected);
- return m_selected;
+ m_subItemTextWidth = width;
}
void ExtendedListItem::setSelected(bool selected)
setData(ITEM_SIZE_HINT_INDEX, QSize(ITEM_WIDTH, m_normalHeight));
}
-ExtendedListItem::~ExtendedListItem()
+bool ExtendedListItem::toggleSelection()
{
qDebug() << __PRETTY_FUNCTION__;
- clearSubItems();
- delete m_subItemStoreList;
+ setSelected(!m_selected);
+ return m_selected;
}
setSubitemTextWidth(SUBITEM_TEXT_MAX_WIDTH);
}
-GeoCoordinate FriendListItem::coordinates() const
+FriendListItem::~FriendListItem()
{
qDebug() << __PRETTY_FUNCTION__;
-
- return m_coordinates;
}
-void FriendListItem::setUserData(User *user)
+GeoCoordinate FriendListItem::coordinates() const
{
qDebug() << __PRETTY_FUNCTION__;
- QString unit;
- double value;
- user->distance(value, unit);
- QString distanceText = QString::number(value) + " " + unit;
- setData(DISTANCE_TEXT_DISPLAY_INDEX, distanceText);
- setDistanceIcon(value, unit);
-
- //Dummy value to get painter font metrics.
- QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT);
- QPainter painter(&p);
- painter.setFont(NOKIA_FONT_SMALL);
- QFontMetrics distanceTextFontMetrics = painter.fontMetrics();
- QRect distanceRect = distanceTextFontMetrics.boundingRect(distanceText);
-
- setData(DISTANCE_SIZE_HINT_INDEX, distanceRect);
- setTitle(shortenText(user->name(), NAME_TEXT_MAX_WIDTH - distanceRect.width() + MARGIN,
- ListItem::TEXT_SIZE_NORMAL));
- setCoordinates(user->coordinates());
-
- if (!user->profileImage().isNull())
- setImage(user->profileImage());
-
- clearSubItems();
-
- addSubItem(user->note(), QPixmap(":/res/images/envelope.png"));
- addSubItem(user->address(), QPixmap(":/res/images/compass.png"));
- addSubItem(user->timestamp(), QPixmap(":/res/images/clock.png"));
+ return m_coordinates;
}
void FriendListItem::setAvatarImage(const QPixmap &image)
setData(DISTANCE_IMAGE_INDEX, distanceImage);
}
-FriendListItem::~FriendListItem()
+void FriendListItem::setUserData(User *user)
{
qDebug() << __PRETTY_FUNCTION__;
+
+ QString unit;
+ double value;
+ user->distance(value, unit);
+ QString distanceText = QString::number(value) + " " + unit;
+ setData(DISTANCE_TEXT_DISPLAY_INDEX, distanceText);
+ setDistanceIcon(value, unit);
+
+ //Dummy value to get painter font metrics.
+ QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT);
+ QPainter painter(&p);
+ painter.setFont(NOKIA_FONT_SMALL);
+ QFontMetrics distanceTextFontMetrics = painter.fontMetrics();
+ QRect distanceRect = distanceTextFontMetrics.boundingRect(distanceText);
+
+ setData(DISTANCE_SIZE_HINT_INDEX, distanceRect);
+ setTitle(shortenText(user->name(), NAME_TEXT_MAX_WIDTH - distanceRect.width() + MARGIN,
+ ListItem::TEXT_SIZE_NORMAL));
+ setCoordinates(user->coordinates());
+
+ if (!user->profileImage().isNull())
+ setImage(user->profileImage());
+
+ clearSubItems();
+
+ addSubItem(user->note(), QPixmap(":/res/images/envelope.png"));
+ addSubItem(user->address(), QPixmap(":/res/images/compass.png"));
+ addSubItem(user->timestamp(), QPixmap(":/res/images/clock.png"));
}
GeoCoordinate coordinates() const;
/**
+ * @brief Sets avatar image for this item.
+ *
+ * @param image image
+ */
+ void setAvatarImage(const QPixmap &image);
+
+ /**
* @brief Sets item's coordinates.
*
* @param coordinates GeoCoordinate
*/
void setUserData(User *user);
- /**
- * @brief Sets avatar image for this item.
- *
- * @param image image
- */
- void setAvatarImage(const QPixmap &image);
-
private:
/**
* @brief Set distance icon.
this, SLOT(topmostWindowChanged(bool)));
// CONTEXT BUTTONS
- m_contextButtonLayout->addWidget(m_routeButton, 0, 0);
- m_contextButtonLayout->addWidget(m_clearGroupFilteringButton, 1, 0);
+ m_contextButtonLayout->addWidget(m_routeButton);
+ m_contextButtonLayout->addWidget(m_clearGroupFilteringButton);
}
void FriendListPanel::anyPanelClosed()
/******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
- /**
- * @brief Returns item's title.
- *
- * @return item's title
- */
- QString title() const;
-
+public:
/**
* @brief Sets item's image.
*
QString shortenText(const QString &text, int textWidth, TextSize textSize);
/**
+ * @brief Returns item's title.
+ *
+ * @return item's title
+ */
+ QString title() const;
+
+ /**
* @brief Toggles selection.
*
* @return true if selection was toggled, false otherwise
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),
if (m_fullScreenButton) {
m_tabbedPanel->stackUnder(m_fullScreenButton);
}
- m_ownLocationCrosshair->stackUnder(m_tabbedPanel);
- m_zoomButtonPanel->stackUnder(m_ownLocationCrosshair);
+ m_crosshair->stackUnder(m_tabbedPanel);
+ 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()));
}
void MainWindow::buildRoutingPanel()
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__;
*
* @param visible
*/
- void setOwnLocationCrosshairVisibility(bool visible);
+ void setCrosshairVisibility(bool visible);
/**
* @brief Sets username to member variable for login dialog
private:
/**
- * @brief Build fullscreen toggle button and connect slots
+ * @brief Build manual location setting cross hair and connect slots
*/
- void buildFullScreenButton();
+ void buildCrosshair();
/**
* @brief Build friend list panel and connect slots
void buildFriendListPanel();
/**
- * @brief Build manual location setting cross hair and connect slots
+ * @brief Build fullscreen toggle button and connect slots
*/
- void buildManualLocationCrosshair();
+ void buildFullScreenButton();
/**
* @brief Build map and connect slots
void drawOsmLicense(const QSize &size);
/**
- * @brief Slot for drawing the own location crosshair
- *
- * @param size Size of the screen
- */
- void drawOwnLocationCrosshair(const QSize &size);
-
- /**
* @brief Slot to intercept signal when error dialog/information note is processed
*
* @param status Status of the dialog
void loadDone(bool done);
/**
+ * @brief Called when map center point horizontal shifting is changed
+ *
+ * @param shifting New shifting value
+ */
+ void mapCenterHorizontalShiftingChanged(int shifting);
+
+ /**
+ * @brief Move the crosshair
+ */
+ void moveCrosshair();
+
+ /**
* @brief Slot to save cookies to settings
*/
void saveCookies();
void settingsDialogAccepted();
/**
- * @brief Set correnct view port size to datamembers
- *
- * @param size Size of the screen
- */
- void setViewPortSize(const QSize &size);
-
- /**
* @brief Start location search (open search dialog)
*/
void startLocationSearch();
/**
* @brief Forwarding signal from MapView to MapEngine
*
- * @param coordinate
+ * @param coordinate New center point coordinate
*/
void mapViewScrolled(const SceneCoordinate &coordinate);
bool m_loggedIn; ///< Indicates login state
bool m_refresh; ///< Indicates when webpage is refreshed
+ int m_mapCenterHorizontalShifting; ///< Amount of map center point horizontal shifting
int m_progressIndicatorCount; ///< Indicates the number of progress indicator calls
QAction *m_gpsToggleAct; ///< Action to trigger gps toggle
QAction *m_loginAct; ///< Action to Login/Logout
QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
+ QLabel *m_crosshair; ///< Label for center point crosshair
QLabel *m_osmLicense; ///< Label for Open Street Map license
- QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
QList<QDialog *> m_error_queue; ///< QList type error dialog queue
QList<QDialog *> m_queue; ///< QList type dialog queue
QMessageBox *m_automaticUpdateLocationDialog; ///< Automatic update location dialog
- QSize m_viewPortSize; ///< Size of the viewport
-
QString m_email; ///< Placeholder for email
QString m_password; ///< Placeholder for password
*/
#include <QDebug>
+#include <QVBoxLayout>
#include "panelbase.h"
m_contextButtons = new QWidget;
- m_contextButtonLayout = new QGridLayout;
+ m_contextButtonLayout = new QVBoxLayout;
m_contextButtonLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
CONTEXT_BUTTON_MARGIN_TOP,
CONTEXT_BUTTON_MARGIN_RIGHT,
#ifndef PANELBASE_H
#define PANELBASE_H
-#include <QGridLayout>
#include <QWidget>
+class QVBoxLayout;
+
class ImageButton;
/**
* DATA MEMBERS
******************************************************************************/
protected:
- QGridLayout *m_contextButtonLayout; ///< Layout for context buttons
+ QVBoxLayout *m_contextButtonLayout; ///< Layout for context buttons
private:
QWidget *m_contextButtons; ///< Widget for context buttons
":/res/images/search_s.png",
"", this);
- m_contextButtonLayout->addWidget(searchLocationButton, 0, 0);
+ m_contextButtonLayout->addWidget(searchLocationButton);
m_routeButton = new ImageButton(":res/images/route_to_location.png",
":res/images/route_to_location_s.png", "", this);
this, SIGNAL(requestSearchLocation()));
// CONTEXT BUTTONS
- m_contextButtonLayout->addWidget(m_routeButton, 1, 0);
+ m_contextButtonLayout->addWidget(m_routeButton);
}
void RoutingPanel::clearListsSelections()
":/res/images/send_position_s.png",
"", this);
- m_contextButtonLayout->addWidget(updateFriendsButton, 0, 0);
- m_contextButtonLayout->addWidget(updateStatusMessageButton, 1, 0);
+ m_contextButtonLayout->addWidget(updateFriendsButton);
+ m_contextButtonLayout->addWidget(updateStatusMessageButton);
connect(updateFriendsButton, SIGNAL(clicked()),
this, SIGNAL(refreshUserData()));