libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQSelectionBox.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:       YQSelectionBox.h
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #ifndef YQSelectionBox_h
00027 #define YQSelectionBox_h
00028 
00029 #include <QFrame>
00030 #include <QTimer>
00031 
00032 #include <yui/YSelectionBox.h>
00033 
00034 class YQWidgetCaption;
00035 class QListWidget;
00036 class QListWidgetItem;
00037 
00038 
00039 class YQSelectionBox : public QFrame, public YSelectionBox
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044 
00045     /**
00046      * Constructor.
00047      **/
00048     YQSelectionBox( YWidget * parent, const std::string & label );
00049 
00050     /**
00051      * Destructor.
00052      **/
00053     virtual ~YQSelectionBox();
00054 
00055     /**
00056      * Change the label text.
00057      *
00058      * Reimplemented from YSelectionWidget.
00059      **/
00060     virtual void setLabel( const std::string & label );
00061 
00062     /**
00063      * Add an item.
00064      *
00065      * Reimplemented from YSelectionWidget.
00066      **/
00067     virtual void addItem( YItem * item );
00068 
00069     /**
00070      * Add multiple items.
00071      *
00072      * Reimplemented for efficiency from YSelectionWidget.
00073      **/
00074     virtual void addItems( const YItemCollection & itemCollection );
00075 
00076     /**
00077      * Select or deselect an item.
00078      *
00079      * Reimplemented from YSelectionWidget.
00080      **/
00081     virtual void selectItem( YItem * item, bool selected = true );
00082 
00083     /**
00084      * Deselect all items.
00085      *
00086      * Reimplemented from YSelectionWidget.
00087      **/
00088     virtual void deselectAllItems();
00089 
00090     /**
00091      * Delete all items.
00092      *
00093      * Reimplemented from YSelectionWidget.
00094      **/
00095     virtual void deleteAllItems();
00096 
00097     /**
00098      * Set enabled/disabled state.
00099      *
00100      * Reimplemented from YWidget.
00101      **/
00102     virtual void setEnabled( bool enabled );
00103 
00104     /**
00105      * Preferred width of the widget.
00106      *
00107      * Reimplemented from YWidget.
00108      **/
00109     virtual int preferredWidth();
00110 
00111     /**
00112      * Preferred height of the widget.
00113      *
00114      * Reimplemented from YWidget.
00115      **/
00116     virtual int preferredHeight();
00117 
00118     /**
00119      * Set the new size of the widget.
00120      *
00121      * Reimplemented from YWidget.
00122      **/
00123     virtual void setSize( int newWidth, int newHeight );
00124 
00125     /**
00126      * Accept the keyboard focus.
00127      *
00128      * Reimplemented from YWidget.
00129      **/
00130     virtual bool setKeyboardFocus();
00131 
00132     /**
00133      * Event filter.
00134      *
00135      * Reimplemented from QWidget.
00136      **/
00137     virtual bool eventFilter( QObject * obj, QEvent * ev );
00138 
00139 
00140 protected slots:
00141 
00142     /**
00143      * Notification that an item has been selected.
00144      * This is only relevant if `opt(`notify ) is set.
00145      **/
00146     void slotSelectionChanged();
00147 
00148     /**
00149      * Notification that an item has been activated (double clicked).
00150      **/
00151     void slotActivated( QListWidgetItem * item );
00152 
00153     /**
00154      * Return after some millseconds delay - collect multiple events.
00155      * This is only relevant if `opt( `notify ) is set.
00156      **/
00157     void returnDelayed();
00158 
00159     /**
00160      * Return immediately.
00161      * This is only relevant if `opt( `notify ) is set.
00162      **/
00163     void returnImmediately();
00164 
00165 
00166 protected:
00167 
00168     /**
00169      * Select an item by index.
00170      **/
00171     void selectItem( int index );
00172 
00173     /**
00174      * Internal addItem() method that will not do expensive operations in batch
00175      * mode.
00176      **/
00177     void addItem( YItem * item, bool batchMode );
00178 
00179 
00180     //
00181     // Data members
00182     //
00183 
00184     YQWidgetCaption *   _caption;
00185     QListWidget *       _qt_listWidget;
00186     QTimer              _timer;
00187 };
00188 
00189 #endif // YQLabel_h
 All Classes Functions Variables