Merge branch 'new_panels_with_context_buttons' of https://vcs.maemo.org/git/situare...
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 25 Aug 2010 10:46:00 +0000 (13:46 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 25 Aug 2010 10:51:22 +0000 (13:51 +0300)
16 files changed:
doc/testing/functionality-tests.doc
src/engine/engine.cpp
src/map/mapscroller.cpp
src/map/mapview.cpp
src/map/mapview.h
src/ui/extendedlistitem.cpp
src/ui/friendlistitem.cpp
src/ui/friendlistitem.h
src/ui/friendlistpanel.cpp
src/ui/listitem.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/routingpanel.cpp
src/ui/userinfopanel.cpp

index 0bac792..3f073b5 100644 (file)
Binary files a/doc/testing/functionality-tests.doc and b/doc/testing/functionality-tests.doc differ
index f764b48..4b7b821 100644 (file)
@@ -502,7 +502,7 @@ void SituareEngine::setAutoCentering(bool enabled)
 
     m_ui->setIndicatorButtonEnabled(enabled);
     m_mapEngine->setAutoCentering(enabled);
-    m_ui->setOwnLocationCrosshairVisibility(!enabled);
+    m_ui->setCrosshairVisibility(!enabled);
 
     if (enabled) {
         setGPS(true);
index 8e04137..f068b74 100644 (file)
@@ -26,7 +26,9 @@
 
 #include "mapscroller.h"
 
+/////////////////////////////////////////////////////////////////////////////
 // scene coordinate interpolator function is not part of this class namespace
+/////////////////////////////////////////////////////////////////////////////
 QVariant sceneCoordinateInterpolator(const SceneCoordinate &start,
                                      const SceneCoordinate &end,
                                      qreal progress);
@@ -49,10 +51,14 @@ void MapScroller::updateCurrentValue(const QVariant &value)
         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));
 }
index c86b93a..30ff47f 100644 (file)
@@ -29,6 +29,7 @@
 #include "coordinates/scenecoordinate.h"
 #include "mapcommon.h"
 #include "mapscroller.h"
+#include "ui/panelcommon.h"
 
 #include "mapview.h"
 
@@ -64,13 +65,47 @@ MapView::MapView(QWidget *parent)
     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()
@@ -81,6 +116,16 @@ 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__;
@@ -88,20 +133,22 @@ void MapView::mouseDoubleClickEvent(QMouseEvent *event)
     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();
     }
@@ -114,20 +161,22 @@ void MapView::mouseMoveEvent(QMouseEvent *event)
     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)
@@ -143,9 +192,9 @@ 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();
@@ -192,8 +241,9 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
 
             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();
         }
@@ -206,7 +256,17 @@ void MapView::resizeEvent(QResizeEvent *event)
 
     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)
@@ -216,6 +276,18 @@ 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)
@@ -235,17 +307,26 @@ 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;
 }
index cd1cc7b..6715fa6 100644 (file)
 #include <QGraphicsView>
 #include <QTime>
 
-class QPropertyAnimation;
+#include "coordinates/scenecoordinate.h"
+
 class QParallelAnimationGroup;
+class QPropertyAnimation;
 
 class MapScroller;
 
-class SceneCoordinate;
-
 #define VALUES 4
 
 /**
@@ -52,6 +52,13 @@ class MapView : public QGraphicsView
     */
     Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
 
+    /**
+    * @brief View shifting
+    *
+    * @property viewShift
+    */
+    Q_PROPERTY(qreal viewShift READ viewShift WRITE setViewShift)
+
 public:
     /**
     * @brief Constructor
@@ -132,6 +139,8 @@ public slots:
     /**
     * @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);
@@ -145,14 +154,33 @@ public slots:
 
 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
@@ -160,17 +188,43 @@ private:
     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.
@@ -200,25 +254,33 @@ signals:
  * 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
index 7e0b859..6d6e1f8 100644 (file)
@@ -44,6 +44,14 @@ ExtendedListItem::ExtendedListItem()
     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__;
@@ -81,17 +89,6 @@ QRect ExtendedListItem::boundingRect(const QString &text)
     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__;
@@ -113,19 +110,22 @@ QRect ExtendedListItem::calculateExpandedTextRect(const QString &text)
     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)
@@ -142,10 +142,10 @@ 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;
 }
index c4491f2..ad48d3a 100644 (file)
@@ -36,44 +36,16 @@ FriendListItem::FriendListItem()
     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)
@@ -113,7 +85,35 @@ void FriendListItem::setDistanceIcon(double value, const QString &unit)
     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"));
 }
index 07ded37..ed16e4a 100644 (file)
@@ -60,6 +60,13 @@ public:
     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
@@ -73,13 +80,6 @@ public:
     */
     void setUserData(User *user);
 
