2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
6 Pekka Nissinen - pekka.nissinen@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #include <QGraphicsView>
29 class QPropertyAnimation;
36 * @brief Map view widget
38 * @author Sami Rämö - sami.ramo (at) ixonos.com
39 * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
41 class MapView : public QGraphicsView
50 Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
56 * @param parent Parent
58 MapView(QWidget *parent = 0);
60 /*******************************************************************************
61 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
62 ******************************************************************************/
65 * @brief Called when view is resized.
67 * @param event resize event
69 void resizeEvent(QResizeEvent *event);
73 * @brief Event handler for mouse move events
75 * Does calculate mouse movement delta from last event position and new view center
76 * based on that delta. Saves current event position for next round. Emits viewScrolled
77 * signal and doesn't actually scroll the view.
78 * @param event Mouse event
80 void mouseMoveEvent(QMouseEvent *event);
83 * @brief Event handler for mouse press events
85 * Saves inial values for mouse and scene location for dragging view.
86 * @param event Mouse event
88 void mousePressEvent(QMouseEvent *event);
90 void mouseReleaseEvent(QMouseEvent *event);
92 /*******************************************************************************
93 * MEMBER FUNCTIONS AND SLOTS
94 ******************************************************************************/
97 * @brief Slot for centering view to new location
99 * @param sceneCoordinate Scene coordinates of the new center point
101 void centerToSceneCoordinates(QPoint sceneCoordinate);
104 * @brief Set zoom level of the view
106 * @param zoomLevel Zoom level
108 void setZoomLevel(int zoomLevel);
112 * @brief Set new view scale
114 * @param viewScale New scaling factor
116 void setViewScale(qreal viewScale);
119 * @brief Get current view scale
121 * @return Current view scaling factor
125 /*******************************************************************************
127 ******************************************************************************/
130 * @brief Signal for view resize events.
132 * Signal is emitted when view has been resized.
133 * @param size view size
135 void viewResized(const QSize &size);
138 * @brief Signal for view scroll events
140 * Signal is emitted when view is scrolled.
141 * @param sceneCoordinate Scene coordinates of the new center point of the view
143 void viewScrolled(QPoint sceneCoordinate);
146 * @brief Signal for informing that zooming animation is finished
148 void viewZoomFinished();
150 /*******************************************************************************
152 ******************************************************************************/
154 int m_dragTime[VALUES];
158 QPoint m_dragMovement[VALUES];
159 QPoint m_mouseLastScenePosition; ///< Previous mouse event position
160 QPoint m_mouseLastViewPosition;
161 QPoint m_scenePosition; ///< New center position
163 QPropertyAnimation *m_zoomAnimation; ///< Zoom animation
167 MapScroller *m_scroller;