libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/QY2ComboTabWidget.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:       QY2ComboTabWidget.h
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023   This is a pure Qt widget - it can be used independently of YaST2.
00024 
00025 /-*/
00026 
00027 
00028 #ifndef QY2ComboTabWidget_h
00029 #define QY2ComboTabWidget_h
00030 
00031 #include <QString>
00032 #include <QHash>
00033 
00034 class QComboBox;
00035 class QLabel;
00036 class QStackedWidget;
00037 class QWidget;
00038 
00039 
00040 /**
00041  * This widget is very much like a QTabWidget, but it uses a combo box above
00042  * the tab pages rather than a ( scrolled ) one-line row of tabs.
00043  **/
00044 class QY2ComboTabWidget : public QWidget
00045 {
00046     Q_OBJECT
00047 
00048 public:
00049 
00050     /**
00051      * Constructor. 'combo_box_label' is the user-visible label of the combo
00052      * box that is used to switch between the different tab pages.
00053      **/
00054     QY2ComboTabWidget( const QString &  combo_box_label,
00055                        QWidget *        parent = 0,
00056                        const char *     name   = 0 );
00057 
00058     /**
00059      * Destructor.
00060      **/
00061     virtual ~QY2ComboTabWidget();
00062 
00063     /**
00064      * Add a page. 'page_label' will be the user-visible combo box entry for
00065      * that page.
00066      **/
00067     void addPage( const QString & page_label, QWidget * page );
00068 
00069 
00070 signals:
00071 
00072     /**
00073      * Emitted when the current page changes.
00074      * NOT emitted initially for the very first page that is shown.
00075      **/
00076     void currentChanged( QWidget * newCurrentPage );
00077 
00078 
00079 public slots:
00080 
00081     /**
00082      * Show a page. Updates the combo box contents accordingly.
00083      * This is an expensive operation: All combo box items are searched for the
00084      * item that corresponds to this page.
00085      **/
00086     void showPage( QWidget * page );
00087 
00088 
00089 protected slots:
00090 
00091     /**
00092      * Show a page identified by its index. Does NOT update the combo box
00093      * contents.
00094      **/
00095     void showPageIndex( int index );
00096 
00097 
00098 protected:
00099 
00100     QComboBox           * combo_box;
00101     QLabel              * combo_label;
00102     QStackedWidget      * widget_stack;
00103     QHash<int, QWidget *>         pages;
00104 };
00105 
00106 #endif // QY2ComboTabWidget_h
 All Classes Functions Variables