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>
27 #include <QPropertyAnimation>
30 * @brief Map view widget
32 * @author Sami Rämö - sami.ramo (at) ixonos.com
33 * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
35 class MapView : public QGraphicsView
44 Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
50 * @param parent Parent
52 MapView(QWidget *parent = 0);
54 /*******************************************************************************
55 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
56 ******************************************************************************/
59 * @brief Called when view is resized.
61 * @param event resize event
63 void resizeEvent(QResizeEvent *event);
67 * @brief Event handler for mouse move events
69 * Does calculate mouse movement delta from last event position and new view center
70 * based on that delta. Saves current event position for next round. Emits viewScrolled
71 * signal and doesn't actually scroll the view.
72 * @param event Mouse event
74 void mouseMoveEvent(QMouseEvent *event);
77 * @brief Event handler for mouse press events
79 * Saves inial values for mouse and scene location for dragging view.
80 * @param event Mouse event
82 void mousePressEvent(QMouseEvent *event);
84 /*******************************************************************************
85 * MEMBER FUNCTIONS AND SLOTS
86 ******************************************************************************/
89 * @brief Slot for centering view to new location
91 * @param sceneCoordinate Scene coordinates of the new center point
93 void centerToSceneCoordinates(QPoint sceneCoordinate);
96 * @brief Set zoom level of the view
98 * @param zoomLevel Zoom level
100 void setZoomLevel(int zoomLevel);
104 * @brief Set new view scale
106 * @param viewScale New scaling factor
108 void setViewScale(qreal viewScale);
111 * @brief Get current view scale
113 * @return Current view scaling factor
117 /*******************************************************************************
119 ******************************************************************************/
122 * @brief Signal for view resize events.
124 * Signal is emitted when view has been resized.
125 * @param size view size
127 void viewResized(const QSize &size);
130 * @brief Signal for view scroll events
132 * Signal is emitted when view is scrolled.
133 * @param sceneCoordinate Scene coordinates of the new center point of the view
135 void viewScrolled(QPoint sceneCoordinate);
138 * @brief Signal for informing that zooming animation is finished
141 void viewZoomFinished();
144 * @brief Signal for drawing OSM license
146 * Signal is emitted when view is resized.
147 * @param width Viewport width
148 * @param height Viewport height
150 void viewResizedNewSize(int width, int height);
152 /*******************************************************************************
154 ******************************************************************************/
156 QPoint m_mousePosition; ///< Previous mouse event position
157 QPoint m_scenePosition; ///< New center position
158 QPropertyAnimation *m_zoomAnimation; ///< Zoom animation