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

tdeui

  • tdeui
klineedit.cpp
1/* This file is part of the KDE libraries
2
3 Copyright (C) 1997 Sven Radej (sven.radej@iname.com)
4 Copyright (c) 1999 Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
5 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
6
7 Re-designed for KDE 2.x by
8 Copyright (c) 2000, 2001 Dawit Alemayehu <adawit@kde.org>
9 Copyright (c) 2000, 2001 Carsten Pfeiffer <pfeiffer@kde.org>
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License (LGPL) as published by the Free Software Foundation;
14 either version 2 of the License, or (at your option) any later
15 version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 Boston, MA 02110-1301, USA.
26*/
27
28#include <tqclipboard.h>
29#include <tqpainter.h>
30#include <tqtimer.h>
31
32#include <tdeconfig.h>
33#include <tqtooltip.h>
34#include <kcursor.h>
35#include <tdelocale.h>
36#include <tdestdaccel.h>
37#include <tdepopupmenu.h>
38#include <kdebug.h>
39#include <tdecompletionbox.h>
40#include <kurl.h>
41#include <kurldrag.h>
42#include <kiconloader.h>
43#include <tdeapplication.h>
44
45#include "klineedit.h"
46#include "klineedit.moc"
47
48
49class KLineEdit::KLineEditPrivate
50{
51public:
52 KLineEditPrivate()
53 {
54 completionBox = 0L;
55 handleURLDrops = true;
56 grabReturnKeyEvents = false;
57
58 userSelection = true;
59 autoSuggest = false;
60 disableRestoreSelection = false;
61 enableSqueezedText = false;
62
63 if ( !initialized )
64 {
65 TDEConfigGroup config( TDEGlobal::config(), "General" );
66 backspacePerformsCompletion = config.readBoolEntry( "Backspace performs completion", false );
67
68 initialized = true;
69 }
70
71 }
72
73 ~KLineEditPrivate()
74 {
75// causes a weird crash in KWord at least, so let Qt delete it for us.
76// delete completionBox;
77 }
78
79 static bool initialized;
80 static bool backspacePerformsCompletion; // Configuration option
81
82 TQColor previousHighlightColor;
83 TQColor previousHighlightedTextColor;
84
85 bool userSelection: 1;
86 bool autoSuggest : 1;
87 bool disableRestoreSelection: 1;
88 bool handleURLDrops:1;
89 bool grabReturnKeyEvents:1;
90 bool enableSqueezedText:1;
91
92 int squeezedEnd;
93 int squeezedStart;
94 BackgroundMode bgMode;
95 TQString squeezedText;
96 TDECompletionBox *completionBox;
97
98 TQString clickMessage;
99 bool drawClickMsg:1;
100};
101
102bool KLineEdit::KLineEditPrivate::backspacePerformsCompletion = false;
103bool KLineEdit::KLineEditPrivate::initialized = false;
104
105
106KLineEdit::KLineEdit( const TQString &string, TQWidget *parent, const char *name )
107 :TQLineEdit( string, parent, name )
108{
109 init();
110}
111
112KLineEdit::KLineEdit( TQWidget *parent, const char *name )
113 :TQLineEdit( parent, name )
114{
115 init();
116}
117
118KLineEdit::~KLineEdit ()
119{
120 delete d;
121 d = 0;
122}
123
124void KLineEdit::init()
125{
126 d = new KLineEditPrivate;
127 possibleTripleClick = false;
128 d->bgMode = backgroundMode ();
129
130 // Enable the context menu by default.
131 KLineEdit::setContextMenuEnabled( true );
132 KCursor::setAutoHideCursor( this, true, true );
133 installEventFilter( this );
134
135 TDEGlobalSettings::Completion mode = completionMode();
136 d->autoSuggest = (mode == TDEGlobalSettings::CompletionMan ||
137 mode == TDEGlobalSettings::CompletionPopupAuto ||
138 mode == TDEGlobalSettings::CompletionAuto);
139 connect( this, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(slotRestoreSelectionColors()));
140
141 TQPalette p = palette();
142 if ( !d->previousHighlightedTextColor.isValid() )
143 d->previousHighlightedTextColor=p.color(TQPalette::Active,TQColorGroup::HighlightedText);
144 if ( !d->previousHighlightColor.isValid() )
145 d->previousHighlightColor=p.color(TQPalette::Active,TQColorGroup::Highlight);
146
147 d->drawClickMsg = false;
148}
149
150void KLineEdit::setCompletionMode( TDEGlobalSettings::Completion mode )
151{
152 TDEGlobalSettings::Completion oldMode = completionMode();
153
154 if ( oldMode != mode && (oldMode == TDEGlobalSettings::CompletionPopup ||
155 oldMode == TDEGlobalSettings::CompletionPopupAuto ) &&
156 d->completionBox && d->completionBox->isVisible() )
157 d->completionBox->hide();
158
159 // If the widgets echo mode is not Normal, no completion
160 // feature will be enabled even if one is requested.
161 if ( echoMode() != TQLineEdit::Normal )
162 mode = TDEGlobalSettings::CompletionNone; // Override the request.
163
164 if ( tdeApp && !tdeApp->authorize("lineedit_text_completion") )
165 mode = TDEGlobalSettings::CompletionNone;
166
167 if ( mode == TDEGlobalSettings::CompletionPopupAuto ||
168 mode == TDEGlobalSettings::CompletionAuto ||
169 mode == TDEGlobalSettings::CompletionMan )
170 d->autoSuggest = true;
171 else
172 d->autoSuggest = false;
173
174 TDECompletionBase::setCompletionMode( mode );
175}
176
177void KLineEdit::setCompletedText( const TQString& t, bool marked )
178{
179 if ( !d->autoSuggest )
180 return;
181
182 TQString txt = text();
183
184 if ( t != txt )
185 {
186 int start = marked ? txt.length() : t.length();
187 validateAndSet( t, cursorPosition(), start, t.length() );
188 setUserSelection(false);
189 }
190 else
191 setUserSelection(true);
192
193}
194
195void KLineEdit::setCompletedText( const TQString& text )
196{
197 TDEGlobalSettings::Completion mode = completionMode();
198 bool marked = ( mode == TDEGlobalSettings::CompletionAuto ||
199 mode == TDEGlobalSettings::CompletionMan ||
200 mode == TDEGlobalSettings::CompletionPopup ||
201 mode == TDEGlobalSettings::CompletionPopupAuto );
202 setCompletedText( text, marked );
203}
204
205void KLineEdit::rotateText( TDECompletionBase::KeyBindingType type )
206{
207 TDECompletion* comp = compObj();
208 if ( comp &&
209 (type == TDECompletionBase::PrevCompletionMatch ||
210 type == TDECompletionBase::NextCompletionMatch ) )
211 {
212 TQString input;
213
214 if (type == TDECompletionBase::PrevCompletionMatch)
215 comp->previousMatch();
216 else
217 comp->nextMatch();
218
219 // Skip rotation if previous/next match is null or the same text
220 if ( input.isNull() || input == displayText() )
221 return;
222 setCompletedText( input, hasSelectedText() );
223 }
224}
225
226void KLineEdit::makeCompletion( const TQString& text )
227{
228 TDECompletion *comp = compObj();
229 TDEGlobalSettings::Completion mode = completionMode();
230
231 if ( !comp || mode == TDEGlobalSettings::CompletionNone )
232 return; // No completion object...
233
234 TQString match = comp->makeCompletion( text );
235
236 if ( mode == TDEGlobalSettings::CompletionPopup ||
237 mode == TDEGlobalSettings::CompletionPopupAuto )
238 {
239 if ( match.isNull() )
240 {
241 if ( d->completionBox )
242 {
243 d->completionBox->hide();
244 d->completionBox->clear();
245 }
246 }
247 else
248 setCompletedItems( comp->allMatches() );
249 }
250 else // Auto, ShortAuto (Man) and Shell
251 {
252 // all other completion modes
253 // If no match or the same match, simply return without completing.
254 if ( match.isNull() || match == text )
255 return;
256
257 if ( mode != TDEGlobalSettings::CompletionShell )
258 setUserSelection(false);
259
260 if ( d->autoSuggest )
261 setCompletedText( match );
262 }
263}
264
265void KLineEdit::setReadOnly(bool readOnly)
266{
267 // Do not do anything if nothing changed...
268 if (readOnly == isReadOnly ())
269 return;
270
271 TQLineEdit::setReadOnly (readOnly);
272
273 if (readOnly)
274 {
275 d->bgMode = backgroundMode ();
276 setBackgroundMode (TQt::PaletteBackground);
277 if (d->enableSqueezedText && d->squeezedText.isEmpty())
278 {
279 d->squeezedText = text();
280 setSqueezedText();
281 }
282 }
283 else
284 {
285 if (!d->squeezedText.isEmpty())
286 {
287 setText(d->squeezedText);
288 d->squeezedText = TQString::null;
289 }
290 setBackgroundMode (d->bgMode);
291 }
292}
293
294void KLineEdit::setSqueezedText( const TQString &text)
295{
296 setEnableSqueezedText(true);
297 setText(text);
298}
299
300void KLineEdit::setEnableSqueezedText( bool enable )
301{
302 d->enableSqueezedText = enable;
303}
304
305bool KLineEdit::isSqueezedTextEnabled() const
306{
307 return d->enableSqueezedText;
308}
309
310void KLineEdit::setText( const TQString& text )
311{
312 d->drawClickMsg = text.isEmpty() && !d->clickMessage.isEmpty();
313 update();
314
315 if( d->enableSqueezedText && isReadOnly() )
316 {
317 d->squeezedText = text;
318 setSqueezedText();
319 return;
320 }
321
322 TQLineEdit::setText( text );
323}
324
325void KLineEdit::setSqueezedText()
326{
327 d->squeezedStart = 0;
328 d->squeezedEnd = 0;
329 TQString fullText = d->squeezedText;
330 TQFontMetrics fm(fontMetrics());
331 int labelWidth = size().width() - 2*frameWidth() - 2;
332 int textWidth = fm.width(fullText);
333
334 if (textWidth > labelWidth)
335 {
336 // start with the dots only
337 TQString squeezedText = "...";
338 int squeezedWidth = fm.width(squeezedText);
339
340 // estimate how many letters we can add to the dots on both sides
341 int letters = fullText.length() * (labelWidth - squeezedWidth) / textWidth / 2;
342 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
343 squeezedWidth = fm.width(squeezedText);
344
345 if (squeezedWidth < labelWidth)
346 {
347 // we estimated too short
348 // add letters while text < label
349 do
350 {
351 letters++;
352 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
353 squeezedWidth = fm.width(squeezedText);
354 } while (squeezedWidth < labelWidth);
355 letters--;
356 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
357 }
358 else if (squeezedWidth > labelWidth)
359 {
360 // we estimated too long
361 // remove letters while text > label
362 do
363 {
364 letters--;
365 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
366 squeezedWidth = fm.width(squeezedText);
367 } while (squeezedWidth > labelWidth);
368 }
369
370 if (letters < 5)
371 {
372 // too few letters added -> we give up squeezing
373 TQLineEdit::setText(fullText);
374 }
375 else
376 {
377 TQLineEdit::setText(squeezedText);
378 d->squeezedStart = letters;
379 d->squeezedEnd = fullText.length() - letters;
380 }
381
382 TQToolTip::remove( this );
383 TQToolTip::add( this, fullText );
384
385 }
386 else
387 {
388 TQLineEdit::setText(fullText);
389
390 TQToolTip::remove( this );
391 TQToolTip::hide();
392 }
393
394 setCursorPosition(0);
395}
396
397void KLineEdit::copy() const
398{
399 if( !copySqueezedText(true))
400 TQLineEdit::copy();
401}
402
403bool KLineEdit::copySqueezedText(bool clipboard) const
404{
405 if (!d->squeezedText.isEmpty() && d->squeezedStart)
406 {
407 int start, end;
408 KLineEdit *that = const_cast<KLineEdit *>(this);
409 if (!that->getSelection(&start, &end))
410 return false;
411 if (start >= d->squeezedStart+3)
412 start = start - 3 - d->squeezedStart + d->squeezedEnd;
413 else if (start > d->squeezedStart)
414 start = d->squeezedStart;
415 if (end >= d->squeezedStart+3)
416 end = end - 3 - d->squeezedStart + d->squeezedEnd;
417 else if (end > d->squeezedStart)
418 end = d->squeezedEnd;
419 if (start == end)
420 return false;
421 TQString t = d->squeezedText;
422 t = t.mid(start, end - start);
423 disconnect( TQApplication::clipboard(), TQ_SIGNAL(selectionChanged()), this, 0);
424 TQApplication::clipboard()->setText( t, clipboard ? TQClipboard::Clipboard : TQClipboard::Selection );
425 connect( TQApplication::clipboard(), TQ_SIGNAL(selectionChanged()), this,
426 TQ_SLOT(clipboardChanged()) );
427 return true;
428 }
429 return false;
430}
431
432void KLineEdit::resizeEvent( TQResizeEvent * ev )
433{
434 if (!d->squeezedText.isEmpty())
435 setSqueezedText();
436
437 TQLineEdit::resizeEvent(ev);
438}
439
440void KLineEdit::keyPressEvent( TQKeyEvent *e )
441{
442 KKey key( e );
443
444 if ( TDEStdAccel::copy().contains( key ) )
445 {
446 copy();
447 return;
448 }
449 else if ( TDEStdAccel::paste().contains( key ) )
450 {
451 paste();
452 return;
453 }
454 else if ( TDEStdAccel::pasteSelection().contains( key ) )
455 {
456 TQString text = TQApplication::clipboard()->text( TQClipboard::Selection);
457 insert( text );
458 deselect();
459 return;
460 }
461
462 else if ( TDEStdAccel::cut().contains( key ) )
463 {
464 cut();
465 return;
466 }
467 else if ( TDEStdAccel::undo().contains( key ) )
468 {
469 undo();
470 return;
471 }
472 else if ( TDEStdAccel::redo().contains( key ) )
473 {
474 redo();
475 return;
476 }
477 else if ( TDEStdAccel::deleteWordBack().contains( key ) )
478 {
479 cursorWordBackward(true);
480 if ( hasSelectedText() )
481 del();
482
483 e->accept();
484 return;
485 }
486 else if ( TDEStdAccel::deleteWordForward().contains( key ) )
487 {
488 // Workaround for QT bug where
489 cursorWordForward(true);
490 if ( hasSelectedText() )
491 del();
492
493 e->accept();
494 return;
495 }
496 else if ( TDEStdAccel::backwardWord().contains( key ) )
497 {
498 cursorWordBackward(false);
499 e->accept();
500 return;
501 }
502 else if ( TDEStdAccel::forwardWord().contains( key ) )
503 {
504 cursorWordForward(false);
505 e->accept();
506 return;
507 }
508 else if ( TDEStdAccel::beginningOfLine().contains( key ) )
509 {
510 home(false);
511 e->accept();
512 return;
513 }
514 else if ( TDEStdAccel::endOfLine().contains( key ) )
515 {
516 end(false);
517 e->accept();
518 return;
519 }
520
521
522 // Filter key-events if EchoMode is normal and
523 // completion mode is not set to CompletionNone
524 if ( echoMode() == TQLineEdit::Normal &&
525 completionMode() != TDEGlobalSettings::CompletionNone )
526 {
527 KeyBindingMap keys = getKeyBindings();
528 TDEGlobalSettings::Completion mode = completionMode();
529 bool noModifier = (e->state() == TQt::NoButton ||
530 e->state() == TQt::ShiftButton ||
531 e->state() == TQt::Keypad);
532
533 if ( (mode == TDEGlobalSettings::CompletionAuto ||
534 mode == TDEGlobalSettings::CompletionPopupAuto ||
535 mode == TDEGlobalSettings::CompletionMan) && noModifier )
536 {
537 if ( !d->userSelection && hasSelectedText() &&
538 ( e->key() == Key_Right || e->key() == Key_Left ) &&
539 e->state()== TQt::NoButton )
540 {
541 TQString old_txt = text();
542 d->disableRestoreSelection = true;
543 int start,end;
544 getSelection(&start, &end);
545
546 deselect();
547 TQLineEdit::keyPressEvent ( e );
548 int cPosition=cursorPosition();
549 if (e->key() ==Key_Right && cPosition > start )
550 validateAndSet(old_txt, cPosition, cPosition, old_txt.length());
551 else
552 validateAndSet(old_txt, cPosition, start, old_txt.length());
553
554 d->disableRestoreSelection = false;
555 return;
556 }
557
558 if ( e->key() == Key_Escape )
559 {
560 if (hasSelectedText() && !d->userSelection )
561 {
562 del();
563 setUserSelection(true);
564 }
565
566 // Don't swallow the Escape press event for the case
567 // of dialogs, which have Escape associated to Cancel
568 e->ignore();
569 return;
570 }
571
572 }
573
574 if ( (mode == TDEGlobalSettings::CompletionAuto ||
575 mode == TDEGlobalSettings::CompletionMan) && noModifier )
576 {
577 TQString keycode = e->text();
578 if ( !keycode.isEmpty() && (keycode.unicode()->isPrint() ||
579 e->key() == Key_Backspace || e->key() == Key_Delete ) )
580 {
581 bool hasUserSelection=d->userSelection;
582 bool hadSelection=hasSelectedText();
583
584 bool cursorNotAtEnd=false;
585
586 int start,end;
587 getSelection(&start, &end);
588 int cPos = cursorPosition();
589
590 // When moving the cursor, we want to keep the autocompletion as an
591 // autocompletion, so we want to process events at the cursor position
592 // as if there was no selection. After processing the key event, we
593 // can set the new autocompletion again.
594 if ( hadSelection && !hasUserSelection && start>cPos )
595 {
596 del();
597 setCursorPosition(cPos);
598 cursorNotAtEnd=true;
599 }
600
601 d->disableRestoreSelection = true;
602 TQLineEdit::keyPressEvent ( e );
603 d->disableRestoreSelection = false;
604
605 TQString txt = text();
606 int len = txt.length();
607 if ( !hasSelectedText() && len /*&& cursorPosition() == len */)
608 {
609 if ( e->key() == Key_Backspace )
610 {
611 if ( hadSelection && !hasUserSelection && !cursorNotAtEnd )
612 {
613 backspace();
614 txt = text();
615 len = txt.length();
616 }
617
618 if ( !d->backspacePerformsCompletion || !len )
619 d->autoSuggest = false;
620 }
621
622 if (e->key() == Key_Delete )
623 d->autoSuggest=false;
624
625 if ( emitSignals() )
626 emit completion( txt );
627
628 if ( handleSignals() )
629 makeCompletion( txt );
630
631 if( (e->key() == Key_Backspace || e->key() == Key_Delete) )
632 d->autoSuggest=true;
633
634 e->accept();
635 }
636
637 return;
638 }
639
640 }
641
642 else if (( mode == TDEGlobalSettings::CompletionPopup ||
643 mode == TDEGlobalSettings::CompletionPopupAuto ) &&
644 noModifier && !e->text().isEmpty() )
645 {
646 TQString old_txt = text();
647 bool hasUserSelection=d->userSelection;
648 bool hadSelection=hasSelectedText();
649 bool cursorNotAtEnd=false;
650
651 int start,end;
652 getSelection(&start, &end);
653 int cPos = cursorPosition();
654 TQString keycode = e->text();
655
656 // When moving the cursor, we want to keep the autocompletion as an
657 // autocompletion, so we want to process events at the cursor position
658 // as if there was no selection. After processing the key event, we
659 // can set the new autocompletion again.
660 if (hadSelection && !hasUserSelection && start>cPos &&
661 ( (!keycode.isEmpty() && keycode.unicode()->isPrint()) ||
662 e->key() == Key_Backspace || e->key() == Key_Delete ) )
663 {
664 del();
665 setCursorPosition(cPos);
666 cursorNotAtEnd=true;
667 }
668
669 uint selectedLength=selectedText().length();
670
671 d->disableRestoreSelection = true;
672 TQLineEdit::keyPressEvent ( e );
673 d->disableRestoreSelection = false;
674
675 if (( selectedLength != selectedText().length() ) && !hasUserSelection )
676 slotRestoreSelectionColors(); // and set userSelection to true
677
678 TQString txt = text();
679 int len = txt.length();
680
681 if ( txt != old_txt && len/* && ( cursorPosition() == len || force )*/ &&
682 ( (!keycode.isEmpty() && keycode.unicode()->isPrint()) ||
683 e->key() == Key_Backspace || e->key() == Key_Delete) )
684 {
685 if ( e->key() == Key_Backspace )
686 {
687 if ( hadSelection && !hasUserSelection && !cursorNotAtEnd )
688 {
689 backspace();
690 txt = text();
691 len = txt.length();
692 }
693
694 if ( !d->backspacePerformsCompletion )
695 d->autoSuggest = false;
696 }
697
698 if (e->key() == Key_Delete )
699 d->autoSuggest=false;
700
701 if ( d->completionBox )
702 d->completionBox->setCancelledText( txt );
703
704 if ( emitSignals() )
705 emit completion( txt ); // emit when requested...
706
707 if ( handleSignals() ) {
708 makeCompletion( txt ); // handle when requested...
709 }
710
711 if ( (e->key() == Key_Backspace || e->key() == Key_Delete ) &&
712 mode == TDEGlobalSettings::CompletionPopupAuto )
713 d->autoSuggest=true;
714
715 e->accept();
716 }
717 else if (!len && d->completionBox && d->completionBox->isVisible())
718 d->completionBox->hide();
719
720 return;
721 }
722
723 else if ( mode == TDEGlobalSettings::CompletionShell )
724 {
725 // Handles completion.
726 TDEShortcut cut;
727 if ( keys[TextCompletion].isNull() )
728 cut = TDEStdAccel::shortcut(TDEStdAccel::TextCompletion);
729 else
730 cut = keys[TextCompletion];
731
732 if ( cut.contains( key ) )
733 {
734 // Emit completion if the completion mode is CompletionShell
735 // and the cursor is at the end of the string.
736 TQString txt = text();
737 int len = txt.length();
738 if ( cursorPosition() == len && len != 0 )
739 {
740 if ( emitSignals() )
741 emit completion( txt );
742 if ( handleSignals() )
743 makeCompletion( txt );
744 return;
745 }
746 }
747 else if ( d->completionBox )
748 d->completionBox->hide();
749 }
750
751 // handle rotation
752 if ( mode != TDEGlobalSettings::CompletionNone )
753 {
754 // Handles previous match
755 TDEShortcut cut;
756 if ( keys[PrevCompletionMatch].isNull() )
757 cut = TDEStdAccel::shortcut(TDEStdAccel::PrevCompletion);
758 else
759 cut = keys[PrevCompletionMatch];
760
761 if ( cut.contains( key ) )
762 {
763 if ( emitSignals() )
764 emit textRotation( TDECompletionBase::PrevCompletionMatch );
765 if ( handleSignals() )
766 rotateText( TDECompletionBase::PrevCompletionMatch );
767 return;
768 }
769
770 // Handles next match
771 if ( keys[NextCompletionMatch].isNull() )
772 cut = TDEStdAccel::shortcut(TDEStdAccel::NextCompletion);
773 else
774 cut = keys[NextCompletionMatch];
775
776 if ( cut.contains( key ) )
777 {
778 if ( emitSignals() )
779 emit textRotation( TDECompletionBase::NextCompletionMatch );
780 if ( handleSignals() )
781 rotateText( TDECompletionBase::NextCompletionMatch );
782 return;
783 }
784 }
785
786 // substring completion
787 if ( compObj() )
788 {
789 TDEShortcut cut;
790 if ( keys[SubstringCompletion].isNull() )
791 cut = TDEStdAccel::shortcut(TDEStdAccel::SubstringCompletion);
792 else
793 cut = keys[SubstringCompletion];
794
795 if ( cut.contains( key ) )
796 {
797 if ( emitSignals() )
798 emit substringCompletion( text() );
799 if ( handleSignals() )
800 {
801 setCompletedItems( compObj()->substringCompletion(text()));
802 e->accept();
803 }
804 return;
805 }
806 }
807 }
808
809 uint selectedLength = selectedText().length();
810
811 // Let TQLineEdit handle any other keys events.
812 TQLineEdit::keyPressEvent ( e );
813
814 if ( selectedLength != selectedText().length() )
815 slotRestoreSelectionColors(); // and set userSelection to true
816}
817
818void KLineEdit::mouseDoubleClickEvent( TQMouseEvent* e )
819{
820 if ( e->button() == TQt::LeftButton )
821 {
822 possibleTripleClick=true;
823 TQTimer::singleShot( TQApplication::doubleClickInterval(),this,
824 TQ_SLOT(tripleClickTimeout()) );
825 }
826 TQLineEdit::mouseDoubleClickEvent( e );
827}
828
829void KLineEdit::mousePressEvent( TQMouseEvent* e )
830{
831 if ( possibleTripleClick && e->button() == TQt::LeftButton )
832 {
833 selectAll();
834 e->accept();
835 return;
836 }
837 TQLineEdit::mousePressEvent( e );
838}
839
840void KLineEdit::mouseReleaseEvent( TQMouseEvent* e )
841{
842 TQLineEdit::mouseReleaseEvent( e );
843 if (TQApplication::clipboard()->supportsSelection() ) {
844 if ( e->button() == TQt::LeftButton ) {
845 // Fix copying of squeezed text if needed
846 copySqueezedText( false );
847 }
848 }
849}
850
851void KLineEdit::tripleClickTimeout()
852{
853 possibleTripleClick=false;
854}
855
856void KLineEdit::contextMenuEvent( TQContextMenuEvent * e )
857{
858 if ( m_bEnableMenu )
859 TQLineEdit::contextMenuEvent( e );
860}
861
862TQPopupMenu *KLineEdit::createPopupMenu()
863{
864 enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
865
866 TQPopupMenu *popup = TQLineEdit::createPopupMenu();
867
868 int id = popup->idAt(0);
869 popup->changeItem( id - IdUndo, SmallIconSet("edit-undo"), popup->text( id - IdUndo) );
870 popup->changeItem( id - IdRedo, SmallIconSet("edit-redo"), popup->text( id - IdRedo) );
871 popup->changeItem( id - IdCut, SmallIconSet("edit-cut"), popup->text( id - IdCut) );
872 popup->changeItem( id - IdCopy, SmallIconSet("edit-copy"), popup->text( id - IdCopy) );
873 popup->changeItem( id - IdPaste, SmallIconSet("edit-paste"), popup->text( id - IdPaste) );
874 popup->changeItem( id - IdClear, SmallIconSet("edit-clear"), popup->text( id - IdClear) );
875
876 // If a completion object is present and the input
877 // widget is not read-only, show the Text Completion
878 // menu item.
879 if ( compObj() && !isReadOnly() && tdeApp->authorize("lineedit_text_completion") )
880 {
881 TQPopupMenu *subMenu = new TQPopupMenu( popup );
882 connect( subMenu, TQ_SIGNAL( activated( int ) ),
883 this, TQ_SLOT( completionMenuActivated( int ) ) );
884
885 popup->insertSeparator();
886 popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"),
887 subMenu );
888
889 subMenu->insertItem( i18n("None"), NoCompletion );
890 subMenu->insertItem( i18n("Manual"), ShellCompletion );
891 subMenu->insertItem( i18n("Automatic"), AutoCompletion );
892 subMenu->insertItem( i18n("Dropdown List"), PopupCompletion );
893 subMenu->insertItem( i18n("Short Automatic"), ShortAutoCompletion );
894 subMenu->insertItem( i18n("Dropdown List && Automatic"), PopupAutoCompletion );
895
896 subMenu->setAccel( TDEStdAccel::completion(), ShellCompletion );
897
898 TDEGlobalSettings::Completion mode = completionMode();
899 subMenu->setItemChecked( NoCompletion,
900 mode == TDEGlobalSettings::CompletionNone );
901 subMenu->setItemChecked( ShellCompletion,
902 mode == TDEGlobalSettings::CompletionShell );
903 subMenu->setItemChecked( PopupCompletion,
904 mode == TDEGlobalSettings::CompletionPopup );
905 subMenu->setItemChecked( AutoCompletion,
906 mode == TDEGlobalSettings::CompletionAuto );
907 subMenu->setItemChecked( ShortAutoCompletion,
908 mode == TDEGlobalSettings::CompletionMan );
909 subMenu->setItemChecked( PopupAutoCompletion,
910 mode == TDEGlobalSettings::CompletionPopupAuto );
911 if ( mode != TDEGlobalSettings::completionMode() )
912 {
913 subMenu->insertSeparator();
914 subMenu->insertItem( i18n("Default"), Default );
915 }
916 }
917
918 // ### do we really need this? Yes, Please do not remove! This
919 // allows applications to extend the popup menu without having to
920 // inherit from this class! (DA)
921 emit aboutToShowContextMenu( popup );
922
923 return popup;
924}
925
926void KLineEdit::completionMenuActivated( int id )
927{
928 TDEGlobalSettings::Completion oldMode = completionMode();
929
930 switch ( id )
931 {
932 case Default:
933 setCompletionMode( TDEGlobalSettings::completionMode() );
934 break;
935 case NoCompletion:
936 setCompletionMode( TDEGlobalSettings::CompletionNone );
937 break;
938 case AutoCompletion:
939 setCompletionMode( TDEGlobalSettings::CompletionAuto );
940 break;
941 case ShortAutoCompletion:
942 setCompletionMode( TDEGlobalSettings::CompletionMan );
943 break;
944 case ShellCompletion:
945 setCompletionMode( TDEGlobalSettings::CompletionShell );
946 break;
947 case PopupCompletion:
948 setCompletionMode( TDEGlobalSettings::CompletionPopup );
949 break;
950 case PopupAutoCompletion:
951 setCompletionMode( TDEGlobalSettings::CompletionPopupAuto );
952 break;
953 default:
954 return;
955 }
956
957 if ( oldMode != completionMode() )
958 {
959 if ( (oldMode == TDEGlobalSettings::CompletionPopup ||
960 oldMode == TDEGlobalSettings::CompletionPopupAuto ) &&
961 d->completionBox && d->completionBox->isVisible() )
962 d->completionBox->hide();
963 emit completionModeChanged( completionMode() );
964 }
965}
966
967void KLineEdit::drawContents( TQPainter *p )
968{
969 TQLineEdit::drawContents( p );
970
971 if ( d->drawClickMsg && !hasFocus() ) {
972 TQPen tmp = p->pen();
973 p->setPen( palette().color( TQPalette::Disabled, TQColorGroup::Text ) );
974 TQRect cr = contentsRect();
975
976 // Add two pixel margin on the left side
977 cr.rLeft() += 3;
978 p->drawText( cr, AlignAuto | AlignVCenter, d->clickMessage );
979 p->setPen( tmp );
980 }
981}
982
983void KLineEdit::dropEvent(TQDropEvent *e)
984{
985 d->drawClickMsg = false;
986 KURL::List urlList;
987 if( d->handleURLDrops && KURLDrag::decode( e, urlList ) )
988 {
989 TQString dropText = text();
990 KURL::List::ConstIterator it;
991 for( it = urlList.begin() ; it != urlList.end() ; ++it )
992 {
993 if(!dropText.isEmpty())
994 dropText+=' ';
995
996 dropText += (*it).prettyURL();
997 }
998
999 validateAndSet( dropText, dropText.length(), 0, 0);
1000
1001 e->accept();
1002 }
1003 else
1004 TQLineEdit::dropEvent(e);
1005}
1006
1007bool KLineEdit::eventFilter( TQObject* o, TQEvent* ev )
1008{
1009 if( o == this )
1010 {
1011 KCursor::autoHideEventFilter( this, ev );
1012 if ( ev->type() == TQEvent::AccelOverride )
1013 {
1014 TQKeyEvent *e = static_cast<TQKeyEvent*>( ev );
1015 if (overrideAccel (e))
1016 {
1017 e->accept();
1018 return true;
1019 }
1020 }
1021 else if( ev->type() == TQEvent::KeyPress )
1022 {
1023 TQKeyEvent *e = static_cast<TQKeyEvent*>( ev );
1024
1025 if( e->key() == TQt::Key_Return || e->key() == TQt::Key_Enter )
1026 {
1027 bool trap = d->completionBox && d->completionBox->isVisible();
1028
1029 bool stopEvent = trap || (d->grabReturnKeyEvents &&
1030 (e->state() == TQt::NoButton ||
1031 e->state() == TQt::Keypad));
1032
1033 // Qt will emit returnPressed() itself if we return false
1034 if ( stopEvent )
1035 {
1036 emit TQLineEdit::returnPressed();
1037 e->accept ();
1038 }
1039
1040 emit returnPressed( displayText() );
1041
1042 if ( trap )
1043 {
1044 d->completionBox->hide();
1045 deselect();
1046 setCursorPosition(text().length());
1047 }
1048
1049 // Eat the event if the user asked for it, or if a completionbox was visible
1050 return stopEvent;
1051 }
1052 }
1053 }
1054 return TQLineEdit::eventFilter( o, ev );
1055}
1056
1057
1058void KLineEdit::setURLDropsEnabled(bool enable)
1059{
1060 d->handleURLDrops=enable;
1061}
1062
1063bool KLineEdit::isURLDropsEnabled() const
1064{
1065 return d->handleURLDrops;
1066}
1067
1068void KLineEdit::setTrapReturnKey( bool grab )
1069{
1070 d->grabReturnKeyEvents = grab;
1071}
1072
1073bool KLineEdit::trapReturnKey() const
1074{
1075 return d->grabReturnKeyEvents;
1076}
1077
1078void KLineEdit::setURL( const KURL& url )
1079{
1080 setText( url.prettyURL() );
1081}
1082
1083void KLineEdit::setCompletionBox( TDECompletionBox *box )
1084{
1085 if ( d->completionBox )
1086 return;
1087
1088 d->completionBox = box;
1089 if ( handleSignals() )
1090 {
1091 connect( d->completionBox, TQ_SIGNAL(highlighted( const TQString& )),
1092 TQ_SLOT(setTextWorkaround( const TQString& )) );
1093 connect( d->completionBox, TQ_SIGNAL(userCancelled( const TQString& )),
1094 TQ_SLOT(userCancelled( const TQString& )) );
1095 connect( d->completionBox, TQ_SIGNAL( activated( const TQString& )),
1096 TQ_SIGNAL(completionBoxActivated( const TQString& )) );
1097 }
1098}
1099
1100void KLineEdit::userCancelled(const TQString & cancelText)
1101{
1102 if ( completionMode() != TDEGlobalSettings::CompletionPopupAuto )
1103 {
1104 // TODO: this sets modified==false. But maybe it was true before...
1105 setText(cancelText);
1106 }
1107 else if (hasSelectedText() )
1108 {
1109 if (d->userSelection)
1110 deselect();
1111 else
1112 {
1113 d->autoSuggest=false;
1114 int start,end;
1115 getSelection(&start, &end);
1116 TQString s=text().remove(start, end-start+1);
1117 validateAndSet(s,start,s.length(),s.length());
1118 d->autoSuggest=true;
1119 }
1120 }
1121}
1122
1123bool KLineEdit::overrideAccel (const TQKeyEvent* e)
1124{
1125 TDEShortcut scKey;
1126
1127 KKey key( e );
1128 KeyBindingMap keys = getKeyBindings();
1129
1130 if (keys[TextCompletion].isNull())
1131 scKey = TDEStdAccel::shortcut(TDEStdAccel::TextCompletion);
1132 else
1133 scKey = keys[TextCompletion];
1134
1135 if (scKey.contains( key ))
1136 return true;
1137
1138 if (keys[NextCompletionMatch].isNull())
1139 scKey = TDEStdAccel::shortcut(TDEStdAccel::NextCompletion);
1140 else
1141 scKey = keys[NextCompletionMatch];
1142
1143 if (scKey.contains( key ))
1144 return true;
1145
1146 if (keys[PrevCompletionMatch].isNull())
1147 scKey = TDEStdAccel::shortcut(TDEStdAccel::PrevCompletion);
1148 else
1149 scKey = keys[PrevCompletionMatch];
1150
1151 if (scKey.contains( key ))
1152 return true;
1153
1154 // Override all the text manupilation accelerators...
1155 if ( TDEStdAccel::copy().contains( key ) )
1156 return true;
1157 else if ( TDEStdAccel::paste().contains( key ) )
1158 return true;
1159 else if ( TDEStdAccel::cut().contains( key ) )
1160 return true;
1161 else if ( TDEStdAccel::undo().contains( key ) )
1162 return true;
1163 else if ( TDEStdAccel::redo().contains( key ) )
1164 return true;
1165 else if (TDEStdAccel::deleteWordBack().contains( key ))
1166 return true;
1167 else if (TDEStdAccel::deleteWordForward().contains( key ))
1168 return true;
1169 else if (TDEStdAccel::forwardWord().contains( key ))
1170 return true;
1171 else if (TDEStdAccel::backwardWord().contains( key ))
1172 return true;
1173 else if (TDEStdAccel::beginningOfLine().contains( key ))
1174 return true;
1175 else if (TDEStdAccel::endOfLine().contains( key ))
1176 return true;
1177
1178 if (d->completionBox && d->completionBox->isVisible ())
1179 {
1180 int key = e->key();
1181 ButtonState state = e->state();
1182 if ((key == Key_Backtab || key == Key_Tab) &&
1183 (state == TQt::NoButton || (state & TQt::ShiftButton)))
1184 {
1185 return true;
1186 }
1187 }
1188
1189
1190 return false;
1191}
1192
1193void KLineEdit::setCompletedItems( const TQStringList& items )
1194{
1195 setCompletedItems( items, true );
1196}
1197
1198void KLineEdit::setCompletedItems( const TQStringList& items, bool autoSuggest )
1199{
1200 TQString txt;
1201 if ( d->completionBox && d->completionBox->isVisible() ) {
1202 // The popup is visible already - do the matching on the initial string,
1203 // not on the currently selected one.
1204 txt = completionBox()->cancelledText();
1205 } else {
1206 txt = text();
1207 }
1208
1209 if ( !items.isEmpty() &&
1210 !(items.count() == 1 && txt == items.first()) )
1211 {
1212 // create completion box if non-existent
1213 completionBox();
1214
1215 if ( d->completionBox->isVisible() )
1216 {
1217 bool wasSelected = d->completionBox->isSelected( d->completionBox->currentItem() );
1218 const TQString currentSelection = d->completionBox->currentText();
1219 d->completionBox->setItems( items );
1220 TQListBoxItem* item = d->completionBox->findItem( currentSelection, TQt::ExactMatch );
1221 // If no item is selected, that means the listbox hasn't been manipulated by the user yet,
1222 // because it's not possible otherwise to have no selected item. In such case make
1223 // always the first item current and unselected, so that the current item doesn't jump.
1224 if( !item || !wasSelected )
1225 {
1226 wasSelected = false;
1227 item = d->completionBox->item( 0 );
1228 }
1229 if ( item )
1230 {
1231 d->completionBox->blockSignals( true );
1232 d->completionBox->setCurrentItem( item );
1233 d->completionBox->setSelected( item, wasSelected );
1234 d->completionBox->blockSignals( false );
1235 }
1236 }
1237 else // completion box not visible yet -> show it
1238 {
1239 if ( !txt.isEmpty() )
1240 d->completionBox->setCancelledText( txt );
1241 d->completionBox->setItems( items );
1242 d->completionBox->popup();
1243 }
1244
1245 if ( d->autoSuggest && autoSuggest )
1246 {
1247 int index = items.first().find( txt );
1248 TQString newText = items.first().mid( index );
1249 setUserSelection(false);
1250 setCompletedText(newText,true);
1251 }
1252 }
1253 else
1254 {
1255 if ( d->completionBox && d->completionBox->isVisible() )
1256 d->completionBox->hide();
1257 }
1258}
1259
1260TDECompletionBox * KLineEdit::completionBox( bool create )
1261{
1262 if ( create && !d->completionBox ) {
1263 setCompletionBox( new TDECompletionBox( this, "completion box" ) );
1264 d->completionBox->setFont(font());
1265 }
1266
1267 return d->completionBox;
1268}
1269
1270void KLineEdit::setCompletionObject( TDECompletion* comp, bool hsig )
1271{
1272 TDECompletion *oldComp = compObj();
1273 if ( oldComp && handleSignals() )
1274 disconnect( oldComp, TQ_SIGNAL( matches( const TQStringList& )),
1275 this, TQ_SLOT( setCompletedItems( const TQStringList& )));
1276
1277 if ( comp && hsig )
1278 connect( comp, TQ_SIGNAL( matches( const TQStringList& )),
1279 this, TQ_SLOT( setCompletedItems( const TQStringList& )));
1280
1281 TDECompletionBase::setCompletionObject( comp, hsig );
1282}
1283
1284// TQWidget::create() turns off mouse-Tracking which would break auto-hiding
1285void KLineEdit::create( WId id, bool initializeWindow, bool destroyOldWindow )
1286{
1287 TQLineEdit::create( id, initializeWindow, destroyOldWindow );
1288 KCursor::setAutoHideCursor( this, true, true );
1289}
1290
1291void KLineEdit::setUserSelection(bool userSelection)
1292{
1293 TQPalette p = palette();
1294
1295 if (userSelection)
1296 {
1297 p.setColor(TQColorGroup::Highlight, d->previousHighlightColor);
1298 p.setColor(TQColorGroup::HighlightedText, d->previousHighlightedTextColor);
1299 }
1300 else
1301 {
1302 TQColor color=p.color(TQPalette::Disabled, TQColorGroup::Text);
1303 p.setColor(TQColorGroup::HighlightedText, color);
1304 color=p.color(TQPalette::Active, TQColorGroup::Base);
1305 p.setColor(TQColorGroup::Highlight, color);
1306 }
1307
1308 d->userSelection=userSelection;
1309 setPalette(p);
1310}
1311
1312void KLineEdit::slotRestoreSelectionColors()
1313{
1314 if (d->disableRestoreSelection)
1315 return;
1316
1317 setUserSelection(true);
1318}
1319
1320void KLineEdit::clear()
1321{
1322 setText( TQString::null );
1323}
1324
1325void KLineEdit::setTextWorkaround( const TQString& text )
1326{
1327 setText( text );
1328 end( false ); // force cursor at end
1329}
1330
1331TQString KLineEdit::originalText() const
1332{
1333 if ( d->enableSqueezedText && isReadOnly() )
1334 return d->squeezedText;
1335
1336 return text();
1337}
1338
1339void KLineEdit::focusInEvent( TQFocusEvent* ev)
1340{
1341 if ( d->drawClickMsg ) {
1342 d->drawClickMsg = false;
1343 update();
1344 }
1345
1346 // Don't selectAll() in TQLineEdit::focusInEvent if selection exists
1347 if ( ev->reason() == TQFocusEvent::Tab && inputMask().isNull() && hasSelectedText() )
1348 return;
1349
1350 TQLineEdit::focusInEvent(ev);
1351}
1352
1353void KLineEdit::focusOutEvent( TQFocusEvent* ev)
1354{
1355 if ( text().isEmpty() && !d->clickMessage.isEmpty() ) {
1356 d->drawClickMsg = true;
1357 update();
1358 }
1359 TQLineEdit::focusOutEvent( ev );
1360}
1361
1362bool KLineEdit::autoSuggest() const
1363{
1364 return d->autoSuggest;
1365}
1366
1367void KLineEdit::setClickMessage( const TQString &msg )
1368{
1369 d->clickMessage = msg;
1370 update();
1371}
1372
1373TQString KLineEdit::clickMessage() const
1374{
1375 return d->clickMessage;
1376}
1377
1378
1379void KLineEdit::virtual_hook( int id, void* data )
1380{ TDECompletionBase::virtual_hook( id, data ); }
KCursor::setAutoHideCursor
static void setAutoHideCursor(TQWidget *w, bool enable)
Sets auto-hiding the cursor for widget w.
Definition: kcursor.cpp:218
KCursor::autoHideEventFilter
static void autoHideEventFilter(TQObject *, TQEvent *)
KCursor has to install an eventFilter over the widget you want to auto-hide.
Definition: kcursor.cpp:229
KKey
KLineEdit
An enhanced TQLineEdit widget for inputting text.
Definition: klineedit.h:146
KLineEdit::setCompletedText
virtual void setCompletedText(const TQString &)
See TDECompletionBase::setCompletedText.
Definition: klineedit.cpp:195
KLineEdit::trapReturnKey
bool trapReturnKey() const
Definition: klineedit.cpp:1073
KLineEdit::~KLineEdit
virtual ~KLineEdit()
Destructor.
Definition: klineedit.cpp:118
KLineEdit::createPopupMenu
virtual TQPopupMenu * createPopupMenu()
Re-implemented for internal reasons.
Definition: klineedit.cpp:862
KLineEdit::textRotation
void textRotation(TDECompletionBase::KeyBindingType)
Emitted when the text rotation key-bindings are pressed.
KLineEdit::returnPressed
void returnPressed(const TQString &)
Emitted when the user presses the return key.
KLineEdit::dropEvent
virtual void dropEvent(TQDropEvent *)
Re-implemented to handle URI drops.
Definition: klineedit.cpp:983
KLineEdit::setURLDropsEnabled
void setURLDropsEnabled(bool enable)
Enables/Disables handling of URL drops.
Definition: klineedit.cpp:1058
KLineEdit::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(TQMouseEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:818
KLineEdit::setTrapReturnKey
void setTrapReturnKey(bool trap)
By default, KLineEdit recognizes Key_Return and Key_Enter and emits the returnPressed() signals,...
Definition: klineedit.cpp:1068
KLineEdit::setReadOnly
virtual void setReadOnly(bool)
Re-implemented for internal reasons.
Definition: klineedit.cpp:265
KLineEdit::setCompletionBox
void setCompletionBox(TDECompletionBox *box)
Set the completion-box to be used in completion mode TDEGlobalSettings::CompletionPopup.
Definition: klineedit.cpp:1083
KLineEdit::setClickMessage
void setClickMessage(const TQString &msg)
This makes the line edit display a grayed-out hinting text as long as the user didn't enter any text.
Definition: klineedit.cpp:1367
KLineEdit::setText
virtual void setText(const TQString &)
Re-implemented to enable text squeezing.
Definition: klineedit.cpp:310
KLineEdit::focusOutEvent
virtual void focusOutEvent(TQFocusEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1353
KLineEdit::focusInEvent
virtual void focusInEvent(TQFocusEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1339
KLineEdit::isURLDropsEnabled
bool isURLDropsEnabled() const
Returns true when decoded URL drops are enabled.
Definition: klineedit.cpp:1063
KLineEdit::contextMenuEvent
virtual void contextMenuEvent(TQContextMenuEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:856
KLineEdit::setURL
void setURL(const KURL &url)
Sets url into the lineedit.
Definition: klineedit.cpp:1078
KLineEdit::rotateText
void rotateText(TDECompletionBase::KeyBindingType type)
Iterates through all possible matches of the completed text or the history list.
Definition: klineedit.cpp:205
KLineEdit::setEnableSqueezedText
void setEnableSqueezedText(bool enable)
Enable text squeezing whenever the supplied text is too long.
Definition: klineedit.cpp:300
KLineEdit::setCompletionMode
virtual void setCompletionMode(TDEGlobalSettings::Completion mode)
Re-implemented from TDECompletionBase for internal reasons.
Definition: klineedit.cpp:150
KLineEdit::mouseReleaseEvent
virtual void mouseReleaseEvent(TQMouseEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:840
KLineEdit::completionBox
TDECompletionBox * completionBox(bool create=true)
Definition: klineedit.cpp:1260
KLineEdit::setUserSelection
void setUserSelection(bool userSelection)
Sets the widget in userSelection mode or in automatic completion selection mode.
Definition: klineedit.cpp:1291
KLineEdit::clickMessage
TQString clickMessage() const
Definition: klineedit.cpp:1373
KLineEdit::substringCompletion
void substringCompletion(const TQString &)
Emitted when the shortcut for substring completion is pressed.
KLineEdit::mousePressEvent
virtual void mousePressEvent(TQMouseEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:829
KLineEdit::setCompletionObject
virtual void setCompletionObject(TDECompletion *, bool hsig=true)
Reimplemented for internal reasons, the API is not affected.
Definition: klineedit.cpp:1270
KLineEdit::completionBoxActivated
void completionBoxActivated(const TQString &)
Emitted whenever the completion box is activated.
KLineEdit::autoSuggest
bool autoSuggest() const
Whether in current state text should be auto-suggested.
Definition: klineedit.cpp:1362
KLineEdit::completionModeChanged
void completionModeChanged(TDEGlobalSettings::Completion)
Emitted when the user changed the completion mode by using the popupmenu.
KLineEdit::setContextMenuEnabled
virtual void setContextMenuEnabled(bool showMenu)
Enables/disables the popup (context) menu.
Definition: klineedit.h:223
KLineEdit::eventFilter
virtual bool eventFilter(TQObject *, TQEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1007
KLineEdit::completion
void completion(const TQString &)
Emitted when the completion key is pressed.
KLineEdit::userCancelled
void userCancelled(const TQString &cancelText)
Resets the current displayed text.
Definition: klineedit.cpp:1100
KLineEdit::aboutToShowContextMenu
void aboutToShowContextMenu(TQPopupMenu *p)
Emitted before the context menu is displayed.
KLineEdit::drawContents
virtual void drawContents(TQPainter *p)
Re-implemented for internal reasons.
Definition: klineedit.cpp:967
KLineEdit::keyPressEvent
virtual void keyPressEvent(TQKeyEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:440
KLineEdit::makeCompletion
virtual void makeCompletion(const TQString &)
Completes the remaining text with a matching one from a given list.
Definition: klineedit.cpp:226
KLineEdit::copy
virtual void copy() const
Reimplemented for internal reasons, the API is not affected.
Definition: klineedit.cpp:397
KLineEdit::resizeEvent
virtual void resizeEvent(TQResizeEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:432
KLineEdit::setCompletedItems
void setCompletedItems(const TQStringList &items)
Sets items into the completion-box if completionMode() is CompletionPopup.
Definition: klineedit.cpp:1193
KLineEdit::isSqueezedTextEnabled
bool isSqueezedTextEnabled() const
Returns true if text squeezing is enabled.
Definition: klineedit.cpp:305
KLineEdit::clear
virtual void clear()
Reimplemented to workaround a buggy TQLineEdit::clear() (changing the clipboard to the text we just h...
Definition: klineedit.cpp:1320
KLineEdit::KLineEdit
KLineEdit(const TQString &string, TQWidget *parent, const char *name=0)
Constructs a KLineEdit object with a default text, a parent, and a name.
Definition: klineedit.cpp:106
KLineEdit::setSqueezedText
void setSqueezedText(const TQString &text)
Squeezes text into the line edit.
Definition: klineedit.cpp:294
KLineEdit::create
virtual void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Reimplemented for internal reasons, the API is not affected.
Definition: klineedit.cpp:1285
KLineEdit::originalText
TQString originalText() const
Returns the original text if text squeezing is enabled.
Definition: klineedit.cpp:1331
KURLDrag::decode
static bool decode(const TQMimeSource *e, KURL::List &urls)
KURL::List
KURL
KURL::prettyURL
TQString prettyURL(int _trailing=0) const
TDECompletionBase::compObj
TDECompletion * compObj() const
TDECompletionBase::completionMode
TDEGlobalSettings::Completion completionMode() const
TDECompletionBase::getKeyBindings
KeyBindingMap getKeyBindings() const
TDECompletionBase::handleSignals
bool handleSignals() const
TDECompletionBase::setCompletionMode
virtual void setCompletionMode(TDEGlobalSettings::Completion mode)
TDECompletionBase::setCompletionObject
virtual void setCompletionObject(TDECompletion *compObj, bool hsig=true)
TDECompletionBase::emitSignals
bool emitSignals() const
TDECompletionBase::KeyBindingType
KeyBindingType
TDECompletionBase::TextCompletion
TextCompletion
TDECompletionBase::SubstringCompletion
SubstringCompletion
TDECompletionBase::PrevCompletionMatch
PrevCompletionMatch
TDECompletionBase::NextCompletionMatch
NextCompletionMatch
TDECompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: tdecompletionbox.h:44
TDECompletionBox::cancelledText
TQString cancelledText() const
Definition: tdecompletionbox.cpp:441
TDECompletion
TDECompletion::previousMatch
TQString previousMatch()
TDECompletion::allMatches
TQStringList allMatches()
TDECompletion::makeCompletion
virtual TQString makeCompletion(const TQString &string)
TDECompletion::nextMatch
TQString nextMatch()
TDEConfigGroup
TDEGlobalSettings::Completion
Completion
TDEGlobalSettings::CompletionNone
CompletionNone
TDEGlobalSettings::CompletionShell
CompletionShell
TDEGlobalSettings::CompletionAuto
CompletionAuto
TDEGlobalSettings::CompletionPopup
CompletionPopup
TDEGlobalSettings::CompletionMan
CompletionMan
TDEGlobalSettings::CompletionPopupAuto
CompletionPopupAuto
TDEGlobalSettings::completionMode
static Completion completionMode()
TDEGlobal::config
static TDEConfig * config()
TDEShortcut
TDEShortcut::contains
bool contains(const KKey &key) const
TDEStdAccel::copy
const TDEShortcut & copy()
TDEStdAccel::endOfLine
const TDEShortcut & endOfLine()
TDEStdAccel::paste
const TDEShortcut & paste()
TDEStdAccel::cut
const TDEShortcut & cut()
TDEStdAccel::redo
const TDEShortcut & redo()
TDEStdAccel::forwardWord
const TDEShortcut & forwardWord()
TDEStdAccel::completion
const TDEShortcut & completion()
TDEStdAccel::beginningOfLine
const TDEShortcut & beginningOfLine()
TDEStdAccel::deleteWordBack
const TDEShortcut & deleteWordBack()
TDEStdAccel::undo
const TDEShortcut & undo()
TDEStdAccel::backwardWord
const TDEShortcut & backwardWord()
TDEStdAccel::pasteSelection
const TDEShortcut & pasteSelection()
TDEStdAccel::deleteWordForward
const TDEShortcut & deleteWordForward()
TDEStdAccel::shortcut
const TDEShortcut & shortcut(StdAccel id)
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.