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