• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

klineedit.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00027     Boston, MA 02110-1301, 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     // @since 3.5.4
00155     Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
00156 
00157 public:
00158 
00167     KLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
00168 
00175     KLineEdit ( QWidget *parent=0, const char *name=0 );
00176 
00180     virtual ~KLineEdit ();
00181 
00186     void setURL( const KURL& url );
00187 
00197     void cursorAtEnd() { end( false ); }
00198 
00207     virtual void setCompletionMode( KGlobalSettings::Completion mode );
00208 
00223     virtual void setContextMenuEnabled( bool showMenu ) {  m_bEnableMenu = showMenu; }
00224 
00228     bool isContextMenuEnabled() const { return m_bEnableMenu; }
00229 
00237     void setURLDropsEnabled( bool enable );
00238 
00242     bool isURLDropsEnabled() const;
00243 
00254     void setTrapReturnKey( bool trap );
00255 
00262     bool trapReturnKey() const;
00263 
00268     virtual bool eventFilter( QObject *, QEvent * );
00269 
00278     KCompletionBox * completionBox( bool create = true );
00279 
00283     virtual void setCompletionObject( KCompletion *, bool hsig = true );
00284 
00288     virtual void copy() const;
00289 
00301     void setEnableSqueezedText( bool enable );
00302 
00309     bool isSqueezedTextEnabled() const;
00310 
00319     QString originalText() const;
00320 
00329     void setCompletionBox( KCompletionBox *box );
00330 
00337     void setClickMessage( const QString &msg );
00338 
00343     QString clickMessage() const;
00344 
00345 signals:
00346 
00351     void completionBoxActivated (const QString &);
00352 
00360     void returnPressed( const QString& );
00361 
00369     void completion( const QString& );
00370 
00374     void substringCompletion( const QString& );
00375 
00388     void textRotation( KCompletionBase::KeyBindingType );
00389 
00394     void completionModeChanged( KGlobalSettings::Completion );
00395 
00408     void aboutToShowContextMenu( QPopupMenu * p );
00409 
00410 public slots:
00411 
00415     virtual void setReadOnly(bool);
00416 
00427     void rotateText( KCompletionBase::KeyBindingType type );
00428 
00432     virtual void setCompletedText( const QString& );
00433 
00440     void setCompletedItems( const QStringList& items );
00441 
00452     void setCompletedItems( const QStringList& items, bool autoSuggest );
00453 
00458     virtual void clear();
00459 
00465     void setSqueezedText( const QString &text);
00466 
00470     virtual void setText ( const QString& );
00471 
00472 
00473 protected slots:
00474 
00479     virtual void makeCompletion( const QString& );
00480 
00484     void slotAboutToShow() {}
00485 
00489     void slotCancelled() {}
00490 
00496     void userCancelled(const QString & cancelText);
00497 
00498 protected:
00499 
00505     virtual void resizeEvent( QResizeEvent * );
00506 
00512     virtual void keyPressEvent( QKeyEvent * );
00513 
00519     virtual void mousePressEvent( QMouseEvent * );
00520 
00526     virtual void mouseDoubleClickEvent( QMouseEvent * );
00527 
00533     virtual void mouseReleaseEvent( QMouseEvent * );
00534 
00540     virtual void contextMenuEvent( QContextMenuEvent * );
00541 
00547     virtual QPopupMenu *createPopupMenu();
00548 
00554     virtual void drawContents( QPainter *p );
00555 
00561     virtual void dropEvent( QDropEvent * );
00562 
00563     /*
00564     * This function simply sets the lineedit text and
00565     * highlights the text appropriately if the boolean
00566     * value is set to true.
00567     *
00568     * @param text
00569     * @param marked
00570     */
00571     virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
00572 
00573 
00578     void setUserSelection( bool userSelection );
00579 
00583     virtual void create( WId = 0, bool initializeWindow = true,
00584                          bool destroyOldWindow = true );
00585 
00591     virtual void focusInEvent( QFocusEvent* );
00592 
00598     virtual void focusOutEvent( QFocusEvent* );
00599 
00604     bool autoSuggest() const;
00605 
00606 private slots:
00607     void completionMenuActivated( int id );
00608     void tripleClickTimeout();  // resets possibleTripleClick
00609     void slotRestoreSelectionColors();
00610     void setTextWorkaround( const QString& text );
00611 
00612 private:
00613 
00614     // Constants that represent the ID's of the popup menu.
00615     enum MenuID
00616     {
00617         Default = 42,
00618         NoCompletion,
00619         AutoCompletion,
00620         ShellCompletion,
00621         PopupCompletion,
00622         ShortAutoCompletion,
00623         PopupAutoCompletion
00624     };
00625 
00629     void init();
00630 
00631     bool copySqueezedText( bool clipboard ) const;
00632 
00637     bool overrideAccel (const QKeyEvent* e);
00638 
00643     void setSqueezedText ();
00644 
00645     bool m_bEnableMenu;
00646 
00647     bool possibleTripleClick;  // set in mousePressEvent, deleted in tripleClickTimeout
00648 
00649 protected:
00650     virtual void virtual_hook( int id, void* data );
00651 private:
00652     class KLineEditPrivate;
00653     KLineEditPrivate *d;
00654 };
00655 
00656 #endif

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal