2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Pekka Nissinen - pekka.nissinen@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Katri Kaikkonen - katri.kaikkonen@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #ifndef INDICATORBUTTONPANEL_H
25 #define INDICATORBUTTONPANEL_H
27 #include <QGraphicsItem>
28 #include <QGridLayout>
30 #include <QMouseEvent>
34 #include "indicatorbutton.h"
37 * @brief Draggable panel for indicator button
39 * @author Katri Kaikkonen - katri.kaikkonen (at) ixonos.com
40 * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
41 * @author Kaj Wallin - kaj.wallin (at) ixonos.com
43 class IndicatorButtonPanel : public QWidget
51 * @param parent Parent
53 IndicatorButtonPanel(QWidget *parent = 0);
55 /*******************************************************************************
56 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
57 ******************************************************************************/
60 * @brief Move event for the indicator button panel
64 void mouseMoveEvent(QMouseEvent *event);
67 * @brief Press event for the indicator button panel
71 void mousePressEvent(QMouseEvent *event);
74 * @brief Event handler for mouse release events
76 * @param event Mouse event
78 void mouseReleaseEvent(QMouseEvent *event);
81 * @brief Event handler for paint events
84 * @param event Paint event
86 void paintEvent(QPaintEvent *event);
88 /*******************************************************************************
89 * MEMBER FUNCTIONS AND SLOTS
90 ******************************************************************************/
93 * @brief Called when direction and distance from current map center point to current GPS
96 * @param direction Direction in degrees
97 * @param distance Distance in meters
98 * @param draw Should the indicator triangle be drawn or not
100 void updateValues(qreal direction, qreal distance, bool draw);
103 * @brief Set indicator button enabled.
105 * @param enabled true if enabled, false otherwise
107 void setIndicatorButtonEnabled(bool enabled);
110 * @brief Toggle zoom panel draggability
112 * @param mode True if draggable, otherwise false
113 * @param distance Start value for dragging
115 void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
118 * @brief Slot to redraw the panel after window resize event
120 * @param size Size of the new screen
122 void screenResized(const QSize &size);
126 * @brief Safeguard slot to release mouse grab if something goes horribly wrong
128 void forceMouseRelease();
131 * @brief Slot that handles drag initialization once timer has timed out
135 /*******************************************************************************
137 ******************************************************************************/
140 * @brief Automatic centering setting changed by user
142 * @param enabled True if automatic centering is enabled, otherwise false
144 void autoCenteringTriggered(bool enabled);
147 * @brief Signal when direction and distance from current map center point to current GPS
148 * location is changed
150 * @param direction Direction in degrees
151 * @param distance Distance in meters
152 * @param draw Should the indicator triangle be drawn or not
154 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
157 * @brief Dragging mode triggered.
159 void draggingModeTriggered();
161 /*******************************************************************************
163 ******************************************************************************/
165 bool m_isDraggable; ///< Boolean for tracking the draggability state
167 qreal m_distance; ///< Distance to the GPS position
169 QColor *m_normalColor; ///< Normal background color
171 QLabel *m_distanceTextLabel; ///< Pointer to distanceTextLabel
173 QPoint m_dragPosition; ///< Location from where the widget is grabbed
175 QSize m_screenSize; ///< Store for the screen size
177 QString m_distanceText; ///< Text description of the distance
179 QTimer *m_dragStartTimer; ///< Timer to init draggability of the zoom panel
180 QTimer *m_forceReleaseTimer; ///< Timer to run forceMouseRelease;
182 IndicatorButton *m_indicatorButton; ///< Indicator button
185 #endif // INDICATORBUTTONPANEL_H