Review, updating functional tests
[situare] / src / map / mapview.h
index ca35767..6715fa6 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "coordinates/scenecoordinate.h"
 
-class QPropertyAnimation;
 class QParallelAnimationGroup;
+class QPropertyAnimation;
 
 class MapScroller;
 
@@ -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
@@ -135,10 +142,8 @@ public slots:
     * Does also shift the center point horizontally, if required.
     *
     * @param coordinate Scene coordinates of the new center point
-    * @param isUserDragAction True if caused by user dragging action. Does not shift the center
-    *                         point if true.
     */
-    void centerToSceneCoordinates(const SceneCoordinate &coordinate, bool isUserDragAction = false);
+    void centerToSceneCoordinates(const SceneCoordinate &coordinate);
 
     /**
     * @brief Set zoom level of the view
@@ -167,6 +172,15 @@ private slots:
 
 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
@@ -174,11 +188,11 @@ private:
     void setViewScale(qreal viewScale);
 
     /**
-    * @brief Toggles the shifting of the center point
+    * @brief Set new view shifting
     *
-    * @param enabled True if shifting is enabled
+    * @param viewShift New shifting amount
     */
-    void toggleCenterShift(bool enabled);
+    void setViewShift(qreal viewShift);
 
     /**
     * @brief Update center shifting value
@@ -190,13 +204,27 @@ private:
     *
     * @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.
@@ -209,9 +237,8 @@ signals:
     *
     * Signal is emitted when view is scrolled.
     * @param coordinate Scene coordinates of the new center point of the view
-    * @param isUserDragAction True if caused by user dragging action
     */
-    void viewScrolled(const SceneCoordinate &coordinate, bool isUserDragAction);
+    void viewScrolled(const SceneCoordinate &coordinate);
 
     /**
     * @brief Signal for informing that zooming animation is finished
@@ -227,26 +254,30 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    bool m_centerShiftEnabled;            ///< Is the center point shifting enabled?
-    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
+    qreal m_centerHorizontalShiftViewPixels;    ///< Center point horizontal shift in the view
+    qreal m_kineticMaxViewDistance;             ///< Maximum kinetic scroll distance in view pixels
 
-    QPoint m_dragMovement[VALUES];        ///< Table of mouse event distances
-    QPoint m_internalScenePosition;       ///< New center position
-    QPoint m_lastMouseEventScenePosition; ///< Previous mouse event position in the scene
-    QPoint m_lastMouseEventViewPosition;  ///< Previous mouse event position in the view
+    QParallelAnimationGroup *m_scrollAndZoomAnimation;  ///< Double click zoom animation
 
-    QPointF m_centerHorizontalShift;      ///< Current amount of center point shifting
+    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
 
-    QParallelAnimationGroup *m_scrollAndZoomAnimation;  ///< Double click zoom animation
-    QPropertyAnimation *m_zoomAnimation;  ///< Zoom animation
+    QPointF m_centerHorizontalShiftPoint;       ///< Current amount of center point shifting
+
+    QPropertyAnimation *m_zoomAnimation;        ///< Zoom animation
+
+    QTime m_time;                               ///< Elapsed time between mouse events
 
-    QTime m_time;                         ///< Elapsed times in mouse events
+    QPropertyAnimation *m_centerShiftAnimation; ///< Animation for shifting the center point
 
     MapScroller *m_scroller;                    ///< Kinetic scroller
     SceneCoordinate m_lastSetScenePosition;     ///< Last center point coordinate set by MapEngine