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 00146 class KLineEdit : public QLineEdit, public KCompletionBase 00147 { 00148 friend class KComboBox; 00149 00150 Q_OBJECT 00151 Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled ) 00152 Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled ) 00153 Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey ) 00154 Q_PROPERTY( bool enableSqueezedText READ isSqueezedTextEnabled WRITE setEnableSqueezedText ) 00155 00156 public: 00157 00166 KLineEdit( const QString &string, QWidget *parent, const char *name = 0 ); 00167 00174 KLineEdit ( QWidget *parent=0, const char *name=0 ); 00175 00179 virtual ~KLineEdit (); 00180 00185 void setURL( const KURL& url ); 00186 00196 void cursorAtEnd() { end( false ); } 00197 00206 virtual void setCompletionMode( KGlobalSettings::Completion mode ); 00207 00222 virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; } 00223 00227 bool isContextMenuEnabled() const { return m_bEnableMenu; } 00228 00236 void setURLDropsEnabled( bool enable ); 00237 00241 bool isURLDropsEnabled() const; 00242 00253 void setTrapReturnKey( bool trap ); 00254 00261 bool trapReturnKey() const; 00262 00267 virtual bool eventFilter( QObject *, QEvent * ); 00268 00277 KCompletionBox * completionBox( bool create = true ); 00278 00282 virtual void setCompletionObject( KCompletion *, bool hsig = true ); 00283 00287 virtual void copy() const; 00288 00299 void setEnableSqueezedText( bool enable ); 00300 00307 bool isSqueezedTextEnabled() const; 00308 00316 QString originalText() const; 00317 00318 signals: 00319 00324 void completionBoxActivated (const QString &); 00325 00333 void returnPressed( const QString& ); 00334 00342 void completion( const QString& ); 00343 00347 void substringCompletion( const QString& ); 00348 00360 void textRotation( KCompletionBase::KeyBindingType ); 00361 00366 void completionModeChanged( KGlobalSettings::Completion ); 00367 00380 void aboutToShowContextMenu( QPopupMenu * p ); 00381 00382 public slots: 00383 00387 virtual void setReadOnly(bool); 00388 00399 void rotateText( KCompletionBase::KeyBindingType type ); 00400 00404 virtual void setCompletedText( const QString& ); 00405 00412 void setCompletedItems( const QStringList& items ); 00413 00424 void setCompletedItems( const QStringList& items, bool autoSuggest ); 00425 00430 virtual void clear(); 00431 00437 void setSqueezedText( const QString &text); 00438 00442 virtual void setText ( const QString& ); 00443 00444 00445 protected slots: 00446 00451 virtual void makeCompletion( const QString& ); 00452 00456 void slotAboutToShow() {} 00457 00461 void slotCancelled() {} 00462 00468 void userCancelled(const QString & cancelText); 00469 00470 protected: 00471 00477 virtual void resizeEvent( QResizeEvent * ); 00478 00484 virtual void keyPressEvent( QKeyEvent * ); 00485 00491 virtual void mousePressEvent( QMouseEvent * ); 00492 00498 virtual void mouseDoubleClickEvent( QMouseEvent * ); 00499 00505 virtual QPopupMenu *createPopupMenu(); 00506 00512 virtual void dropEvent( QDropEvent * ); 00513 00514 /* 00515 * This function simply sets the lineedit text and 00516 * highlights the text appropriately if the boolean 00517 * value is set to true. 00518 * 00519 * @param text 00520 * @param marked 00521 */ 00522 virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ ); 00523 00524 00529 void setUserSelection( bool userSelection ); 00530 00534 virtual void create( WId = 0, bool initializeWindow = true, 00535 bool destroyOldWindow = true ); 00536 00537 private slots: 00538 void completionMenuActivated( int id ); 00539 void tripleClickTimeout(); // resets possibleTripleClick 00540 void slotRestoreSelectionColors(); 00541 void setTextWorkaround( const QString& text ); 00542 00543 private: 00544 00545 // Constants that represent the ID's of the popup menu. 00546 enum MenuID 00547 { 00548 Default = 42, 00549 NoCompletion, 00550 AutoCompletion, 00551 ShellCompletion, 00552 PopupCompletion, 00553 ShortAutoCompletion, 00554 PopupAutoCompletion 00555 }; 00556 00560 void init(); 00561 00565 void makeCompletionBox(); 00566 00571 bool overrideAccel (const QKeyEvent* e); 00572 00577 void setSqueezedText (); 00578 00579 bool m_bEnableMenu; 00580 00581 bool possibleTripleClick; // set in mousePressEvent, deleted in tripleClickTimeout 00582 00583 protected: 00584 virtual void virtual_hook( int id, void* data ); 00585 private: 00586 class KLineEditPrivate; 00587 KLineEditPrivate *d; 00588 }; 00589 00590 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:43:28 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003