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>
28 class QPropertyAnimation;
31 * @brief Map view widget
33 * @author Sami Rämö - sami.ramo (at) ixonos.com
34 * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
36 class MapView : public QGraphicsView
45 Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
51 * @param parent Parent
53 MapView(QWidget *parent = 0);
55 /*******************************************************************************
56 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
57 ******************************************************************************/
60 * @brief Event handler for mouse double click event
62 * Emits zoomIn signal.
63 * @param event QMouseEvent
65 void mouseDoubleClickEvent(QMouseEvent *event);
68 * @brief Event handler for mouse move events
70 * Does calculate mouse movement delta from last event position and new view center
71 * based on that delta. Saves current event position for next round. Emits viewScrolled
72 * signal and doesn't actually scroll the view.
73 * @param event Mouse event
75 void mouseMoveEvent(QMouseEvent *event);
78 * @brief Event handler for mouse press events
80 * Saves inial values for mouse and scene location for dragging view.
81 * @param event Mouse event
83 void mousePressEvent(QMouseEvent *event);
85 void mouseReleaseEvent(QMouseEvent *event);
88 * @brief Called when view is resized.
90 * @param event resize event
92 void resizeEvent(QResizeEvent *event);
94 /*******************************************************************************
95 * MEMBER FUNCTIONS AND SLOTS
96 ******************************************************************************/
99 * @brief Slot for centering view to new location
101 * @param sceneCoordinate Scene coordinates of the new center point
103 void centerToSceneCoordinates(QPoint sceneCoordinate);
106 * @brief Set zoom level of the view
108 * @param zoomLevel Zoom level
110 void setZoomLevel(int zoomLevel);
112 void disableAnchor();
116 * @brief Set new view scale
118 * @param viewScale New scaling factor
120 void setViewScale(qreal viewScale);
123 * @brief Get current view scale
125 * @return Current view scaling factor
129 /*******************************************************************************
131 ******************************************************************************/
134 * @brief Signal for view resize events.
136 * Signal is emitted when view has been resized.
137 * @param size view size
139 void viewResized(const QSize &size);
142 * @brief Signal for view scroll events
144 * Signal is emitted when view is scrolled.
145 * @param sceneCoordinate Scene coordinates of the new center point of the view
147 void viewScrolled(QPoint sceneCoordinate);
150 * @brief Signal for informing that zooming animation is finished
152 void viewZoomFinished();
155 * @brief Signal for zooming in.
159 /*******************************************************************************
161 ******************************************************************************/
163 QPoint m_mousePosition; ///< Previous mouse event position
164 QPoint m_scenePosition; ///< New center position
165 QPropertyAnimation *m_zoomAnimation; ///< Zoom animation