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);
57 * Destroys m_normalColor
59 ~IndicatorButtonPanel();
61 /*******************************************************************************
62 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
63 ******************************************************************************/
66 * @brief Move event for the indicator button panel
70 void mouseMoveEvent(QMouseEvent *event);
73 * @brief Press event for the indicator button panel
77 void mousePressEvent(QMouseEvent *event);
80 * @brief Event handler for mouse release events
82 * @param event Mouse event
84 void mouseReleaseEvent(QMouseEvent *event);
87 * @brief Event handler for paint events
90 * @param event Paint event
92 void paintEvent(QPaintEvent *event);
94 /*******************************************************************************
95 * MEMBER FUNCTIONS AND SLOTS
96 ******************************************************************************/
99 * @brief Called when direction and distance from current map center point to current GPS
100 * location is changed
102 * @param direction Direction in degrees
103 * @param distance Distance in meters
104 * @param draw Should the indicator triangle be drawn or not
106 void updateValues(qreal direction, qreal distance, bool draw);
109 * @brief Set indicator button enabled.
111 * @param enabled true if enabled, false otherwise
113 void setIndicatorButtonEnabled(bool enabled);
116 * @brief Toggle indicator button panel draggability
118 * @param mode True if draggable, otherwise false
119 * @param eventPosition Start position of the dragging
121 void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
124 * @brief Slot to redraw the panel after window resize event
126 * @param size Size of the new screen
128 void screenResized(const QSize &size);
132 * @brief Safeguard slot to release mouse grab if something goes horribly wrong
134 void forceMouseRelease();
137 * @brief Slot that handles drag initialization once timer has timed out
141 /*******************************************************************************
143 ******************************************************************************/
146 * @brief Automatic centering setting changed by user
148 * @param enabled True if automatic centering is enabled, otherwise false
150 void autoCenteringTriggered(bool enabled);
153 * @brief Signal when direction and distance from current map center point to current GPS
154 * location is changed
156 * @param direction Direction in degrees
157 * @param distance Distance in meters
158 * @param draw Should the indicator triangle be drawn or not
160 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
163 * @brief Dragging mode triggered.
165 void draggingModeTriggered();
167 /*******************************************************************************
169 ******************************************************************************/
171 bool m_isDraggable; ///< Boolean for tracking the draggability state
173 qreal m_distance; ///< Distance to the GPS position
175 QColor *m_normalColor; ///< Normal background color
177 QLabel *m_distanceTextLabel; ///< Pointer to distanceTextLabel
179 QPoint m_dragPosition; ///< Location from where the widget is grabbed
181 QSize m_screenSize; ///< Store for the screen size
183 QString m_distanceText; ///< Text description of the distance
185 QTimer *m_dragStartTimer; ///< Timer to init draggability of the zoom panel
186 QTimer *m_forceReleaseTimer; ///< Timer to run forceMouseRelease;
188 IndicatorButton *m_indicatorButton; ///< Indicator button
191 #endif // INDICATORBUTTONPANEL_H