| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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
    00136 class KLineEdit : public QLineEdit, public KCompletionBase
    00137 {
    00138     friend class KComboBox;
    00139
    00140     Q_OBJECT
    00141     Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
    00142     Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
    00143
    00144 public:
    00145
    00154     KLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
    00155
    00163     KLineEdit ( QWidget *parent=0, const char *name=0 );
    00164
    00168     virtual ~KLineEdit ();
    00169
    00174     void setURL( const KURL& url );
    00175
    00185     void cursorAtEnd() { end( false ); }
    00186
    00195     virtual void setCompletionMode( KGlobalSettings::Completion mode );
    00196
    00211     virtual void setContextMenuEnabled( bool showMenu ) {  m_bEnableMenu = showMenu; }
    00212
    00216     bool isContextMenuEnabled() const { return m_bEnableMenu; }
    00217
    00225     void setURLDropsEnabled( bool enable );
    00226
    00230     bool isURLDropsEnabled() const;
    00231
    00242     void setTrapReturnKey( bool trap );
    00243
    00250     bool trapReturnKey() const;
    00251
    00257     virtual bool eventFilter( QObject *, QEvent * );
    00258
    00267     KCompletionBox * completionBox( bool create = true );
    00268
    00272     virtual void setCompletionObject( KCompletion *, bool hsig = true );
    00273
    00277     virtual void copy() const;
    00278
    00279 signals:
    00280
    00285     void completionBoxActivated (const QString &);
    00286
    00294     void returnPressed( const QString& );
    00295
    00303     void completion( const QString& );
    00304
    00308     void substringCompletion( const QString& );
    00309
    00321     void textRotation( KCompletionBase::KeyBindingType );
    00322
    00327     void completionModeChanged( KGlobalSettings::Completion );
    00328
    00341     void aboutToShowContextMenu( QPopupMenu* );
    00342
    00343 public slots:
    00344
    00348     virtual void setReadOnly(bool);
    00349
    00360     void rotateText( KCompletionBase::KeyBindingType /* type */ );
    00361
    00365     virtual void setCompletedText( const QString& );
    00366
    00371     void setCompletedItems( const QStringList& items );
    00372
    00377     virtual void clear();
    00378
    00384     void setSqueezedText( const QString &text);
    00385
    00386 protected slots:
    00387
    00392     virtual void makeCompletion( const QString& );
    00393
    00397     void slotAboutToShow() {}
    00398
    00402     void slotCancelled() {}
    00403
    00404 protected:
    00405
    00411     virtual void resizeEvent( QResizeEvent * );
    00412
    00418     virtual void keyPressEvent( QKeyEvent * );
    00419
    00425     virtual void mousePressEvent( QMouseEvent * );
    00426
    00432     virtual void mouseDoubleClickEvent( QMouseEvent * );
    00433
    00439     virtual QPopupMenu *createPopupMenu();
    00440
    00446     virtual void dropEvent( QDropEvent * );
    00447
    00448     /*
    00449     * This function simply sets the lineedit text and
    00450     * highlights the text appropriately if the boolean
    00451     * value is set to true.
    00452     *
    00453     * @param text
    00454     * @param marked
    00455     */
    00456     virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
    00457
    00461     virtual void create( WId = 0, bool initializeWindow = true,
    00462                          bool destroyOldWindow = true );
    00463
    00464 private slots:
    00465     void completionMenuActivated( int id );
    00466     void tripleClickTimeout();  // resets possibleTripleClick
    00467     void setTextWorkaround( const QString& text );
    00468
    00469 private:
    00470     // Constants that represent the ID's of the popup menu.
    00471     // TODO: See if we can replace this mess with KActionMenu
    00472     // in the future though it's working lovely.
    00473     enum MenuID {
    00474         Default = 42,
    00475         NoCompletion,
    00476         AutoCompletion,
    00477         ShellCompletion,
    00478         PopupCompletion,
    00479         SemiAutoCompletion
    00480     };
    00481
    00485     void init();
    00486
    00490     void makeCompletionBox();
    00491
    00496     bool overrideAccel (const QKeyEvent* e);
    00497
    00498     bool m_bEnableMenu;
    00499
    00500     bool possibleTripleClick;  // set in mousePressEvent, deleted in tripleClickTimeout
    00501
    00502 protected:
    00503     virtual void virtual_hook( int id, void* data );
    00504 private:
    00505     class KLineEditPrivate;
    00506     KLineEditPrivate *d;
    00507 };
    00508
    00509 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:57:08 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001