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 #include <kdemacros.h> 00036 00037 class QPopupMenu; 00038 00039 class KCompletionBox; 00040 class KURL; 00041 00142 class KLineEdit : public QLineEdit, public KCompletionBase 00143 { 00144 friend class KComboBox; 00145 00146 Q_OBJECT 00147 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 00148 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 00149 Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey ) 00150 Q_PROPERTY( bool enableSqueezedText READ isSqueezedTextEnabled WRITE setEnableSqueezedText ) 00151 00152 public: 00153 00162 KLineEdit( const QString &string, QWidget *parent, const char *name = 0 ); 00163 00170 KLineEdit ( QWidget *parent=0, const char *name=0 ); 00171 00175 virtual ~KLineEdit (); 00176 00181 void setURL( const KURL& url ); 00182 00192 void cursorAtEnd() { end( false ); } 00193 00202 virtual void setCompletionMode( KGlobalSettings::Completion mode ); 00203 00218 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; } 00219 00223 bool isContextMenuEnabled() const { return m_bEnableMenu; } 00224 00232 void setURLDropsEnabled( bool enable ); 00233 00237 bool isURLDropsEnabled() const; 00238 00249 void setTrapReturnKey( bool trap ); 00250 00257 bool trapReturnKey() const; 00258 00263 virtual bool eventFilter( QObject *, QEvent * ); 00264 00273 KCompletionBox * completionBox( bool create = true ); 00274 00278 virtual void setCompletionObject( KCompletion *, bool hsig = true ); 00279 00283 virtual void copy() const; 00284 00295 void setEnableSqueezedText( bool enable ); 00296 00302 bool isSqueezedTextEnabled() const; 00303 00311 QString originalText() const; 00312 00313 signals: 00314 00319 void completionBoxActivated (const QString &); 00320 00328 void returnPressed( const QString& ); 00329 00337 void completion( const QString& ); 00338 00342 void substringCompletion( const QString& ); 00343 00355 void textRotation( KCompletionBase::KeyBindingType ); 00356 00361 void completionModeChanged( KGlobalSettings::Completion ); 00362 00375 void aboutToShowContextMenu( QPopupMenu * p ); 00376 00377 public slots: 00378 00382 virtual void setReadOnly(bool); 00383 00394 void rotateText( KCompletionBase::KeyBindingType type ); 00395 00399 virtual void setCompletedText( const QString& ); 00400 00405 void setCompletedItems( const QStringList& items ); 00406 00411 virtual void clear(); 00412 00418 void setSqueezedText( const QString &text); 00419 00423 virtual void setText ( const QString& ); 00424 00425 00426 protected slots: 00427 00432 virtual void makeCompletion( const QString& ); 00433 00437 void slotAboutToShow() {} 00438 00442 void slotCancelled() {} 00443 00449 void userCancelled(const QString & cancelText); 00450 00451 protected: 00452 00458 virtual void resizeEvent( QResizeEvent * ); 00459 00465 virtual void keyPressEvent( QKeyEvent * ); 00466 00472 virtual void mousePressEvent( QMouseEvent * ); 00473 00479 virtual void mouseDoubleClickEvent( QMouseEvent * ); 00480 00486 virtual QPopupMenu *createPopupMenu(); 00487 00493 virtual void dropEvent( QDropEvent * ); 00494 00495 /* 00496 * This function simply sets the lineedit text and 00497 * highlights the text appropriately if the boolean 00498 * value is set to true. 00499 * 00500 * @param text 00501 * @param marked 00502 */ 00503 virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ ); 00504 00505 00510 void setUserSelection( bool userSelection ); 00511 00515 virtual void create( WId = 0, bool initializeWindow = true, 00516 bool destroyOldWindow = true ); 00517 00518 private slots: 00519 void completionMenuActivated( int id ); 00520 void tripleClickTimeout(); // resets possibleTripleClick 00521 void slotRestoreSelectionColors(); 00522 void setTextWorkaround( const QString& text ); 00523 00524 private: 00525 00526 // Constants that represent the ID's of the popup menu. 00527 enum MenuID 00528 { 00529 Default = 42, 00530 NoCompletion, 00531 AutoCompletion, 00532 ShellCompletion, 00533 PopupCompletion, 00534 ShortAutoCompletion, 00535 PopupAutoCompletion 00536 }; 00537 00541 void init(); 00542 00546 void makeCompletionBox(); 00547 00552 bool overrideAccel (const QKeyEvent* e); 00553 00558 void setSqueezedText (); 00559 00560 bool m_bEnableMenu; 00561 00562 bool possibleTripleClick; // set in mousePressEvent, deleted in tripleClickTimeout 00563 00564 protected: 00565 virtual void virtual_hook( int id, void* data ); 00566 private: 00567 class KLineEditPrivate; 00568 KLineEditPrivate *d; 00569 }; 00570 00571 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 8 11:14:26 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003