kdeui Library API Documentation

klineedit.h

00001 /* This file is part of the KDE libraries 00002 00003 This class was originally inspired by Torben Weis' 00004 fileentry.cpp for KFM II. 00005 00006 Copyright (C) 1997 Sven Radej <sven.radej@iname.com> 00007 Copyright (c) 1999 Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com> 00008 Copyright (c) 1999 Preston Brown <pbrown@kde.org> 00009 00010 Completely re-designed: 00011 Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org> 00012 00013 This library is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU Lesser General Public 00015 License (LGPL) as published by the Free Software Foundation; 00016 either version 2 of the License, or (at your option) any later 00017 version. 00018 00019 This library is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 Lesser General Public License for more details. 00023 00024 You should have received a copy of the GNU Lesser General Public License 00025 along with this library; see the file COPYING.LIB. If not, write to 00026 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00027 Boston, MA 02111-1307, USA. 00028 */ 00029 00030 #ifndef _KLINEEDIT_H 00031 #define _KLINEEDIT_H 00032 00033 #include <qlineedit.h> 00034 #include <kcompletion.h> 00035 00036 class QPopupMenu; 00037 00038 class KCompletionBox; 00039 class KURL; 00040 00145 class KDEUI_EXPORT KLineEdit : public QLineEdit, public KCompletionBase 00146 { 00147 friend class KComboBox; 00148 00149 Q_OBJECT 00150 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 00151 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 00152 Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey ) 00153 Q_PROPERTY( bool enableSqueezedText READ isSqueezedTextEnabled WRITE setEnableSqueezedText ) 00154 00155 public: 00156 00165 KLineEdit( const QString &string, QWidget *parent, const char *name = 0 ); 00166 00173 KLineEdit ( QWidget *parent=0, const char *name=0 ); 00174 00178 virtual ~KLineEdit (); 00179 00184 void setURL( const KURL& url ); 00185 00195 void cursorAtEnd() { end( false ); } 00196 00205 virtual void setCompletionMode( KGlobalSettings::Completion mode ); 00206 00221 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; } 00222 00226 bool isContextMenuEnabled() const { return m_bEnableMenu; } 00227 00235 void setURLDropsEnabled( bool enable ); 00236 00240 bool isURLDropsEnabled() const; 00241 00252 void setTrapReturnKey( bool trap ); 00253 00260 bool trapReturnKey() const; 00261 00266 virtual bool eventFilter( QObject *, QEvent * ); 00267 00276 KCompletionBox * completionBox( bool create = true ); 00277 00281 virtual void setCompletionObject( KCompletion *, bool hsig = true ); 00282 00286 virtual void copy() const; 00287 00299 void setEnableSqueezedText( bool enable ); 00300 00307 bool isSqueezedTextEnabled() const; 00308 00317 QString originalText() const; 00318 00327 void setCompletionBox( KCompletionBox *box ); 00328 00329 signals: 00330 00335 void completionBoxActivated (const QString &); 00336 00344 void returnPressed( const QString& ); 00345 00353 void completion( const QString& ); 00354 00358 void substringCompletion( const QString& ); 00359 00371 void textRotation( KCompletionBase::KeyBindingType ); 00372 00377 void completionModeChanged( KGlobalSettings::Completion ); 00378 00391 void aboutToShowContextMenu( QPopupMenu * p ); 00392 00393 public slots: 00394 00398 virtual void setReadOnly(bool); 00399 00410 void rotateText( KCompletionBase::KeyBindingType type ); 00411 00415 virtual void setCompletedText( const QString& ); 00416 00423 void setCompletedItems( const QStringList& items ); 00424 00435 void setCompletedItems( const QStringList& items, bool autoSuggest ); 00436 00441 virtual void clear(); 00442 00448 void setSqueezedText( const QString &text); 00449 00453 virtual void setText ( const QString& ); 00454 00455 00456 protected slots: 00457 00462 virtual void makeCompletion( const QString& ); 00463 00467 void slotAboutToShow() {} 00468 00472 void slotCancelled() {} 00473 00479 void userCancelled(const QString & cancelText); 00480 00481 protected: 00482 00488 virtual void resizeEvent( QResizeEvent * ); 00489 00495 virtual void keyPressEvent( QKeyEvent * ); 00496 00502 virtual void mousePressEvent( QMouseEvent * ); 00503 00509 virtual void mouseDoubleClickEvent( QMouseEvent * ); 00510 00516 virtual void contextMenuEvent( QContextMenuEvent * ); 00517 00523 virtual QPopupMenu *createPopupMenu(); 00524 00530 virtual void dropEvent( QDropEvent * ); 00531 00532 /* 00533 * This function simply sets the lineedit text and 00534 * highlights the text appropriately if the boolean 00535 * value is set to true. 00536 * 00537 * @param text 00538 * @param marked 00539 */ 00540 virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ ); 00541 00542 00547 void setUserSelection( bool userSelection ); 00548 00552 virtual void create( WId = 0, bool initializeWindow = true, 00553 bool destroyOldWindow = true ); 00554 00560 virtual void focusInEvent( QFocusEvent* ); 00561 00566 bool autoSuggest() const; 00567 00568 private slots: 00569 void completionMenuActivated( int id ); 00570 void tripleClickTimeout(); // resets possibleTripleClick 00571 void slotRestoreSelectionColors(); 00572 void setTextWorkaround( const QString& text ); 00573 00574 private: 00575 00576 // Constants that represent the ID's of the popup menu. 00577 enum MenuID 00578 { 00579 Default = 42, 00580 NoCompletion, 00581 AutoCompletion, 00582 ShellCompletion, 00583 PopupCompletion, 00584 ShortAutoCompletion, 00585 PopupAutoCompletion 00586 }; 00587 00591 void init(); 00592 00597 bool overrideAccel (const QKeyEvent* e); 00598 00603 void setSqueezedText (); 00604 00605 bool m_bEnableMenu; 00606 00607 bool possibleTripleClick; // set in mousePressEvent, deleted in tripleClickTimeout 00608 00609 protected: 00610 virtual void virtual_hook( int id, void* data ); 00611 private: 00612 class KLineEditPrivate; 00613 KLineEditPrivate *d; 00614 }; 00615 00616 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:10:13 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003