• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
kcombobox.cpp
1/* This file is part of the KDE libraries
2
3 Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org>
4 Copyright (c) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
5 Copyright (c) 2000 Stefan Schimanski <1Stein@gmx.de>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License (LGPL) as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include <tqclipboard.h>
24#include <tqlistbox.h>
25#include <tqpopupmenu.h>
26#include <tqapplication.h>
27
28#include <tdecompletionbox.h>
29#include <kcursor.h>
30#include <kiconloader.h>
31#include <kicontheme.h>
32#include <tdelistviewsearchline.h>
33#include <klineedit.h>
34#include <tdelocale.h>
35#include <knotifyclient.h>
36#include <kpixmapprovider.h>
37#include <tdestdaccel.h>
38#include <kurl.h>
39#include <kurldrag.h>
40
41#include <kdebug.h>
42
43#include "kcombobox.h"
44
45#include <stdlib.h> // getenv
46
47class KComboBox::KComboBoxPrivate
48{
49public:
50 KComboBoxPrivate() : klineEdit(0L)
51 {
52 }
53 ~KComboBoxPrivate()
54 {
55 }
56
57 KLineEdit *klineEdit;
58};
59
60KComboBox::KComboBox( TQWidget *parent, const char *name )
61 : TQComboBox( parent, name ), d(new KComboBoxPrivate)
62{
63 init();
64}
65
66KComboBox::KComboBox( bool rw, TQWidget *parent, const char *name )
67 : TQComboBox( rw, parent, name ), d(new KComboBoxPrivate)
68{
69 init();
70
71 if ( rw )
72 {
73 KLineEdit *edit = new KLineEdit( this, "combo lineedit" );
74 setLineEdit( edit );
75 }
76}
77
78KComboBox::~KComboBox()
79{
80 delete d;
81}
82
83void KComboBox::init()
84{
85 // Permanently set some parameters in the parent object.
86 TQComboBox::setAutoCompletion( false );
87
88 // Enable context menu by default if widget
89 // is editable.
90 setContextMenuEnabled( true );
91}
92
93
94bool KComboBox::contains( const TQString& _text ) const
95{
96 if ( _text.isEmpty() )
97 return false;
98
99 const int itemCount = count();
100 for (int i = 0; i < itemCount; ++i )
101 {
102 if ( text(i) == _text )
103 return true;
104 }
105 return false;
106}
107
108void KComboBox::setAutoCompletion( bool autocomplete )
109{
110 if ( d->klineEdit )
111 {
112 if ( autocomplete )
113 {
114 d->klineEdit->setCompletionMode( TDEGlobalSettings::CompletionAuto );
115 setCompletionMode( TDEGlobalSettings::CompletionAuto );
116 }
117 else
118 {
119 d->klineEdit->setCompletionMode( TDEGlobalSettings::completionMode() );
120 setCompletionMode( TDEGlobalSettings::completionMode() );
121 }
122 }
123}
124
125void KComboBox::setContextMenuEnabled( bool showMenu )
126{
127 if( d->klineEdit )
128 d->klineEdit->setContextMenuEnabled( showMenu );
129}
130
131
132void KComboBox::setURLDropsEnabled( bool enable )
133{
134 if ( d->klineEdit )
135 d->klineEdit->setURLDropsEnabled( enable );
136}
137
138bool KComboBox::isURLDropsEnabled() const
139{
140 return d->klineEdit && d->klineEdit->isURLDropsEnabled();
141}
142
143
144void KComboBox::setCompletedText( const TQString& text, bool marked )
145{
146 if ( d->klineEdit )
147 d->klineEdit->setCompletedText( text, marked );
148}
149
150void KComboBox::setCompletedText( const TQString& text )
151{
152 if ( d->klineEdit )
153 d->klineEdit->setCompletedText( text );
154}
155
156void KComboBox::makeCompletion( const TQString& text )
157{
158 if( d->klineEdit )
159 d->klineEdit->makeCompletion( text );
160
161 else // read-only combo completion
162 {
163 if( text.isNull() || !listBox() )
164 return;
165
166 const int index = listBox()->index( listBox()->findItem( text ) );
167 if( index >= 0 )
168 setCurrentItem( index );
169 }
170}
171
172void KComboBox::rotateText( TDECompletionBase::KeyBindingType type )
173{
174 if ( d->klineEdit )
175 d->klineEdit->rotateText( type );
176}
177
178// not needed anymore
179bool KComboBox::eventFilter( TQObject* o, TQEvent* ev )
180{
181 return TQComboBox::eventFilter( o, ev );
182}
183
184void KComboBox::setTrapReturnKey( bool grab )
185{
186 if ( d->klineEdit )
187 d->klineEdit->setTrapReturnKey( grab );
188 else
189 tqWarning("KComboBox::setTrapReturnKey not supported with a non-KLineEdit.");
190}
191
192bool KComboBox::trapReturnKey() const
193{
194 return d->klineEdit && d->klineEdit->trapReturnKey();
195}
196
197
198void KComboBox::setEditURL( const KURL& url )
199{
200 TQComboBox::setEditText( url.prettyURL() );
201}
202
203void KComboBox::insertURL( const KURL& url, int index )
204{
205 TQComboBox::insertItem( url.prettyURL(), index );
206}
207
208void KComboBox::insertURL( const TQPixmap& pixmap, const KURL& url, int index )
209{
210 TQComboBox::insertItem( pixmap, url.prettyURL(), index );
211}
212
213void KComboBox::changeURL( const KURL& url, int index )
214{
215 TQComboBox::changeItem( url.prettyURL(), index );
216}
217
218void KComboBox::changeURL( const TQPixmap& pixmap, const KURL& url, int index )
219{
220 TQComboBox::changeItem( pixmap, url.prettyURL(), index );
221}
222
223void KComboBox::setCompletedItems( const TQStringList& items )
224{
225 if ( d->klineEdit )
226 d->klineEdit->setCompletedItems( items );
227}
228
229TDECompletionBox * KComboBox::completionBox( bool create )
230{
231 if ( d->klineEdit )
232 return d->klineEdit->completionBox( create );
233 return 0;
234}
235
236// TQWidget::create() turns off mouse-Tracking which would break auto-hiding
237void KComboBox::create( WId id, bool initializeWindow, bool destroyOldWindow )
238{
239 TQComboBox::create( id, initializeWindow, destroyOldWindow );
240 KCursor::setAutoHideCursor( lineEdit(), true, true );
241}
242
243void KComboBox::wheelEvent( TQWheelEvent *ev )
244{
245 // Not necessary anymore
246 TQComboBox::wheelEvent( ev );
247}
248
249void KComboBox::setLineEdit( TQLineEdit *edit )
250{
251 if ( !editable() && edit &&
252 !qstrcmp( edit->className(), "TQLineEdit" ) )
253 {
254 // uic generates code that creates a read-only KComboBox and then
255 // calls combo->setEditable( true ), which causes TQComboBox to set up
256 // a dumb TQLineEdit instead of our nice KLineEdit.
257 // As some KComboBox features rely on the KLineEdit, we reject
258 // this order here.
259 delete edit;
260 edit = new KLineEdit( this, "combo edit" );
261 }
262
263 TQComboBox::setLineEdit( edit );
264 d->klineEdit = dynamic_cast<KLineEdit*>( edit );
265 setDelegate( d->klineEdit );
266
267 // Connect the returnPressed signal for both Q[K]LineEdits'
268 if (edit)
269 connect( edit, TQ_SIGNAL( returnPressed() ), TQ_SIGNAL( returnPressed() ));
270
271 if ( d->klineEdit )
272 {
273 // someone calling KComboBox::setEditable( false ) destroys our
274 // lineedit without us noticing. And TDECompletionBase::delegate would
275 // be a dangling pointer then, so prevent that. Note: only do this
276 // when it is a KLineEdit!
277 connect( edit, TQ_SIGNAL( destroyed() ), TQ_SLOT( lineEditDeleted() ));
278
279 connect( d->klineEdit, TQ_SIGNAL( returnPressed( const TQString& )),
280 TQ_SIGNAL( returnPressed( const TQString& ) ));
281
282 connect( d->klineEdit, TQ_SIGNAL( completion( const TQString& )),
283 TQ_SIGNAL( completion( const TQString& )) );
284
285 connect( d->klineEdit, TQ_SIGNAL( substringCompletion( const TQString& )),
286 TQ_SIGNAL( substringCompletion( const TQString& )) );
287
288 connect( d->klineEdit,
289 TQ_SIGNAL( textRotation( TDECompletionBase::KeyBindingType )),
290 TQ_SIGNAL( textRotation( TDECompletionBase::KeyBindingType )) );
291
292 connect( d->klineEdit,
293 TQ_SIGNAL( completionModeChanged( TDEGlobalSettings::Completion )),
294 TQ_SIGNAL( completionModeChanged( TDEGlobalSettings::Completion)));
295
296 connect( d->klineEdit,
297 TQ_SIGNAL( aboutToShowContextMenu( TQPopupMenu * )),
298 TQ_SIGNAL( aboutToShowContextMenu( TQPopupMenu * )) );
299
300 connect( d->klineEdit,
301 TQ_SIGNAL( completionBoxActivated( const TQString& )),
302 TQ_SIGNAL( activated( const TQString& )) );
303 }
304}
305
306void KComboBox::setCurrentItem( const TQString& item, bool insert, int index )
307{
308 int sel = -1;
309
310 const int itemCount = count();
311 for (int i = 0; i < itemCount; ++i)
312 {
313 if (text(i) == item)
314 {
315 sel = i;
316 break;
317 }
318 }
319
320 if (sel == -1 && insert)
321 {
322 insertItem(item, index);
323 if (index >= 0)
324 sel = index;
325 else
326 sel = count() - 1;
327 }
328 setCurrentItem(sel);
329}
330
331void KComboBox::lineEditDeleted()
332{
333 // yes, we need those ugly casts due to the multiple inheritance
334 // sender() is guaranteed to be a KLineEdit (see the connect() to the
335 // destroyed() signal
336 const TDECompletionBase *base = static_cast<const TDECompletionBase*>( static_cast<const KLineEdit*>( sender() ));
337
338 // is it our delegate, that is destroyed?
339 if ( base == delegate() )
340 setDelegate( 0L );
341}
342
343
344// *********************************************************************
345// *********************************************************************
346
347class KHistoryCombo::KHistoryComboPrivate
348{
349public:
350 KHistoryComboPrivate() : bHistoryEditorEnabled(false)
351 {
352 }
353 ~KHistoryComboPrivate()
354 {
355 }
356
357 bool bHistoryEditorEnabled;
358};
359
360// we are always read-write
361KHistoryCombo::KHistoryCombo( TQWidget *parent, const char *name )
362 : KComboBox( true, parent, name ), d(new KHistoryComboPrivate)
363{
364 init( true ); // using completion
365}
366
367// we are always read-write
368KHistoryCombo::KHistoryCombo( bool useCompletion,
369 TQWidget *parent, const char *name )
370 : KComboBox( true, parent, name ), d(new KHistoryComboPrivate)
371{
372 init( useCompletion );
373}
374
375void KHistoryCombo::init( bool useCompletion )
376{
377 // Set a default history size to something reasonable, Qt sets it to INT_MAX by default
378 setMaxCount( 50 );
379
380 if ( useCompletion )
381 completionObject()->setOrder( TDECompletion::Weighted );
382
383 setInsertionPolicy( NoInsertion );
384 myIterateIndex = -1;
385 myRotated = false;
386 myPixProvider = 0L;
387
388 // obey HISTCONTROL setting
389 TQCString histControl = getenv("HISTCONTROL");
390 if ( histControl == "ignoredups" || histControl == "ignoreboth" )
391 setDuplicatesEnabled( false );
392
393 connect( this, TQ_SIGNAL(aboutToShowContextMenu(TQPopupMenu*)),
394 TQ_SLOT(addContextMenuItems(TQPopupMenu*)) );
395 connect( this, TQ_SIGNAL( activated(int) ), TQ_SLOT( slotReset() ));
396 connect( this, TQ_SIGNAL( returnPressed(const TQString&) ), TQ_SLOT(slotReset()));
397}
398
399KHistoryCombo::~KHistoryCombo()
400{
401 delete myPixProvider;
402}
403
404void KHistoryCombo::setHistoryItems( TQStringList items,
405 bool setCompletionList )
406{
407 KComboBox::clear();
408
409 // limit to maxCount()
410 const int itemCount = items.count();
411 const int toRemove = itemCount - maxCount();
412
413 if (toRemove >= itemCount) {
414 items.clear();
415 } else {
416 for (int i = 0; i < toRemove; ++i)
417 items.pop_front();
418 }
419
420 insertItems( items );
421
422 if ( setCompletionList && useCompletion() ) {
423 // we don't have any weighting information here ;(
424 TDECompletion *comp = completionObject();
425 comp->setOrder( TDECompletion::Insertion );
426 comp->setItems( items );
427 comp->setOrder( TDECompletion::Weighted );
428 }
429
430 clearEdit();
431}
432
433TQStringList KHistoryCombo::historyItems() const
434{
435 TQStringList list;
436 const int itemCount = count();
437 for ( int i = 0; i < itemCount; ++i )
438 list.append( text( i ) );
439
440 return list;
441}
442
443void KHistoryCombo::clearHistory()
444{
445 const TQString temp = currentText();
446 KComboBox::clear();
447 if ( useCompletion() )
448 completionObject()->clear();
449 setEditText( temp );
450}
451
452void KHistoryCombo::addContextMenuItems( TQPopupMenu* menu )
453{
454 if ( menu )
455 {
456 menu->insertSeparator();
457 if (d->bHistoryEditorEnabled) {
458 int idedit = menu->insertItem( SmallIconSet("edit"), i18n("&Edit History..."), this, TQ_SLOT( slotEdit()) );
459 menu->setItemEnabled(idedit, count());
460 }
461 int id = menu->insertItem( SmallIconSet("history_clear"), i18n("Clear &History"), this, TQ_SLOT( slotClear()));
462 if (!count())
463 menu->setItemEnabled(id, false);
464 }
465}
466
467void KHistoryCombo::addToHistory( const TQString& item )
468{
469 if ( item.isEmpty() || (count() > 0 && item == text(0) )) {
470 return;
471 }
472
473 bool wasCurrent = false;
474 // remove all existing items before adding
475 if ( !duplicatesEnabled() ) {
476 int i = 0;
477 int itemCount = count();
478 while ( i < itemCount ) {
479 if ( text( i ) == item ) {
480 if ( !wasCurrent )
481 wasCurrent = ( i == currentItem() );
482 removeItem( i );
483 --itemCount;
484 } else {
485 ++i;
486 }
487 }
488 }
489
490 // now add the item
491 if ( myPixProvider )
492 insertItem( myPixProvider->pixmapFor(item, TDEIcon::SizeSmall), item, 0);
493 else
494 insertItem( item, 0 );
495
496 if ( wasCurrent )
497 setCurrentItem( 0 );
498
499 const bool useComp = useCompletion();
500
501 const int last = count() - 1; // last valid index
502 const int mc = maxCount();
503 const int stopAt = TQMAX(mc, 0);
504
505 for (int rmIndex = last; rmIndex >= stopAt; --rmIndex) {
506 // remove the last item, as long as we are longer than maxCount()
507 // remove the removed item from the completionObject if it isn't
508 // anymore available at all in the combobox.
509 const TQString rmItem = text( rmIndex );
510 removeItem( rmIndex );
511 if ( useComp && !contains( rmItem ) )
512 completionObject()->removeItem( rmItem );
513 }
514
515 if ( useComp )
516 completionObject()->addItem( item );
517}
518
519bool KHistoryCombo::removeFromHistory( const TQString& item )
520{
521 if ( item.isEmpty() )
522 return false;
523
524 bool removed = false;
525 const TQString temp = currentText();
526 int i = 0;
527 int itemCount = count();
528 while ( i < itemCount ) {
529 if ( item == text( i ) ) {
530 removed = true;
531 removeItem( i );
532 --itemCount;
533 } else {
534 ++i;
535 }
536 }
537
538 if ( removed && useCompletion() )
539 completionObject()->removeItem( item );
540
541 setEditText( temp );
542 return removed;
543}
544
545void KHistoryCombo::rotateUp()
546{
547 // save the current text in the lineedit
548 if ( myIterateIndex == -1 )
549 myText = currentText();
550
551 ++myIterateIndex;
552
553 // skip duplicates/empty items
554 const int last = count() - 1; // last valid index
555 const TQString currText = currentText();
556
557 while ( myIterateIndex < last &&
558 (currText == text( myIterateIndex ) ||
559 text( myIterateIndex ).isEmpty()) )
560 ++myIterateIndex;
561
562 if ( myIterateIndex >= count() ) {
563 myRotated = true;
564 myIterateIndex = -1;
565
566 // if the typed text is the same as the first item, skip the first
567 if ( count() > 0 && myText == text(0) )
568 myIterateIndex = 0;
569
570 setEditText( myText );
571 }
572 else
573 setEditText( text( myIterateIndex ));
574}
575
576void KHistoryCombo::rotateDown()
577{
578 // save the current text in the lineedit
579 if ( myIterateIndex == -1 )
580 myText = currentText();
581
582 --myIterateIndex;
583
584 const TQString currText = currentText();
585 // skip duplicates/empty items
586 while ( myIterateIndex >= 0 &&
587 (currText == text( myIterateIndex ) ||
588 text( myIterateIndex ).isEmpty()) )
589 --myIterateIndex;
590
591
592 if ( myIterateIndex < 0 ) {
593 if ( myRotated && myIterateIndex == -2 ) {
594 myRotated = false;
595 myIterateIndex = count() - 1;
596 setEditText( text(myIterateIndex) );
597 }
598 else { // bottom of history
599 if ( myIterateIndex == -2 ) {
600 KNotifyClient::event( (int)winId(), KNotifyClient::notification,
601 i18n("No further item in the history."));
602 }
603
604 myIterateIndex = -1;
605 if ( currentText() != myText )
606 setEditText( myText );
607 }
608 }
609 else
610 setEditText( text( myIterateIndex ));
611
612}
613
614void KHistoryCombo::keyPressEvent( TQKeyEvent *e )
615{
616 KKey event_key( e );
617
618 // going up in the history, rotating when reaching TQListBox::count()
619 if ( TDEStdAccel::rotateUp().contains(event_key) )
620 rotateUp();
621
622 // going down in the history, no rotation possible. Last item will be
623 // the text that was in the lineedit before Up was called.
624 else if ( TDEStdAccel::rotateDown().contains(event_key) )
625 rotateDown();
626 else
627 KComboBox::keyPressEvent( e );
628}
629
630void KHistoryCombo::wheelEvent( TQWheelEvent *ev )
631{
632 // Pass to poppable listbox if it's up
633 TQListBox* const lb = listBox();
634 if ( lb && lb->isVisible() )
635 {
636 TQApplication::sendEvent( lb, ev );
637 return;
638 }
639 // Otherwise make it change the text without emitting activated
640 if ( ev->delta() > 0 ) {
641 rotateUp();
642 } else {
643 rotateDown();
644 }
645 ev->accept();
646}
647
648void KHistoryCombo::slotReset()
649{
650 myIterateIndex = -1;
651 myRotated = false;
652}
653
654
655void KHistoryCombo::setPixmapProvider( KPixmapProvider *prov )
656{
657 if ( myPixProvider == prov )
658 return;
659
660 delete myPixProvider;
661 myPixProvider = prov;
662
663 // re-insert all the items with/without pixmap
664 // I would prefer to use changeItem(), but that doesn't honor the pixmap
665 // when using an editable combobox (what we do)
666 if ( count() > 0 ) {
667 TQStringList items( historyItems() );
668 clear();
669 insertItems( items );
670 }
671}
672
673void KHistoryCombo::insertItems( const TQStringList& items )
674{
675 TQStringList::ConstIterator it = items.constBegin();
676 const TQStringList::ConstIterator itEnd = items.constEnd();
677
678 while ( it != itEnd ) {
679 const TQString item = *it;
680 if ( !item.isEmpty() ) { // only insert non-empty items
681 if ( myPixProvider )
682 insertItem( myPixProvider->pixmapFor(item, TDEIcon::SizeSmall),
683 item );
684 else
685 insertItem( item );
686 }
687 ++it;
688 }
689}
690
691void KHistoryCombo::slotClear()
692{
693 clearHistory();
694 emit cleared();
695}
696
697void KHistoryCombo::slotEdit()
698{
699 KHistoryComboEditor dlg( historyItems(), this );
700 connect( &dlg, TQ_SIGNAL( removeFromHistory(const TQString&) ), TQ_SLOT( slotRemoveFromHistory(const TQString&)) );
701 dlg.exec();
702}
703
704void KHistoryCombo::slotRemoveFromHistory(const TQString &entry)
705{
706 removeFromHistory(entry);
707 emit removed(entry);
708}
709
710void KHistoryCombo::setHistoryEditorEnabled( bool enable )
711{
712 d->bHistoryEditorEnabled = enable;
713}
714
715bool KHistoryCombo::isHistoryEditorEnabled() const
716{
717 return d->bHistoryEditorEnabled;
718}
719
720void KComboBox::virtual_hook( int id, void* data )
721{ TDECompletionBase::virtual_hook( id, data ); }
722
723void KHistoryCombo::virtual_hook( int id, void* data )
724{ KComboBox::virtual_hook( id, data ); }
725
726void KHistoryComboEditor::virtual_hook( int id, void* data )
727{ KDialogBase::virtual_hook( id, data ); }
728
729KHistoryComboEditor::KHistoryComboEditor( const TQStringList& entries, TQWidget *parent )
730: KDialogBase( parent, "khistorycomboeditor", true, i18n( "History Editor" ),
731 KDialogBase::Close | KDialogBase::User1, KDialogBase::User1, true,
732 KGuiItem( i18n( "&Delete Entry" ), "edit-delete") ), d(0)
733{
734 TQVBox* box = new TQVBox( this );
735 box->setSpacing( KDialog::spacingHint() );
736 setMainWidget( box );
737
738 new TQLabel( i18n( "This dialog allows you to delete unwanted history items." ), box );
739
740 // Add searchline
741 TQHBox* searchbox = new TQHBox( box );
742 searchbox->setSpacing( KDialog::spacingHint() );
743
744 TQToolButton *clearSearch = new TQToolButton(searchbox);
745 clearSearch->setTextLabel(i18n("Clear Search"), true);
746 clearSearch->setIconSet(SmallIconSet(TQApplication::reverseLayout() ? "clear_left" : "locationbar_erase"));
747 TQLabel* slbl = new TQLabel(i18n("&Search:"), searchbox);
748 TDEListViewSearchLine* listViewSearch = new TDEListViewSearchLine(searchbox);
749 slbl->setBuddy(listViewSearch);
750 connect(clearSearch, TQ_SIGNAL(pressed()), listViewSearch, TQ_SLOT(clear()));
751
752 // Add ListView
753 m_pListView = new TDEListView( box );
754 listViewSearch->setListView(m_pListView);
755 m_pListView->setAllColumnsShowFocus(true);
756 m_pListView->header()->hide();
757 m_pListView->addColumn("");
758 m_pListView->setRenameable( 0 );
759
760 box->setStretchFactor( m_pListView, 1 );
761
762 TQStringList newlist = entries;
763 for ( TQStringList::Iterator it = newlist.begin(); it != newlist.end(); ++it ) {
764 new TQListViewItem( m_pListView, *it );
765 }
766
767 m_pListView->setMinimumSize( m_pListView->sizeHint() );
768
769 connect( m_pListView, TQ_SIGNAL( selectionChanged( TQListViewItem * ) ),
770 this, TQ_SLOT( slotSelectionChanged( TQListViewItem * ) ) );
771
772 enableButton( KDialogBase::User1, false );
773
774 resize( sizeHint() );
775}
776
777KHistoryComboEditor::~KHistoryComboEditor()
778{
779}
780
781void KHistoryComboEditor::slotUser1() // Delete button
782{
783 TQListViewItem *item = m_pListView->selectedItem();
784
785 if ( item ) {
786 emit removeFromHistory( item->text(0) );
787 m_pListView->takeItem( item );
788 enableButton( KDialogBase::User1, false );
789 }
790}
791
792void KHistoryComboEditor::slotSelectionChanged( TQListViewItem * item )
793{
794 enableButton( KDialogBase::User1, item );
795}
796
797#include "kcombobox.moc"
KComboBox
An enhanced combo box.
Definition: kcombobox.h:152
KComboBox::setEditURL
void setEditURL(const KURL &url)
Sets url into the edit field of the combobox.
Definition: kcombobox.cpp:198
KComboBox::completionModeChanged
void completionModeChanged(TDEGlobalSettings::Completion)
Emitted whenever the completion mode is changed by the user through the context menu.
KComboBox::aboutToShowContextMenu
void aboutToShowContextMenu(TQPopupMenu *p)
Emitted before the context menu is displayed.
KComboBox::setCurrentItem
void setCurrentItem(const TQString &item, bool insert=false, int index=-1)
Selects the first item that matches item.
Definition: kcombobox.cpp:306
KComboBox::isURLDropsEnabled
bool isURLDropsEnabled() const
Returns true when decoded URL drops are enabled.
Definition: kcombobox.cpp:138
KComboBox::insertURL
void insertURL(const KURL &url, int index=-1)
Inserts url at position index into the combobox.
Definition: kcombobox.cpp:203
KComboBox::textRotation
void textRotation(TDECompletionBase::KeyBindingType)
Emitted when the text rotation key-bindings are pressed.
KComboBox::~KComboBox
virtual ~KComboBox()
Destructor.
Definition: kcombobox.cpp:78
KComboBox::setContextMenuEnabled
virtual void setContextMenuEnabled(bool showMenu)
Enables or disable the popup (context) menu.
Definition: kcombobox.cpp:125
KComboBox::trapReturnKey
bool trapReturnKey() const
Definition: kcombobox.cpp:192
KComboBox::setTrapReturnKey
void setTrapReturnKey(bool trap)
By default, KComboBox recognizes Key_Return and Key_Enter and emits the returnPressed() signals,...
Definition: kcombobox.cpp:184
KComboBox::changeURL
void changeURL(const KURL &url, int index)
Replaces the item at position index with url.
Definition: kcombobox.cpp:213
KComboBox::eventFilter
virtual bool eventFilter(TQObject *, TQEvent *)
Re-implemented for internal reasons.
Definition: kcombobox.cpp:179
KComboBox::completionBox
TDECompletionBox * completionBox(bool create=true)
Definition: kcombobox.cpp:229
KComboBox::setCompletedItems
void setCompletedItems(const TQStringList &items)
Sets items into the completion-box if completionMode() is CompletionPopup.
Definition: kcombobox.cpp:223
KComboBox::create
virtual void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Reimplemented for internal reasons, the API is not affected.
Definition: kcombobox.cpp:237
KComboBox::setLineEdit
virtual void setLineEdit(TQLineEdit *)
Re-implemented for internal reasons.
Definition: kcombobox.cpp:249
KComboBox::setURLDropsEnabled
void setURLDropsEnabled(bool enable)
Enables/Disables handling of URL drops.
Definition: kcombobox.cpp:132
KComboBox::substringCompletion
void substringCompletion(const TQString &)
Emitted when the shortcut for substring completion is pressed.
KComboBox::makeCompletion
virtual void makeCompletion(const TQString &)
Completes text according to the completion mode.
Definition: kcombobox.cpp:156
KComboBox::returnPressed
void returnPressed()
Emitted when the user presses the Enter key.
KComboBox::setCompletedText
virtual void setCompletedText(const TQString &)
Sets the completed text in the line-edit appropriately.
Definition: kcombobox.cpp:150
KComboBox::completion
void completion(const TQString &)
Emitted when the completion key is pressed.
KComboBox::rotateText
void rotateText(TDECompletionBase::KeyBindingType type)
Iterates through all possible matches of the completed text or the history list.
Definition: kcombobox.cpp:172
KComboBox::contains
bool contains(const TQString &text) const
Convenience method which iterates over all items and checks if any of them is equal to text.
Definition: kcombobox.cpp:94
KComboBox::setAutoCompletion
virtual void setAutoCompletion(bool autocomplete)
Re-implemented from TQComboBox.
Definition: kcombobox.cpp:108
KComboBox::KComboBox
KComboBox(TQWidget *parent=0, const char *name=0)
Constructs a read-only or rather select-only combo box with a parent object and a name.
Definition: kcombobox.cpp:60
KCursor::setAutoHideCursor
static void setAutoHideCursor(TQWidget *w, bool enable)
Sets auto-hiding the cursor for widget w.
Definition: kcursor.cpp:218
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:192
KDialogBase::User1
@ User1
Show User defined button 1.
Definition: kdialogbase.h:206
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:110
KGuiItem
An abstract class for GUI data such as ToolTip and Icon.
Definition: kguiitem.h:39
KHistoryCombo::historyItems
TQStringList historyItems() const
Returns the list of history items.
Definition: kcombobox.cpp:433
KHistoryCombo::setHistoryEditorEnabled
void setHistoryEditorEnabled(bool enable)
When enabling it you have to connect to "removed" signal and save changes.
Definition: kcombobox.cpp:710
KHistoryCombo::useCompletion
bool useCompletion() const
Definition: kcombobox.h:744
KHistoryCombo::insertItems
void insertItems(const TQStringList &items)
Inserts items into the combo, honoring pixmapProvider() Does not update the completionObject.
Definition: kcombobox.cpp:673
KHistoryCombo::cleared
void cleared()
Emitted when the history was cleared by the entry in the popup menu.
KHistoryCombo::~KHistoryCombo
~KHistoryCombo()
Destructs the combo, the completion-object and the pixmap-provider.
Definition: kcombobox.cpp:399
KHistoryCombo::clearHistory
void clearHistory()
Clears the history and the completion list.
Definition: kcombobox.cpp:443
KHistoryCombo::setHistoryItems
void setHistoryItems(TQStringList items)
Inserts items into the combobox.
Definition: kcombobox.h:588
KHistoryCombo::wheelEvent
virtual void wheelEvent(TQWheelEvent *ev)
Handling wheel-events, to rotate the items.
Definition: kcombobox.cpp:630
KHistoryCombo::keyPressEvent
virtual void keyPressEvent(TQKeyEvent *)
Handling key-events, the shortcuts to rotate the items.
Definition: kcombobox.cpp:614
KHistoryCombo::KHistoryCombo
KHistoryCombo(TQWidget *parent=0L, const char *name=0L)
Constructs a "read-write" combobox.
Definition: kcombobox.cpp:361
KHistoryCombo::addToHistory
void addToHistory(const TQString &item)
Adds an item to the end of the history list and to the completion list.
Definition: kcombobox.cpp:467
KHistoryCombo::removeFromHistory
bool removeFromHistory(const TQString &item)
Removes all items named item.
Definition: kcombobox.cpp:519
KHistoryCombo::setPixmapProvider
void setPixmapProvider(KPixmapProvider *prov)
Sets a pixmap provider, so that items in the combobox can have a pixmap.
Definition: kcombobox.cpp:655
KKey
KLineEdit
An enhanced TQLineEdit widget for inputting text.
Definition: klineedit.h:146
KPixmapProvider
KPixmapProvider::pixmapFor
virtual TQPixmap pixmapFor(const TQString &text, int size=0)=0
KURL
KURL::prettyURL
TQString prettyURL(int _trailing=0) const
TDECompletionBase
TDECompletionBase::setCompletionMode
virtual void setCompletionMode(TDEGlobalSettings::Completion mode)
TDECompletionBase::delegate
TDECompletionBase * delegate() const
TDECompletionBase::setDelegate
void setDelegate(TDECompletionBase *delegate)
TDECompletionBase::completionObject
TDECompletion * completionObject(bool hsig=true)
TDECompletionBase::KeyBindingType
KeyBindingType
TDECompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: tdecompletionbox.h:44
TDECompletion
TDECompletion::setOrder
virtual void setOrder(CompOrder order)
TDECompletion::removeItem
void removeItem(const TQString &item)
TDECompletion::setItems
virtual void setItems(const TQStringList &list)
TDECompletion::Insertion
Insertion
TDECompletion::Weighted
Weighted
TDECompletion::clear
virtual void clear()
TDECompletion::addItem
void addItem(const TQString &item)
TDEGlobalSettings::Completion
Completion
TDEGlobalSettings::CompletionAuto
CompletionAuto
TDEGlobalSettings::completionMode
static Completion completionMode()
TDEIcon::SizeSmall
SizeSmall
TDEListViewSearchLine
This class makes it easy to add a search line for filtering the items in a listview based on a simple...
Definition: tdelistviewsearchline.h:48
TDEListViewSearchLine::setListView
void setListView(TDEListView *lv)
Sets the TDEListView that is filtered by this search line.
Definition: tdelistviewsearchline.cpp:178
TDEListView
This Widget extends the functionality of TQListView to honor the system wide settings for Single Clic...
Definition: tdelistview.h:85
KNotifyClient::event
int event(const TQString &message, const TQString &text=TQString::null) TDE_DEPRECATED
KStdAction::clear
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Clear the content of the focus widget.
Definition: kstdaction.cpp:176
TDEStdAccel::rotateUp
const TDEShortcut & rotateUp()
TDEStdAccel::rotateDown
const TDEShortcut & rotateDown()
tdelocale.h

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.