Added indicatorbuttonpanel.cpp and indicatorbuttonpanel.h
[situare] / src / ui / indicatorbuttonpanel.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Pekka Nissinen - pekka.nissinen@ixonos.com
6        Kaj Wallin - kaj.wallin@ixonos.com
7
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.
11
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.
16
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,
20    USA.
21 */
22
23 #ifndef INDICATORBUTTONPANEL_H
24 #define INDICATORBUTTONPANEL_H
25
26 #include <QGraphicsItem>
27 #include <QGridLayout>
28 #include <QTimer>
29 #include <QWidget>
30 #include <QLabel>
31 #include <QLineEdit>
32
33 #include "indicatorbutton.h"
34
35 /**
36  * @brief Panel for zoom buttons
37  *
38  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
39  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
40  */
41 class IndicatorButtonPanel : public QWidget
42 {
43     Q_OBJECT
44
45 public:
46     /**
47      * @brief Constructor
48      *
49      * @param parent Parent
50      */
51     IndicatorButtonPanel(QWidget *parent = 0);
52
53 /*******************************************************************************
54  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
55  ******************************************************************************/
56 protected:
57     /**
58      * @brief Move event for the zoom button panel
59      *
60      * @param event Event
61      */
62     void mouseMoveEvent(QMouseEvent *event);
63
64     /**
65      * @brief Press event for the zoom button panel
66      *
67      * @param event Event
68      */
69     void mousePressEvent(QMouseEvent *event);
70
71     /**
72      * @brief Event handler for mouse release events
73      *
74      * @param event Mouse event
75      */
76     void mouseReleaseEvent(QMouseEvent *event);
77
78     /**
79      * @brief Event handler for paint events
80      *
81      * Paints the panel
82      * @param event Paint event
83      */
84     void paintEvent(QPaintEvent *event);
85
86 /*******************************************************************************
87  * MEMBER FUNCTIONS AND SLOTS
88  ******************************************************************************/
89 public:
90 //    /**
91 //     * @brief Getter for the zoom in button
92 //     *
93 //     * @return Pointer to the zoomInButton
94 //     */
95 //    const IndicatorButton* IndicatorButtonPanel::indicatorButton();
96
97 public slots:
98 //    /**
99 //     * @brief Disables the zoom in button
100 //     */
101 //    void disableZoomInButton();
102
103 //    /**
104 //     * @brief Disables the zoom out button
105 //     */
106 //    void disableZoomOutButton();
107
108 //    /**
109 //     * @brief Reset zoom button states to normal
110 //     */
111 //    void resetButtons();
112
113     /**
114      * @brief Toggle zoom panel draggability
115      */
116     void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
117
118     /**
119      * @brief Slot to redraw the panel after window resize event
120      *
121      * @param size Size of the new screen
122      */
123     void screenResized(const QSize &size);
124
125 private slots:
126     /**
127      * @brief Safeguard slot to release mouse grab if something goes horribly wrong
128      */
129     void forceMouseRelease();
130
131     /**
132      * @brief Slot that handles drag initialization once timer has timed out
133      */
134     void timerExpired();
135
136 /*******************************************************************************
137  * DATA MEMBERS
138  ******************************************************************************/
139 private:
140     bool m_isDraggable;             ///< Boolean for tracking the draggability state
141
142     QLabel *m_distanceTextLabel; ///< Pointer to locationLabel
143
144     QPoint m_dragPosition;          ///< Location from where the widget is grabbed
145
146 //    QIcon::Mode m_zoomInMode;       ///< Store for zoom in button mode before dragging
147 //    QIcon::Mode m_zoomOutMode;      ///< Store for zoom out button mode before dragging
148
149     QSize m_screenSize;             ///< Store for the screen size
150
151     QTimer *m_dragStartTimer;       ///< Timer to init draggability of the zoom panel
152     QTimer *m_forceReleaseTimer;    ///< Timer to run forceMouseRelease;
153
154     IndicatorButton *m_indicatorButton;    ///< Button for zoom in
155
156 };
157
158 #endif // INDICATORBUTTONPANEL_H