• 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 
49 class KLineEdit::KLineEditPrivate
50 {
51 public:
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 
102 bool KLineEdit::KLineEditPrivate::backspacePerformsCompletion = false;
103 bool KLineEdit::KLineEditPrivate::initialized = false;
104 
105 
106 KLineEdit::KLineEdit( const TQString &string, TQWidget *parent, const char *name )
107  :TQLineEdit( string, parent, name )
108 {
109  init();
110 }
111 
112 KLineEdit::KLineEdit( TQWidget *parent, const char *name )
113  :TQLineEdit( parent, name )
114 {
115  init();
116 }
117 
118 KLineEdit::~KLineEdit ()
119 {
120  delete d;
121  d = 0;
122 }
123 
124 void 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, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotRestoreSelectionColors()));
140 
141  TQPalette p = palette();
142  if ( !d->previousHighlightedTextColor.isValid() )
143  d->previousHighlightedTextColor=p.color(TQPalette::Normal,TQColorGroup::HighlightedText);
144  if ( !d->previousHighlightColor.isValid() )
145  d->previousHighlightColor=p.color(TQPalette::Normal,TQColorGroup::Highlight);
146 
147  d->drawClickMsg = false;
148 }
149 
150 void 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 ( kapp && !kapp->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 
177 void 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 
195 void 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 
205 void 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 
226 void 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 
265 void 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 
294 void KLineEdit::setSqueezedText( const TQString &text)
295 {
296  setEnableSqueezedText(true);
297  setText(text);
298 }
299 
300 void KLineEdit::setEnableSqueezedText( bool enable )
301 {
302  d->enableSqueezedText = enable;
303 }
304 
305 bool KLineEdit::isSqueezedTextEnabled() const
306 {
307  return d->enableSqueezedText;
308 }
309 
310 void 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 
325 void 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 
397 void KLineEdit::copy() const
398 {
399  if( !copySqueezedText(true))
400  TQLineEdit::copy();
401 }
402 
403 bool 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(), TQT_SIGNAL(selectionChanged()), this, 0);
424  TQApplication::clipboard()->setText( t, clipboard ? TQClipboard::Clipboard : TQClipboard::Selection );
425  connect( TQApplication::clipboard(), TQT_SIGNAL(selectionChanged()), this,
426  TQT_SLOT(clipboardChanged()) );
427  return true;
428  }
429  return false;
430 }
431 
432 void KLineEdit::resizeEvent( TQResizeEvent * ev )
433 {
434  if (!d->squeezedText.isEmpty())
435  setSqueezedText();
436 
437  TQLineEdit::resizeEvent(ev);
438 }
439 
440 void 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() == Qt::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()== Qt::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 
818 void KLineEdit::mouseDoubleClickEvent( TQMouseEvent* e )
819 {
820  if ( e->button() == Qt::LeftButton )
821  {
822  possibleTripleClick=true;
823  TQTimer::singleShot( TQApplication::doubleClickInterval(),this,
824  TQT_SLOT(tripleClickTimeout()) );
825  }
826  TQLineEdit::mouseDoubleClickEvent( e );
827 }
828 
829 void KLineEdit::mousePressEvent( TQMouseEvent* e )
830 {
831  if ( possibleTripleClick && e->button() == Qt::LeftButton )
832  {
833  selectAll();
834  e->accept();
835  return;
836  }
837  TQLineEdit::mousePressEvent( e );
838 }
839 
840 void KLineEdit::mouseReleaseEvent( TQMouseEvent* e )
841 {
842  TQLineEdit::mouseReleaseEvent( e );
843  if (TQApplication::clipboard()->supportsSelection() ) {
844  if ( e->button() == Qt::LeftButton ) {
845  // Fix copying of squeezed text if needed
846  copySqueezedText( false );
847  }
848  }
849 }
850 
851 void KLineEdit::tripleClickTimeout()
852 {
853  possibleTripleClick=false;
854 }
855 
856 void KLineEdit::contextMenuEvent( TQContextMenuEvent * e )
857 {
858  if ( m_bEnableMenu )
859  TQLineEdit::contextMenuEvent( e );
860 }
861 
862 TQPopupMenu *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() && kapp->authorize("lineedit_text_completion") )
880  {
881  TQPopupMenu *subMenu = new TQPopupMenu( popup );
882  connect( subMenu, TQT_SIGNAL( activated( int ) ),
883  this, TQT_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 
926 void 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 
967 void 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 
983 void 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 
1007 bool KLineEdit::eventFilter( TQObject* o, TQEvent* ev )
1008 {
1009  if( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(this) )
1010  {
1011  KCursor::autoHideEventFilter( TQT_TQOBJECT(this), ev );
1012  if ( ev->type() == TQEvent::AccelOverride )
1013  {
1014  TQKeyEvent *e = TQT_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 = TQT_TQKEYEVENT( ev );
1024 
1025  if( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
1026  {
1027  bool trap = d->completionBox && d->completionBox->isVisible();
1028 
1029  bool stopEvent = trap || (d->grabReturnKeyEvents &&
1030  (e->state() == Qt::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 
1058 void KLineEdit::setURLDropsEnabled(bool enable)
1059 {
1060  d->handleURLDrops=enable;
1061 }
1062 
1063 bool KLineEdit::isURLDropsEnabled() const
1064 {
1065  return d->handleURLDrops;
1066 }
1067 
1068 void KLineEdit::setTrapReturnKey( bool grab )
1069 {
1070  d->grabReturnKeyEvents = grab;
1071 }
1072 
1073 bool KLineEdit::trapReturnKey() const
1074 {
1075  return d->grabReturnKeyEvents;
1076 }
1077 
1078 void KLineEdit::setURL( const KURL& url )
1079 {
1080  setText( url.prettyURL() );
1081 }
1082 
1083 void KLineEdit::setCompletionBox( TDECompletionBox *box )
1084 {
1085  if ( d->completionBox )
1086  return;
1087 
1088  d->completionBox = box;
1089  if ( handleSignals() )
1090  {
1091  connect( d->completionBox, TQT_SIGNAL(highlighted( const TQString& )),
1092  TQT_SLOT(setTextWorkaround( const TQString& )) );
1093  connect( d->completionBox, TQT_SIGNAL(userCancelled( const TQString& )),
1094  TQT_SLOT(userCancelled( const TQString& )) );
1095 
1096  // TODO: we need our own slot, and to call setModified(true) if Qt4 has that.
1097  connect( d->completionBox, TQT_SIGNAL( activated( const TQString& )),
1098  TQT_SIGNAL(completionBoxActivated( const TQString& )) );
1099  }
1100 }
1101 
1102 void KLineEdit::userCancelled(const TQString & cancelText)
1103 {
1104  if ( completionMode() != TDEGlobalSettings::CompletionPopupAuto )
1105  {
1106  // TODO: this sets modified==false. But maybe it was true before...
1107  setText(cancelText);
1108  }
1109  else if (hasSelectedText() )
1110  {
1111  if (d->userSelection)
1112  deselect();
1113  else
1114  {
1115  d->autoSuggest=false;
1116  int start,end;
1117  getSelection(&start, &end);
1118  TQString s=text().remove(start, end-start+1);
1119  validateAndSet(s,start,s.length(),s.length());
1120  d->autoSuggest=true;
1121  }
1122  }
1123 }
1124 
1125 bool KLineEdit::overrideAccel (const TQKeyEvent* e)
1126 {
1127  TDEShortcut scKey;
1128 
1129  KKey key( e );
1130  KeyBindingMap keys = getKeyBindings();
1131 
1132  if (keys[TextCompletion].isNull())
1133  scKey = TDEStdAccel::shortcut(TDEStdAccel::TextCompletion);
1134  else
1135  scKey = keys[TextCompletion];
1136 
1137  if (scKey.contains( key ))
1138  return true;
1139 
1140  if (keys[NextCompletionMatch].isNull())
1141  scKey = TDEStdAccel::shortcut(TDEStdAccel::NextCompletion);
1142  else
1143  scKey = keys[NextCompletionMatch];
1144 
1145  if (scKey.contains( key ))
1146  return true;
1147 
1148  if (keys[PrevCompletionMatch].isNull())
1149  scKey = TDEStdAccel::shortcut(TDEStdAccel::PrevCompletion);
1150  else
1151  scKey = keys[PrevCompletionMatch];
1152 
1153  if (scKey.contains( key ))
1154  return true;
1155 
1156  // Override all the text manupilation accelerators...
1157  if ( TDEStdAccel::copy().contains( key ) )
1158  return true;
1159  else if ( TDEStdAccel::paste().contains( key ) )
1160  return true;
1161  else if ( TDEStdAccel::cut().contains( key ) )
1162  return true;
1163  else if ( TDEStdAccel::undo().contains( key ) )
1164  return true;
1165  else if ( TDEStdAccel::redo().contains( key ) )
1166  return true;
1167  else if (TDEStdAccel::deleteWordBack().contains( key ))
1168  return true;
1169  else if (TDEStdAccel::deleteWordForward().contains( key ))
1170  return true;
1171  else if (TDEStdAccel::forwardWord().contains( key ))
1172  return true;
1173  else if (TDEStdAccel::backwardWord().contains( key ))
1174  return true;
1175  else if (TDEStdAccel::beginningOfLine().contains( key ))
1176  return true;
1177  else if (TDEStdAccel::endOfLine().contains( key ))
1178  return true;
1179 
1180  if (d->completionBox && d->completionBox->isVisible ())
1181  {
1182  int key = e->key();
1183  ButtonState state = e->state();
1184  if ((key == Key_Backtab || key == Key_Tab) &&
1185  (state == Qt::NoButton || (state & TQt::ShiftButton)))
1186  {
1187  return true;
1188  }
1189  }
1190 
1191 
1192  return false;
1193 }
1194 
1195 void KLineEdit::setCompletedItems( const TQStringList& items )
1196 {
1197  setCompletedItems( items, true );
1198 }
1199 
1200 void KLineEdit::setCompletedItems( const TQStringList& items, bool autoSuggest )
1201 {
1202  TQString txt;
1203  if ( d->completionBox && d->completionBox->isVisible() ) {
1204  // The popup is visible already - do the matching on the initial string,
1205  // not on the currently selected one.
1206  txt = completionBox()->cancelledText();
1207  } else {
1208  txt = text();
1209  }
1210 
1211  if ( !items.isEmpty() &&
1212  !(items.count() == 1 && txt == items.first()) )
1213  {
1214  // create completion box if non-existent
1215  completionBox();
1216 
1217  if ( d->completionBox->isVisible() )
1218  {
1219  bool wasSelected = d->completionBox->isSelected( d->completionBox->currentItem() );
1220  const TQString currentSelection = d->completionBox->currentText();
1221  d->completionBox->setItems( items );
1222  TQListBoxItem* item = d->completionBox->findItem( currentSelection, TQt::ExactMatch );
1223  // If no item is selected, that means the listbox hasn't been manipulated by the user yet,
1224  // because it's not possible otherwise to have no selected item. In such case make
1225  // always the first item current and unselected, so that the current item doesn't jump.
1226  if( !item || !wasSelected )
1227  {
1228  wasSelected = false;
1229  item = d->completionBox->item( 0 );
1230  }
1231  if ( item )
1232  {
1233  d->completionBox->blockSignals( true );
1234  d->completionBox->setCurrentItem( item );
1235  d->completionBox->setSelected( item, wasSelected );
1236  d->completionBox->blockSignals( false );
1237  }
1238  }
1239  else // completion box not visible yet -> show it
1240  {
1241  if ( !txt.isEmpty() )
1242  d->completionBox->setCancelledText( txt );
1243  d->completionBox->setItems( items );
1244  d->completionBox->popup();
1245  }
1246 
1247  if ( d->autoSuggest && autoSuggest )
1248  {
1249  int index = items.first().find( txt );
1250  TQString newText = items.first().mid( index );
1251  setUserSelection(false);
1252  setCompletedText(newText,true);
1253  }
1254  }
1255  else
1256  {
1257  if ( d->completionBox && d->completionBox->isVisible() )
1258  d->completionBox->hide();
1259  }
1260 }
1261 
1262 TDECompletionBox * KLineEdit::completionBox( bool create )
1263 {
1264  if ( create && !d->completionBox ) {
1265  setCompletionBox( new TDECompletionBox( this, "completion box" ) );
1266  d->completionBox->setFont(font());
1267  }
1268 
1269  return d->completionBox;
1270 }
1271 
1272 void KLineEdit::setCompletionObject( TDECompletion* comp, bool hsig )
1273 {
1274  TDECompletion *oldComp = compObj();
1275  if ( oldComp && handleSignals() )
1276  disconnect( oldComp, TQT_SIGNAL( matches( const TQStringList& )),
1277  this, TQT_SLOT( setCompletedItems( const TQStringList& )));
1278 
1279  if ( comp && hsig )
1280  connect( comp, TQT_SIGNAL( matches( const TQStringList& )),
1281  this, TQT_SLOT( setCompletedItems( const TQStringList& )));
1282 
1283  TDECompletionBase::setCompletionObject( comp, hsig );
1284 }
1285 
1286 // TQWidget::create() turns off mouse-Tracking which would break auto-hiding
1287 void KLineEdit::create( WId id, bool initializeWindow, bool destroyOldWindow )
1288 {
1289  TQLineEdit::create( id, initializeWindow, destroyOldWindow );
1290  KCursor::setAutoHideCursor( this, true, true );
1291 }
1292 
1293 void KLineEdit::setUserSelection(bool userSelection)
1294 {
1295  TQPalette p = palette();
1296 
1297  if (userSelection)
1298  {
1299  p.setColor(TQColorGroup::Highlight, d->previousHighlightColor);
1300  p.setColor(TQColorGroup::HighlightedText, d->previousHighlightedTextColor);
1301  }
1302  else
1303  {
1304  TQColor color=p.color(TQPalette::Disabled, TQColorGroup::Text);
1305  p.setColor(TQColorGroup::HighlightedText, color);
1306  color=p.color(TQPalette::Active, TQColorGroup::Base);
1307  p.setColor(TQColorGroup::Highlight, color);
1308  }
1309 
1310  d->userSelection=userSelection;
1311  setPalette(p);
1312 }
1313 
1314 void KLineEdit::slotRestoreSelectionColors()
1315 {
1316  if (d->disableRestoreSelection)
1317  return;
1318 
1319  setUserSelection(true);
1320 }
1321 
1322 void KLineEdit::clear()
1323 {
1324  setText( TQString::null );
1325 }
1326 
1327 void KLineEdit::setTextWorkaround( const TQString& text )
1328 {
1329  setText( text );
1330  end( false ); // force cursor at end
1331 }
1332 
1333 TQString KLineEdit::originalText() const
1334 {
1335  if ( d->enableSqueezedText && isReadOnly() )
1336  return d->squeezedText;
1337 
1338  return text();
1339 }
1340 
1341 void KLineEdit::focusInEvent( TQFocusEvent* ev)
1342 {
1343  if ( d->drawClickMsg ) {
1344  d->drawClickMsg = false;
1345  update();
1346  }
1347 
1348  // Don't selectAll() in TQLineEdit::focusInEvent if selection exists
1349  if ( ev->reason() == TQFocusEvent::Tab && inputMask().isNull() && hasSelectedText() )
1350  return;
1351 
1352  TQLineEdit::focusInEvent(ev);
1353 }
1354 
1355 void KLineEdit::focusOutEvent( TQFocusEvent* ev)
1356 {
1357  if ( text().isEmpty() && !d->clickMessage.isEmpty() ) {
1358  d->drawClickMsg = true;
1359  update();
1360  }
1361  TQLineEdit::focusOutEvent( ev );
1362 }
1363 
1364 bool KLineEdit::autoSuggest() const
1365 {
1366  return d->autoSuggest;
1367 }
1368 
1369 void KLineEdit::setClickMessage( const TQString &msg )
1370 {
1371  d->clickMessage = msg;
1372  update();
1373 }
1374 
1375 TQString KLineEdit::clickMessage() const
1376 {
1377  return d->clickMessage;
1378 }
1379 
1380 
1381 void KLineEdit::virtual_hook( int id, void* data )
1382 { TDECompletionBase::virtual_hook( id, data ); }
KURL
TDECompletion::makeCompletion
virtual TQString makeCompletion(const TQString &string)
TDEStdAccel::undo
const TDEShortcut & undo()
KLineEdit::keyPressEvent
virtual void keyPressEvent(TQKeyEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:440
KLineEdit::clickMessage
TQString clickMessage() const
Definition: klineedit.cpp:1375
TDECompletionBase::handleSignals
bool handleSignals() const
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::focusOutEvent
virtual void focusOutEvent(TQFocusEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1355
KLineEdit::textRotation
void textRotation(TDECompletionBase::KeyBindingType)
Emitted when the text rotation key-bindings are pressed.
KLineEdit::mouseReleaseEvent
virtual void mouseReleaseEvent(TQMouseEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:840
TDEStdAccel::deleteWordForward
const TDEShortcut & deleteWordForward()
KLineEdit::completion
void completion(const TQString &)
Emitted when the completion key is pressed.
TDEStdAccel::beginningOfLine
const TDEShortcut & beginningOfLine()
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:1287
TDECompletion
KLineEdit::drawContents
virtual void drawContents(TQPainter *p)
Re-implemented for internal reasons.
Definition: klineedit.cpp:967
TDECompletionBase::completionMode
TDEGlobalSettings::Completion completionMode() const
TDEGlobalSettings::Completion
Completion
TDEShortcut::contains
bool contains(const KKey &key) const
TDECompletionBase::setCompletionObject
virtual void setCompletionObject(TDECompletion *compObj, bool hsig=true)
KLineEdit::isSqueezedTextEnabled
bool isSqueezedTextEnabled() const
Returns true if text squeezing is enabled.
Definition: klineedit.cpp:305
KLineEdit::trapReturnKey
bool trapReturnKey() const
Definition: klineedit.cpp:1073
KLineEdit::createPopupMenu
virtual TQPopupMenu * createPopupMenu()
Re-implemented for internal reasons.
Definition: klineedit.cpp:862
TDEGlobalSettings::CompletionPopup
KLineEdit::autoSuggest
bool autoSuggest() const
Whether in current state text should be auto-suggested.
Definition: klineedit.cpp:1364
TDEStdAccel::shortcut
const TDEShortcut & shortcut(StdAccel id)
KLineEdit::setCompletedItems
void setCompletedItems(const TQStringList &items)
Sets items into the completion-box if completionMode() is CompletionPopup.
Definition: klineedit.cpp:1195
KLineEdit::rotateText
void rotateText(TDECompletionBase::KeyBindingType type)
Iterates through all possible matches of the completed text or the history list.
Definition: klineedit.cpp:205
TDEStdAccel::cut
const TDEShortcut & cut()
TDECompletionBase::setCompletionMode
virtual void setCompletionMode(TDEGlobalSettings::Completion mode)
KLineEdit::setEnableSqueezedText
void setEnableSqueezedText(bool enable)
Enable text squeezing whenever the supplied text is too long.
Definition: klineedit.cpp:300
KLineEdit::returnPressed
void returnPressed(const TQString &)
Emitted when the user presses the return key.
KLineEdit::clear
virtual void clear()
Reimplemented to workaround a buggy TQLineEdit::clear() (changing the clipboard to the text we just h...
Definition: klineedit.cpp:1322
KCursor::setAutoHideCursor
static void setAutoHideCursor(TQWidget *w, bool enable)
Sets auto-hiding the cursor for widget w.
Definition: kcursor.cpp:218
TDEGlobalSettings::CompletionPopupAuto
TDEStdAccel::redo
const TDEShortcut & redo()
TDEStdAccel::backwardWord
const TDEShortcut & backwardWord()
KLineEdit::originalText
TQString originalText() const
Returns the original text if text squeezing is enabled.
Definition: klineedit.cpp:1333
TDEConfigGroup
KLineEdit::makeCompletion
virtual void makeCompletion(const TQString &)
Completes the remaining text with a matching one from a given list.
Definition: klineedit.cpp:226
TDECompletionBase::getKeyBindings
KeyBindingMap getKeyBindings() const
KLineEdit::focusInEvent
virtual void focusInEvent(TQFocusEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1341
tdelocale.h
TDECompletion::nextMatch
TQString nextMatch()
TDEGlobalSettings::completionMode
static Completion completionMode()
TDEStdAccel::pasteSelection
const TDEShortcut & pasteSelection()
TDEGlobalSettings::CompletionNone
KLineEdit::setUserSelection
void setUserSelection(bool userSelection)
Sets the widget in userSelection mode or in automatic completion selection mode.
Definition: klineedit.cpp:1293
KLineEdit::~KLineEdit
virtual ~KLineEdit()
Destructor.
Definition: klineedit.cpp:118
KLineEdit::contextMenuEvent
virtual void contextMenuEvent(TQContextMenuEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:856
TDEStdAccel::deleteWordBack
const TDEShortcut & deleteWordBack()
KURLDrag::decode
static bool decode(const TQMimeSource *e, KURL::List &urls)
KLineEdit::setCompletedText
virtual void setCompletedText(const TQString &)
See TDECompletionBase::setCompletedText.
Definition: klineedit.cpp:195
TDECompletionBase::emitSignals
bool emitSignals() const
KLineEdit::completionModeChanged
void completionModeChanged(TDEGlobalSettings::Completion)
Emitted when the user changed the completion mode by using the popupmenu.
KLineEdit::mousePressEvent
virtual void mousePressEvent(TQMouseEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:829
KLineEdit::aboutToShowContextMenu
void aboutToShowContextMenu(TQPopupMenu *p)
Emitted before the context menu is displayed.
TDEGlobalSettings::CompletionAuto
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::eventFilter
virtual bool eventFilter(TQObject *, TQEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:1007
KLineEdit::substringCompletion
void substringCompletion(const TQString &)
Emitted when the shortcut for substring completion is pressed.
KLineEdit::setURLDropsEnabled
void setURLDropsEnabled(bool enable)
Enables/Disables handling of URL drops.
Definition: klineedit.cpp:1058
TDECompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: tdecompletionbox.h:43
KLineEdit::setContextMenuEnabled
virtual void setContextMenuEnabled(bool showMenu)
Enables/disables the popup (context) menu.
Definition: klineedit.h:223
KLineEdit
An enhanced TQLineEdit widget for inputting text.
Definition: klineedit.h:145
TDECompletionBase::KeyBindingType
KeyBindingType
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:1369
KLineEdit::setCompletionBox
void setCompletionBox(TDECompletionBox *box)
Set the completion-box to be used in completion mode TDEGlobalSettings::CompletionPopup.
Definition: klineedit.cpp:1083
KKey
TDEShortcut
KLineEdit::completionBoxActivated
void completionBoxActivated(const TQString &)
Emitted whenever the completion box is activated.
TDECompletionBase::compObj
TDECompletion * compObj() const
KLineEdit::completionBox
TDECompletionBox * completionBox(bool create=true)
Definition: klineedit.cpp:1262
KLineEdit::dropEvent
virtual void dropEvent(TQDropEvent *)
Re-implemented to handle URI drops.
Definition: klineedit.cpp:983
KLineEdit::setCompletionObject
virtual void setCompletionObject(TDECompletion *, bool hsig=true)
Reimplemented for internal reasons, the API is not affected.
Definition: klineedit.cpp:1272
TDEStdAccel::copy
const TDEShortcut & copy()
KLineEdit::copy
virtual void copy() const
Reimplemented for internal reasons, the API is not affected.
Definition: klineedit.cpp:397
TDECompletion::previousMatch
TQString previousMatch()
TDECompletionBase::TextCompletion
KLineEdit::setURL
void setURL(const KURL &url)
Sets url into the lineedit.
Definition: klineedit.cpp:1078
TDEGlobalSettings::CompletionMan
KLineEdit::isURLDropsEnabled
bool isURLDropsEnabled() const
Returns true when decoded URL drops are enabled.
Definition: klineedit.cpp:1063
TDEStdAccel::forwardWord
const TDEShortcut & forwardWord()
KLineEdit::userCancelled
void userCancelled(const TQString &cancelText)
Resets the current displayed text.
Definition: klineedit.cpp:1102
TDEStdAccel::paste
const TDEShortcut & paste()
TDECompletionBox::cancelledText
TQString cancelledText() const
Definition: tdecompletionbox.cpp:441
TDEGlobal::config
static TDEConfig * config()
KLineEdit::resizeEvent
virtual void resizeEvent(TQResizeEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:432
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
KLineEdit::setReadOnly
virtual void setReadOnly(bool)
Re-implemented for internal reasons.
Definition: klineedit.cpp:265
KLineEdit::setCompletionMode
virtual void setCompletionMode(TDEGlobalSettings::Completion mode)
Re-implemented from TDECompletionBase for internal reasons.
Definition: klineedit.cpp:150
KLineEdit::setSqueezedText
void setSqueezedText(const TQString &text)
Squeezes text into the line edit.
Definition: klineedit.cpp:294
KURL::List
TDECompletionBase::NextCompletionMatch
TDEStdAccel::completion
const TDEShortcut & completion()
TDECompletion::allMatches
TQStringList allMatches()
TDEGlobalSettings::CompletionShell
TDECompletionBase::SubstringCompletion
KLineEdit::setText
virtual void setText(const TQString &)
Re-implemented to enable text squeezing.
Definition: klineedit.cpp:310
TDEStdAccel::endOfLine
const TDEShortcut & endOfLine()
KURL::prettyURL
TQString prettyURL(int _trailing=0) const
KLineEdit::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(TQMouseEvent *)
Re-implemented for internal reasons.
Definition: klineedit.cpp:818
TDECompletionBase::PrevCompletionMatch

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.