Fixed naming convention and started writing unit tests
[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
23 #ifndef SIDEPANEL_H
24 #define SIDEPANEL_H
25
26 #include <QWidget>
27 #include <QtGui>
28 #include "panelcommon.h"
29
30 class PanelSideBar;
31 class PanelSliderBar;
32
33 /**
34 * @brief Base class for sliding side panels
35 *
36 * @author Kaj Wallin - kaj.wallin (at) ixonos.com
37 * @class SidePanel sidepanel.h "ui/sidepanel.h"
38 */
39 class SidePanel : public QWidget
40 {
41     Q_OBJECT
42 public:
43     /**
44     * @brief
45
46     * @param parent
47     */
48     SidePanel(QWidget *parent);
49
50     /**
51     * @brief Enumerator for the panel type
52     * Defines values: UserPanel, FriendPanel
53     *
54     * @sa setType
55     */
56     enum PanelType {UserPanel, FriendPanel};
57 /******************************************************************************
58  * MEMBER FUNCTIONS AND SLOTS
59  ******************************************************************************/
60 public slots:
61     /**
62     * @brief Public slot that will open the panel unless already open
63     */
64     void openPanel();
65
66     /**
67     * @brief Public slot that will close the panel unless already closed
68     */
69     void closePanel();
70
71     /**
72     * @brief Slot to redraw the panel after window resize event
73     *
74     * @param size Size of the new screen
75     */
76     void screenResized(const QSize &size);
77
78     /**
79     * @brief Type setter for the panel. Also sets panel visible
80     *
81     * Use to set panel type as UserPanel or FriendPanel. Panel type determines
82     * which side the panel will be rendered. UserPanel will always be rendered
83     * on the left side of the screen and FriendPanel on the right side.
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  * DATA MEMBERS
115  *******************************************************************************/
116 protected:
117     QVBoxLayout *m_panelVBox; ///< Vertical layout inside the panel
118
119 private:
120     bool isOpen; ///< Boolean used to tranch the current state of the statemachine
121     QSignalTransition *m_panelTransitionClose; ///< Transition signal for closing the panel
122     QSignalTransition *m_panelTransitionOpen; ///< Transition signal for opening the panel
123     QState *m_panelStateClosed; ///< State of the closed panel
124     QState *m_panelStateOpened; ///< State of the opened panel
125     QStateMachine *m_panelStateMachine; ///< State machine for sliding the panel
126     QWidget *m_panelBase; ///< Widget for panel base
127
128     PanelType currentType; ///< Holder for the type of this panel
129     PanelSideBar *userPanelSidebar; ///< Overlaying widget for sidebar
130     PanelSliderBar *m_panelSlidingBar; ///< Widget for sidebar tab item
131 };
132
133 #endif // SIDEPANEL_H