]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/QY2ComboTabWidget.h
follow the widget state - for reference: you don't
[duncan/yast2-qt4.git] / src / QY2ComboTabWidget.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                          contributed Qt widgets                      |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       QY2ComboTabWidget.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   This is a pure Qt widget - it can be used independently of YaST2.
18
19 /-*/
20
21
22 #ifndef QY2ComboTabWidget_h
23 #define QY2ComboTabWidget_h
24
25 #include <q3vbox.h>
26 #include <qstring.h>
27 #include <q3intdict.h>
28
29 class QComboBox;
30 class QLabel;
31 class Q3WidgetStack;
32 class QWidget;
33
34
35 /**
36  * This widget is very much like a QTabWidget, but it uses a combo box above
37  * the tab pages rather than a ( scrolled ) one-line row of tabs.
38  **/
39 class QY2ComboTabWidget : public Q3VBox
40 {
41     Q_OBJECT
42
43 public:
44
45     /**
46      * Constructor. 'combo_box_label' is the user-visible label of the combo
47      * box that is used to switch between the different tab pages.
48      **/
49     QY2ComboTabWidget( const QString &  combo_box_label,
50                        QWidget *        parent = 0,
51                        const char *     name   = 0 );
52
53     /**
54      * Destructor.
55      **/
56     virtual ~QY2ComboTabWidget();
57
58     /**
59      * Add a page. 'page_label' will be the user-visible combo box entry for
60      * that page.
61      **/
62     void addPage( const QString & page_label, QWidget * page );
63
64     
65 signals:
66
67     /**
68      * Emitted when the current page changes.
69      * NOT emitted initially for the very first page that is shown.
70      **/
71     void currentChanged( QWidget * newCurrentPage );
72
73     
74 public slots:
75
76     /**
77      * Show a page. Updates the combo box contents accordingly.
78      * This is an expensive operation: All combo box items are searched for the
79      * item that corresponds to this page.
80      **/
81     void showPage( QWidget * page );
82
83
84
85 protected slots:
86
87     /**
88      * Show a page identified by its index. Does NOT update the combo box
89      * contents.
90      **/
91     void showPage( int index );
92
93
94 protected:
95
96     QComboBox           * combo_box;
97     QLabel              * combo_label;
98     Q3WidgetStack       * widget_stack;
99     Q3IntDict<QWidget>    pages;
100 };
101
102 #endif // QY2ComboTabWidget_h