Finished implementing zoom button drag feature
[situare] / src / ui / zoombutton.h
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20  */
21
22 #include "imagebutton.h"
23
24 #ifndef ZOOMBUTTON_H
25 #define ZOOMBUTTON_H
26
27 class QTimer;
28
29 /**
30  * @brief A class for Zoom Buttons
31  *
32  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
33  */
34 class ZoomButton : public ImageButton
35 {
36     Q_OBJECT
37
38 public:
39     /**
40      * @brief Constructor
41      *
42      * @param parent Parent
43      * @param normalIconPictureFileName Normal state Icon image file name
44      * @param selectedIconPictureFileName Selected state Icon image file name (optional)
45      */
46     ZoomButton(QWidget *parent = 0, QString normalIconPictureFileName = "",
47                QString selectedIconPictureFileName = "");
48
49 /*******************************************************************************
50  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
51  ******************************************************************************/
52 protected:
53     /**
54      * @brief Event handler for mouse press events
55      *
56      * @param event Mouse event
57      */
58     void mousePressEvent(QMouseEvent *event);
59
60     /**
61      * @brief Event handler for mouse release events
62      *
63      * @param event Mouse event
64      */
65     void mouseReleaseEvent(QMouseEvent *event);
66
67 /*******************************************************************************
68  * MEMBER FUNCTIONS AND SLOTS
69  ******************************************************************************/
70 private slots:
71     /**
72      * @brief Slot to emit signal to zoom button panel to start drag mode after timer timeout
73      */
74     void timerExpired();
75
76 /*******************************************************************************
77  * SIGNALS
78  ******************************************************************************/
79 signals:
80     /**
81      * @brief Signal for starting drag mode
82      *
83      * @param mode True to start drag mode
84      * @param eventPosition Position of mousePressEvent mapped to parent
85      */
86     void startDragMode(bool mode, QPoint eventPosition);
87
88 /*******************************************************************************
89  * DATA MEMBERS
90  ******************************************************************************/
91 private:
92     QTimer *m_dragStartTimer;   ///< Mouse press timer, initiates drag mode
93     QPoint eventPosition;       ///< Position of mousePressEvent
94 };
95
96 #endif // ZOOMBUTTON_H