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: YQComboBox.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #ifndef YQComboBox_h 00027 #define YQComboBox_h 00028 00029 #include <QFrame> 00030 #include <yui/YComboBox.h> 00031 00032 class YQWidgetCaption; 00033 class QComboBox; 00034 class QY2CharValidator; 00035 00036 00037 class YQComboBox : public QFrame, public YComboBox 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 /** 00043 * Constructor. 00044 **/ 00045 YQComboBox( YWidget * parent, const std::string & label, bool editable ); 00046 00047 /** 00048 * Destructor. 00049 **/ 00050 ~YQComboBox(); 00051 00052 /** 00053 * Add one item. This widget assumes ownership of the item object and will 00054 * delete it in its destructor. 00055 * 00056 * Reimplemented from YComboBox. 00057 **/ 00058 virtual void addItem( YItem * item ); 00059 00060 /** 00061 * Delete all items. 00062 * 00063 * Reimplemented from YSelectionWidget. 00064 **/ 00065 virtual void deleteAllItems(); 00066 00067 /** 00068 * Change the label text. 00069 * 00070 * Reimplemented from YSelectionWidget. 00071 **/ 00072 virtual void setLabel( const std::string & label ); 00073 00074 /** 00075 * Change the valid input characters. 00076 * 00077 * Reimplemented from YComboBox. 00078 **/ 00079 virtual void setValidChars( const std::string & validChars ); 00080 00081 /** 00082 * Specify the amount of characters which can be inserted. 00083 * 00084 * Reimplemented from YComboBox. 00085 **/ 00086 virtual void setInputMaxLength( int numberOfChars ); 00087 00088 /** 00089 * Returns 'true' if the given text is valid according to the current 00090 * setting of ValidChars. 00091 **/ 00092 bool isValidText( const QString & txt ) const; 00093 00094 /** 00095 * Set enabled / disabled state. 00096 * 00097 * Reimplemented from YWidget. 00098 **/ 00099 virtual void setEnabled( bool enabled ); 00100 00101 /** 00102 * Preferred width of the widget. 00103 * 00104 * Reimplemented from YWidget. 00105 **/ 00106 virtual int preferredWidth(); 00107 00108 /** 00109 * Preferred height of the widget. 00110 * 00111 * Reimplemented from YWidget. 00112 **/ 00113 virtual int preferredHeight(); 00114 00115 /** 00116 * Set the new size of the widget. 00117 * 00118 * Reimplemented from YWidget. 00119 **/ 00120 virtual void setSize( int newWidth, int newHeight ); 00121 00122 /** 00123 * Accept the keyboard focus. 00124 **/ 00125 virtual bool setKeyboardFocus(); 00126 00127 00128 protected slots: 00129 00130 /** 00131 * Tells the ui that an item has been selected. This is only 00132 * interesting if the `notify option is set. 00133 **/ 00134 void slotSelected( int i ); 00135 00136 /** 00137 * Tells the ui that the user has edited the text ( if the 00138 * 'editable' option is set ). 00139 * This is only interesting if the `notify option is set. 00140 **/ 00141 void textChanged( QString ); 00142 00143 00144 protected: 00145 00146 /** 00147 * Return this ComboBox's current value as text. 00148 * 00149 * Called internally from value(), selectedItem() and related. 00150 * 00151 * Implemented from YComboBox. 00152 **/ 00153 virtual std::string text(); 00154 00155 /** 00156 * 00157 * Set this ComboBox's current value as text. 00158 * 00159 * Called internally whenever the content is to change 00160 * programmatically. Don't call setValue() or selectItem() from here. 00161 * 00162 * Implemented from YComboBox. 00163 **/ 00164 virtual void setText( const std::string & newText ); 00165 00166 00167 // 00168 // Data members 00169 // 00170 00171 YQWidgetCaption * _caption; 00172 QComboBox * _qt_comboBox; 00173 QY2CharValidator * _validator; 00174 }; 00175 00176 00177 #endif // YQLabel_h