35ed793f8326e256d4ba71f24134a921def2d7f8
[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 private:
82     /**
83      * @brief Initializes and formats tab buttons layout
84      */
85     void setUpTabLayout();
86
87 public slots:
88     /**
89      * @brief This slot is used to clear tab selections
90      */
91     void deselectTabs();
92
93     /**
94      * @brief This slot selects a tab at given index
95      *
96      * @param index Index of the tab
97      */
98     void selectTab(int index);
99
100 private slots:
101     /**
102      * @brief Sets the tab at current index active
103      *
104      * @param index Index of the tab
105      */
106     void setCurrentIndex(int index);
107
108 /*******************************************************************************
109  * SIGNALS
110  ******************************************************************************/
111 signals:
112     /**
113      * @brief This signal is emitted whenever the current tab changes
114      *
115      * @param index Index of the new tab
116      */
117     void currentChanged(int index);
118
119     /**
120      * @brief This signal is emitted when tabs are added or removed
121      */
122     void sizeChangeRequested();
123
124     /**
125      * @brief This signal is emitted whenever user wants to close a tab
126      *
127      * @param index Index of the currently active tab
128      */
129     void tabCloseRequested(int index);
130
131 /*******************************************************************************
132  * DATA MEMBERS
133  ******************************************************************************/
134 private:
135     int m_activeTab;    ///< Index of a active tab
136
137     QButtonGroup *m_tabButtonGroup; ///< Button groub for tab buttons
138 };
139
140 #endif // PANELTABBAR_H