25 #include <QtGui/QClipboard>
26 #include <QtGui/QLineEdit>
27 #include <QtGui/QMenu>
28 #include <QtGui/QApplication>
29 #include <QtGui/QActionEvent>
43 class KComboBox::KComboBoxPrivate
58 :
QComboBox( parent ), d(new KComboBoxPrivate)
64 :
QComboBox( parent ), d(new KComboBoxPrivate)
75 void KComboBox::init()
83 lineEdit()->setContextMenuPolicy( Qt::DefaultContextMenu );
90 if ( _text.isEmpty() )
93 const int itemCount = count();
94 for (
int i = 0; i < itemCount; ++i )
96 if ( itemText(i) == _text )
104 return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1;
129 #ifndef KDE_NO_DEPRECATED
133 d->klineEdit->setContextMenuEnabled( showMenu );
141 d->klineEdit->setUrlDropsEnabled( enable );
146 return d->klineEdit && d->klineEdit->urlDropsEnabled();
153 d->klineEdit->setCompletedText( text, marked );
159 d->klineEdit->setCompletedText( text );
165 d->klineEdit->makeCompletion( text );
169 if( text.isNull() || !view() )
172 view()->keyboardSearch(text);
179 d->klineEdit->rotateText( type );
190 d->trapReturnKey = grab;
193 d->klineEdit->setTrapReturnKey( grab );
195 qWarning(
"KComboBox::setTrapReturnKey not supported with a non-KLineEdit.");
200 return d->trapReturnKey;
216 QComboBox::addItem( icon, url.
prettyUrl() );
221 QComboBox::insertItem( index, url.
prettyUrl() );
226 QComboBox::insertItem( index, icon, url.
prettyUrl() );
231 QComboBox::setItemText( index, url.
prettyUrl() );
236 QComboBox::setItemIcon( index, icon );
237 QComboBox::setItemText( index, url.
prettyUrl() );
243 d->klineEdit->setCompletedItems( items, autosubject );
249 return d->klineEdit->completionBox( create );
269 if (isEditable() && d->klineEdit) {
273 QSize bs = d->klineEdit->clearButtonUsedSize();
275 size.rwidth() += bs.width();
276 size.rheight() = qMax(size.height(), bs.height());
284 if ( !isEditable() && edit &&
285 !qstrcmp( edit->metaObject()->className(),
"QLineEdit" ) )
295 if ( isEditable() ) {
303 d->klineEdit = qobject_cast<
KLineEdit*>( edit );
316 connect( edit, SIGNAL(destroyed()), SLOT(lineEditDeleted()));
327 connect( d->klineEdit,
331 connect( d->klineEdit,
335 connect( d->klineEdit,
339 connect( d->klineEdit,
340 SIGNAL(completionBoxActivated(
QString)),
343 d->klineEdit->setTrapReturnKey( d->trapReturnKey );
351 const int itemCount = count();
352 for (
int i = 0; i < itemCount; ++i)
354 if (itemText(i) == item)
361 if (sel == -1 && insert)
364 insertItem(index, item);
371 setCurrentIndex(sel);
374 void KComboBox::lineEditDeleted()
400 #include "kcombobox.moc"