libyui-qt
2.43.5
|
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: YQMultiSelectionBox.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #ifndef YQMultiSelectionBox_h 00027 #define YQMultiSelectionBox_h 00028 00029 #include <QFrame> 00030 #include <QColorGroup> 00031 #include <QTreeWidget> 00032 00033 #include <yui/YMultiSelectionBox.h> 00034 00035 class YQWidgetCaption; 00036 class YQMultiSelectionBoxItem; 00037 00038 00039 class YQMultiSelectionBox : public QFrame, public YMultiSelectionBox 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 00045 /** 00046 * Constructor. 00047 **/ 00048 YQMultiSelectionBox( YWidget * parent, const std::string & label ); 00049 00050 /** 00051 * Destructor. 00052 **/ 00053 ~YQMultiSelectionBox(); 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 * Select or deselect an item. 00071 * 00072 * Reimplemented from YSelectionWidget. 00073 **/ 00074 virtual void selectItem( YItem * item, bool selected = true ); 00075 00076 /** 00077 * Deselect all items. 00078 * 00079 * Reimplemented from YSelectionWidget. 00080 **/ 00081 virtual void deselectAllItems(); 00082 00083 /** 00084 * Delete all items. 00085 * 00086 * Reimplemented from YSelectionWidget. 00087 **/ 00088 virtual void deleteAllItems(); 00089 00090 /** 00091 * Return the the item that currently has the keyboard focus 00092 * or 0 if no item currently has the keyboard focus. 00093 * 00094 * Reimplemented from YMultiSelectionBox. 00095 **/ 00096 virtual YItem * currentItem(); 00097 00098 /** 00099 * Set the keyboard focus to the specified item. 00100 * 0 means clear the keyboard focus. 00101 * 00102 * Reimplemented from YMultiSelectionBox. 00103 **/ 00104 virtual void setCurrentItem( YItem * item ); 00105 00106 /** 00107 * Set enabled/disabled state. 00108 * 00109 * Reimplemented from YWidget. 00110 **/ 00111 virtual void setEnabled( bool enabled ); 00112 00113 /** 00114 * Preferred width of the widget. 00115 * 00116 * Reimplemented from YWidget. 00117 **/ 00118 virtual int preferredWidth(); 00119 00120 /** 00121 * Preferred height of the widget. 00122 * 00123 * Reimplemented from YWidget. 00124 **/ 00125 virtual int preferredHeight(); 00126 00127 /** 00128 * Set the new size of the widget. 00129 * 00130 * Reimplemented from YWidget. 00131 **/ 00132 virtual void setSize( int newWidth, int newHeight ); 00133 00134 /** 00135 * Accept the keyboard focus. 00136 **/ 00137 virtual bool setKeyboardFocus(); 00138 00139 00140 signals: 00141 /** 00142 * Emitted upon when an item changes its state. 00143 **/ 00144 void valueChanged(); 00145 00146 00147 protected slots: 00148 /** 00149 * Send SelectionChanged event if `opt(`notify) is set. 00150 **/ 00151 void slotSelected(); 00152 00153 /** 00154 * Send ValueChanged event if `opt(`notify) is set. 00155 **/ 00156 void slotValueChanged(); 00157 00158 void slotItemChanged( QTreeWidgetItem*, int ); 00159 00160 protected: 00161 /** 00162 * Find the counterpart of 'item'. Return 0 if there is none. 00163 **/ 00164 YQMultiSelectionBoxItem * findItem( YItem * item ); 00165 00166 00167 YQWidgetCaption * _caption; 00168 QTreeWidget * _qt_listView; 00169 }; 00170 00171 00172 00173 class YQMultiSelectionBoxItem: public QTreeWidgetItem 00174 { 00175 public: 00176 /** 00177 * Constructor. 00178 **/ 00179 YQMultiSelectionBoxItem( YQMultiSelectionBox * parent, 00180 QTreeWidget * listView, 00181 YItem * yItem ); 00182 00183 /** 00184 * Destructor. 00185 **/ 00186 virtual ~YQMultiSelectionBoxItem() {} 00187 00188 /** 00189 * Return the corresponding YItem. 00190 **/ 00191 YItem * yItem() const { return _yItem; } 00192 00193 00194 protected: 00195 00196 // 00197 // Data members 00198 // 00199 00200 YItem * _yItem; 00201 int _serial; 00202 YQMultiSelectionBox * _multiSelectionBox; 00203 00204 00205 /** 00206 * The next serial number to use 00207 **/ 00208 static int _item_count; 00209 }; 00210 00211 #endif // YQLabel_h