libyui-qt  2.43.5
 All Classes Functions Variables
QY2ComboTabWidget.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: QY2ComboTabWidget.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23  This is a pure Qt widget - it can be used independently of YaST2.
24 
25 /-*/
26 
27 
28 #ifndef QY2ComboTabWidget_h
29 #define QY2ComboTabWidget_h
30 
31 #include <QString>
32 #include <QHash>
33 
34 class QComboBox;
35 class QLabel;
36 class QStackedWidget;
37 class QWidget;
38 
39 
40 /**
41  * This widget is very much like a QTabWidget, but it uses a combo box above
42  * the tab pages rather than a ( scrolled ) one-line row of tabs.
43  **/
44 class QY2ComboTabWidget : public QWidget
45 {
46  Q_OBJECT
47 
48 public:
49 
50  /**
51  * Constructor. 'combo_box_label' is the user-visible label of the combo
52  * box that is used to switch between the different tab pages.
53  **/
54  QY2ComboTabWidget( const QString & combo_box_label,
55  QWidget * parent = 0,
56  const char * name = 0 );
57 
58  /**
59  * Destructor.
60  **/
61  virtual ~QY2ComboTabWidget();
62 
63  /**
64  * Add a page. 'page_label' will be the user-visible combo box entry for
65  * that page.
66  **/
67  void addPage( const QString & page_label, QWidget * page );
68 
69 
70 signals:
71 
72  /**
73  * Emitted when the current page changes.
74  * NOT emitted initially for the very first page that is shown.
75  **/
76  void currentChanged( QWidget * newCurrentPage );
77 
78 
79 public slots:
80 
81  /**
82  * Show a page. Updates the combo box contents accordingly.
83  * This is an expensive operation: All combo box items are searched for the
84  * item that corresponds to this page.
85  **/
86  void showPage( QWidget * page );
87 
88 
89 protected slots:
90 
91  /**
92  * Show a page identified by its index. Does NOT update the combo box
93  * contents.
94  **/
95  void showPageIndex( int index );
96 
97 
98 protected:
99 
100  QComboBox * combo_box;
101  QLabel * combo_label;
102  QStackedWidget * widget_stack;
103  QHash<int, QWidget *> pages;
104 };
105 
106 #endif // QY2ComboTabWidget_h