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 
00298     void setEnableSqueezedText( bool enable );
00299     
00306     bool isSqueezedTextEnabled() const;
00307     
00315     QString originalText() const;
00316 
00317 signals:
00318 
00323     void completionBoxActivated (const QString &);
00324 
00332     void returnPressed( const QString& );
00333 
00341     void completion( const QString& );
00342 
00346     void substringCompletion( const QString& );
00347 
00359     void textRotation( KCompletionBase::KeyBindingType );
00360 
00365     void completionModeChanged( KGlobalSettings::Completion );
00366 
00379     void aboutToShowContextMenu( QPopupMenu * p );
00380 
00381 public slots:
00382 
00386     virtual void setReadOnly(bool);
00387 
00398     void rotateText( KCompletionBase::KeyBindingType type );
00399 
00403     virtual void setCompletedText( const QString& );
00404 
00411     void setCompletedItems( const QStringList& items );
00412     
00423     void setCompletedItems( const QStringList& items, bool autoSuggest );
00424 
00429     virtual void clear();
00430 
00436     void setSqueezedText( const QString &text);
00437 
00441     virtual void setText ( const QString& );
00442     
00443     
00444 protected slots:
00445 
00450     virtual void makeCompletion( const QString& );
00451 
00455     void slotAboutToShow() {}
00456 
00460     void slotCancelled() {}
00461     
00467     void userCancelled(const QString & cancelText);
00468 
00469 protected:
00470 
00476     virtual void resizeEvent( QResizeEvent * );
00477 
00483     virtual void keyPressEvent( QKeyEvent * );
00484 
00490     virtual void mousePressEvent( QMouseEvent * );
00491 
00497     virtual void mouseDoubleClickEvent( QMouseEvent * );
00498 
00504     virtual void contextMenuEvent( QContextMenuEvent * );
00505 
00511     virtual QPopupMenu *createPopupMenu();
00512 
00518     virtual void dropEvent( QDropEvent * );
00519 
00520     /*
00521     * This function simply sets the lineedit text and
00522     * highlights the text appropriately if the boolean
00523     * value is set to true.
00524     *
00525     * @param text
00526     * @param marked
00527     */
00528     virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
00529 
00530 
00535     void setUserSelection( bool userSelection );
00536 
00540     virtual void create( WId = 0, bool initializeWindow = true,
00541                          bool destroyOldWindow = true );
00542 
00543 
00544 private slots:
00545     void completionMenuActivated( int id );
00546     void tripleClickTimeout();  // resets possibleTripleClick
00547     void slotRestoreSelectionColors();
00548     void setTextWorkaround( const QString& text );
00549 
00550 private:
00551 
00552     // Constants that represent the ID's of the popup menu.
00553     enum MenuID
00554     {
00555         Default = 42,
00556         NoCompletion,
00557         AutoCompletion,
00558         ShellCompletion,
00559         PopupCompletion,
00560         ShortAutoCompletion,
00561         PopupAutoCompletion
00562     };
00563 
00567     void init();
00568 
00572     void makeCompletionBox();
00573 
00578     bool overrideAccel (const QKeyEvent* e);
00579 
00584     void setSqueezedText ();
00585 
00586     bool m_bEnableMenu;
00587 
00588     bool possibleTripleClick;  // set in mousePressEvent, deleted in tripleClickTimeout
00589 
00590 protected:
00591     virtual void virtual_hook( int id, void* data );
00592 private:
00593     class KLineEditPrivate;
00594     KLineEditPrivate *d;
00595 };
00596 
00597 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:12:01 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003