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