Added method to disable tabs.
[situare] / src / ui / paneltabbar.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
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 PANELTABBAR_H
23 #define PANELTABBAR_H
24
25 #include <QWidget>
26
27 class QButtonGroup;
28
29 /**
30  * @brief Class for tab bar
31  *
32  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
33  */
34 class PanelTabBar : public QWidget
35 {
36     Q_OBJECT
37
38 public:
39     /**
40      * @brief Constructor
41      *
42      * @param parent Parent
43      */
44     PanelTabBar(QWidget *parent = 0);
45
46 /*******************************************************************************
47  * MEMBER FUNCTIONS AND SLOTS
48  ******************************************************************************/
49 public:
50     /**
51      * @brief Adds a tab
52      *
53      * Adds a tab with icon and returns the index of the inserted tab
54      *
55      * @param icon Icon of the tab
56      */
57     int addTab(const QIcon& icon);
58
59     /**
60      * @brief Inserts a tab
61      *
62      * Inserts a tab with icon at the specified index and returns the index of the inserted tab.
63      * If index is out of range, the tab is appended.
64      *
65      * @param index Index of the tab
66      * @param icon Icon of the tab
67      */
68     int insertTab(int index, const QIcon& icon);
69
70     /**
71      * @brief Removes a tab
72      *
73      * Removes a tab at index position
74      *
75      * @todo: Fix tab drawing order
76      *
77      * @param index Index of the tab
78      */
79     void removeTab(int index);
80
81     /**
82     * @brief Returns all tabs.
83     *
84     * @return All tabs
85     */
86     QButtonGroup *tabs() const;
87
88 private:
89     /**
90      * @brief Initializes and formats tab buttons layout
91      */
92     void setUpTabLayout();
93
94 public slots:
95     /**
96      * @brief This slot is used to clear tab selections
97      */
98     void deselectTabs();
99
100     /**
101      * @brief This slot selects a tab at given index
102      *
103      * @param index Index of the tab
104      */
105     void selectTab(int index);
106
107 private slots:
108     /**
109      * @brief Sets the tab at current index active
110      *
111      * @param index Index of the tab
112      */
113     void setCurrentIndex(int index);
114
115 /*******************************************************************************
116  * SIGNALS
117  ******************************************************************************/
118 signals:
119     /**
120      * @brief This signal is emitted whenever the current tab changes
121      *
122      * @param index Index of the new tab
123      */
124     void currentChanged(int index);
125
126     /**
127      * @brief This signal is emitted when tabs are added or removed
128      */
129     void sizeChangeRequested();
130
131     /**
132      * @brief This signal is emitted whenever user wants to close a tab
133      *
134      * @param index Index of the currently active tab
135      */
136     void tabCloseRequested(int index);
137
138 /*******************************************************************************
139  * DATA MEMBERS
140  ******************************************************************************/
141 private:
142     int m_activeTab;    ///< Index of a active tab
143
144     QButtonGroup *m_tabButtonGroup; ///< Button groub for tab buttons
145 };
146
147 #endif // PANELTABBAR_H