-    /**
-    * @brief Sets avatar image for this item.
-    *
-    * @param image image
-    */
-    void setAvatarImage(const QPixmap &image);
-
 private:
     /**
     * @brief Set distance icon.
index 19f3136..92d656f 100644 (file)
@@ -138,8 +138,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
             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()
index 7c6e320..29600b0 100644 (file)
@@ -48,13 +48,7 @@ public:
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
-    /**
-    * @brief Returns item's title.
-    *
-    * @return item's title
-    */
-    QString title() const;
-
+public:
     /**
     * @brief Sets item's image.
     *
@@ -94,6 +88,13 @@ public:
     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
index 039ba38..a4cf029 100644 (file)
@@ -65,8 +65,9 @@ MainWindow::MainWindow(QWidget *parent)
       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),
@@ -93,8 +94,8 @@ MainWindow::MainWindow(QWidget *parent)
     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);
@@ -140,21 +141,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()
@@ -179,6 +181,23 @@ 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__;
@@ -230,21 +249,6 @@ void MainWindow::buildInformationBox(const QString &message, bool modal)
     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__;
@@ -253,7 +257,7 @@ void MainWindow::buildMap()
 
     buildZoomButtonPanel();
     buildOsmLicense();
-    buildManualLocationCrosshair();
+    buildCrosshair();
     buildFullScreenButton();
     buildIndicatorButtonPanel();
     buildMapScale();
@@ -274,7 +278,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)));
@@ -339,6 +343,12 @@ void MainWindow::buildPanels()
 
     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()
@@ -570,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__;
@@ -769,32 +769,34 @@ void MainWindow::loginUsingCookies()
 
 }
 
-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)
@@ -815,6 +817,23 @@ 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__;
@@ -836,6 +855,18 @@ void MainWindow::saveCookies()
     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__;
@@ -857,18 +888,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__;
@@ -883,13 +902,6 @@ void MainWindow::setUsername(const QString &username)
     m_email = username;
 }
 
-void MainWindow::setViewPortSize(const QSize &size)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_viewPortSize = size;
-}
-
 void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -904,16 +916,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__;
@@ -982,6 +984,16 @@ void MainWindow::startLoginProcess()
     queueDialog(loginDialog);
 }
 
+void MainWindow::toggleFullScreen()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if(windowState() == Qt::WindowNoState)
+        showFullScreen();
+    else
+        showNormal();
+}
+
 void MainWindow::toggleProgressIndicator(bool value)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 6d7d554..5c2776f 100644 (file)
@@ -188,7 +188,7 @@ public slots:
      *
      * @param visible
      */
-    void setOwnLocationCrosshairVisibility(bool visible);
+    void setCrosshairVisibility(bool visible);
 
     /**
      * @brief Sets username to member variable for login dialog
@@ -223,9 +223,9 @@ public slots:
 
 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
@@ -233,9 +233,9 @@ private:
     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
@@ -346,13 +346,6 @@ private 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
@@ -379,6 +372,18 @@ private slots:
     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();
@@ -389,13 +394,6 @@ private slots:
     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();
@@ -534,7 +532,7 @@ signals:
     /**
      * @brief Forwarding signal from MapView to MapEngine
      *
-     * @param coordinate
+     * @param coordinate New center point coordinate
      */
     void mapViewScrolled(const SceneCoordinate &coordinate);
 
@@ -661,14 +659,15 @@ private:
     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
@@ -677,8 +676,6 @@ private:
 
     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
 
index 59e6ab7..a0ebc33 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include <QDebug>
+#include <QVBoxLayout>
 
 #include "panelbase.h"
 
@@ -36,7 +37,7 @@ PanelBase::PanelBase(QWidget *parent)
 
     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,
index 272b8df..deeaa08 100644 (file)
 #ifndef PANELBASE_H
 #define PANELBASE_H
 
-#include <QGridLayout>
 #include <QWidget>
 
+class QVBoxLayout;
+
 class ImageButton;
 
 /**
@@ -70,7 +71,7 @@ signals:
  * 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
index 9662506..7b7f132 100644 (file)
@@ -33,7 +33,7 @@ RoutingPanel::RoutingPanel(QWidget *parent)
                                                         ":/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);
@@ -83,7 +83,7 @@ RoutingPanel::RoutingPanel(QWidget *parent)
             this, SIGNAL(requestSearchLocation()));
 
     // CONTEXT BUTTONS
-    m_contextButtonLayout->addWidget(m_routeButton, 1, 0);
+    m_contextButtonLayout->addWidget(m_routeButton);
 }
 
 void RoutingPanel::clearListsSelections()
index a8ffab5..af8670a 100644 (file)
@@ -86,8 +86,8 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
                                                              ":/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()));