libyui-qt  2.47.1.1
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 #include <QWidget>
34 
35 class QComboBox;
36 class QLabel;
37 class QStackedWidget;
38 class QWidget;
39 
40 
41 /**
42  * This widget is very much like a QTabWidget, but it uses a combo box above
43  * the tab pages rather than a ( scrolled ) one-line row of tabs.
44  **/
45 class QY2ComboTabWidget : public QWidget
46 {
47  Q_OBJECT
48 
49 public:
50 
51  /**
52  * Constructor. 'combo_box_label' is the user-visible label of the combo
53  * box that is used to switch between the different tab pages.
54  **/
55  QY2ComboTabWidget( const QString & combo_box_label,
56  QWidget * parent = 0,
57  const char * name = 0 );
58 
59  /**
60  * Destructor.
61  **/
62  virtual ~QY2ComboTabWidget();
63 
64  /**
65  * Add a page. 'page_label' will be the user-visible combo box entry for
66  * that page.
67  **/
68  void addPage( const QString & page_label, QWidget * page );
69 
70 
71 signals:
72 
73  /**
74  * Emitted when the current page changes.
75  * NOT emitted initially for the very first page that is shown.
76  **/
77  void currentChanged( QWidget * newCurrentPage );
78 
79 
80 public slots:
81 
82  /**
83  * Show a page. Updates the combo box contents accordingly.
84  * This is an expensive operation: All combo box items are searched for the
85  * item that corresponds to this page.
86  **/
87  void showPage( QWidget * page );
88 
89 
90 protected slots:
91 
92  /**
93  * Show a page identified by its index. Does NOT update the combo box
94  * contents.
95  **/
96  void showPageIndex( int index );
97 
98 
99 protected:
100 
101  QComboBox * combo_box;
102  QLabel * combo_label;
103  QStackedWidget * widget_stack;
104  QHash<int, QWidget *> pages;
105 };
106 
107 #endif // QY2ComboTabWidget_h
void showPage(QWidget *page)
Show a page.
void showPageIndex(int index)
Show a page identified by its index.
This widget is very much like a QTabWidget, but it uses a combo box above the tab pages rather than a...
void addPage(const QString &page_label, QWidget *page)
Add a page.
virtual ~QY2ComboTabWidget()
Destructor.
void currentChanged(QWidget *newCurrentPage)
Emitted when the current page changes.
QY2ComboTabWidget(const QString &combo_box_label, QWidget *parent=0, const char *name=0)
Constructor.