Added new scalable panels, deleted obsolite bitmaps and made some minor cosmetic...
[situare] / src / ui / sidepanel.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         Pekka Nissinen - pekka.nissinen@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 SIDEPANEL_H
24 #define SIDEPANEL_H
25
26 #include <QWidget>
27 #include <QtGui>
28
29 class PanelSliderBar;
30 class SidePanelBase;
31
32 /**
33  * @brief Base class for sliding side panels
34  *
35  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
36  * @author Pekka Nissinen - pekka.nissinen@ixonos.com
37  *
38  * @class SidePanel sidepanel.h "ui/sidepanel.h"
39  */
40 class SidePanel : public QWidget
41 {
42     Q_OBJECT
43
44 public:
45     /**
46      * @brief Constructor
47      *
48      * @param parent
49      */
50     SidePanel(QWidget *parent = 0);
51
52     /**
53      * @brief Enumerator for the panel type
54      * Defines values: UserPanel, FriendPanel, None
55      *
56      * @sa setType
57      */
58     enum PanelType {UserPanel, FriendPanel, None};
59
60 /******************************************************************************
61  * MEMBER FUNCTIONS AND SLOTS
62  ******************************************************************************/
63 public slots:
64     /**
65      * @brief Public slot that will open the panel unless already open
66      */
67     void openPanel();
68
69     /**
70      * @brief Public slot that will close the panel unless already closed
71      */
72     void closePanel();
73
74     /**
75      * @brief Slot to redraw the panel after window resize event
76      *
77      * @param size Size of the new window
78      */
79     void resizePanel(const QSize &size);
80
81     /**
82      * @brief Type setter for the panel. Also sets panel visible
83      *
84      * Use to set panel type as UserPanel or FriendPanel. Panel type determines
85      * which side the panel will be rendered. UserPanel will always be rendered
86      * on the left side of the screen and FriendPanel on the right side. Type
87      * cannot be set twice.
88      *
89      * @param type Type of the panel, either UserPanel or FriendPanel
90      * @sa PanelType
91      */
92     void setType(SidePanel::PanelType type);
93
94 private slots:
95     /**
96      * @brief Internal slot used to track statemachine state
97      */
98     void stateChangedToClosed();
99
100     /**
101      * @brief Internal slot used to track statemachine state
102      */
103     void stateChangedToOpen();
104
105 /******************************************************************************
106  * SIGNALS
107  ******************************************************************************/
108 signals:
109     /**
110      * @brief Signal that is sent to state machine when state must be changed
111      *
112      * @sa openPanel
113      * @sa closePanel
114      */
115     void toggleState();
116
117     /**
118      * @brief Signal that is sent when panel is closed
119      *
120      * @sa openPanel
121      * @sa closePanel
122      */
123     void panelClosed();
124
125     /**
126      * @brief Signal that is sent when panel is opened
127      *
128      * @sa openPanel
129      * @sa closePanel
130      */
131     void panelOpened();
132
133 /*******************************************************************************
134  * DATA MEMBERS
135  *******************************************************************************/
136 protected:
137     QVBoxLayout *m_panelVBox; ///< Vertical layout inside the panel
138
139 private:
140     bool m_isOpen; ///< Boolean used to track the current state of the statemachine
141
142     QSignalTransition *m_panelTransitionClose;  ///< Transition signal for closing the panel
143     QSignalTransition *m_panelTransitionOpen;   ///< Transition signal for opening the panel
144     QState *m_panelStateClosed;                 ///< State of the closed panel
145     QState *m_panelStateOpened;                 ///< State of the opened panel
146     QStateMachine *m_panelStateMachine;         ///< State machine for sliding the panel
147
148     SidePanelBase *m_panelBase;         ///< Widget for panel base
149     PanelType currentType;              ///< Holder for the type of this panel
150     PanelSliderBar *m_panelSlidingBar;  ///< Widget for panel sliding bar item
151 };
152
153 #endif // SIDEPANEL_H