klineedit.h
/* This file is part of the KDE libraries
This class was originally inspired by Torben Weis'
fileentry.cpp for KFM II.
Copyright (C) 1997 Sven Radej <sven.radej@iname.com>
Copyright (c) 1999 Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
Copyright (c) 1999 Preston Brown <pbrown@kde.org>
Completely re-designed:
Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KLINEEDIT_H
#define _KLINEEDIT_H
#include <qlineedit.h>
#include <kcompletion.h>
class QPopupMenu;
class KCompletionBox;
class KURL;
class KDEUI_EXPORT KLineEdit : public QLineEdit, public KCompletionBase
{
friend class KComboBox;
Q_OBJECT
Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
Q_PROPERTY( bool trapEnterKeyEvent READ trapReturnKey WRITE setTrapReturnKey )
Q_PROPERTY( bool enableSqueezedText READ isSqueezedTextEnabled WRITE setEnableSqueezedText )
// @since 3.5.4
Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
public:
KLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
KLineEdit ( QWidget *parent=0, const char *name=0 );
virtual ~KLineEdit ();
void setURL( const KURL& url );
void cursorAtEnd() { end( false ); }
virtual void setCompletionMode( KGlobalSettings::Completion mode );
virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; }
bool isContextMenuEnabled() const { return m_bEnableMenu; }
void setURLDropsEnabled( bool enable );
bool isURLDropsEnabled() const;
void setTrapReturnKey( bool trap );
bool trapReturnKey() const;
virtual bool eventFilter( QObject *, QEvent * );
KCompletionBox * completionBox( bool create = true );
virtual void setCompletionObject( KCompletion *, bool hsig = true );
virtual void copy() const;
void setEnableSqueezedText( bool enable );
bool isSqueezedTextEnabled() const;
QString originalText() const;
void setCompletionBox( KCompletionBox *box );
void setClickMessage( const QString &msg );
QString clickMessage() const;
signals:
void completionBoxActivated (const QString &);
void returnPressed( const QString& );
void completion( const QString& );
void substringCompletion( const QString& );
void textRotation( KCompletionBase::KeyBindingType );
void completionModeChanged( KGlobalSettings::Completion );
void aboutToShowContextMenu( QPopupMenu * p );
public slots:
virtual void setReadOnly(bool);
void rotateText( KCompletionBase::KeyBindingType type );
virtual void setCompletedText( const QString& );
void setCompletedItems( const QStringList& items );
void setCompletedItems( const QStringList& items, bool autoSuggest );
virtual void clear();
void setSqueezedText( const QString &text);
virtual void setText ( const QString& );
protected slots:
virtual void makeCompletion( const QString& );
void slotAboutToShow() {}
void slotCancelled() {}
void userCancelled(const QString & cancelText);
protected:
virtual void resizeEvent( QResizeEvent * );
virtual void keyPressEvent( QKeyEvent * );
virtual void mousePressEvent( QMouseEvent * );
virtual void mouseDoubleClickEvent( QMouseEvent * );
virtual void mouseReleaseEvent( QMouseEvent * );
virtual void contextMenuEvent( QContextMenuEvent * );
virtual QPopupMenu *createPopupMenu();
virtual void drawContents( QPainter *p );
virtual void dropEvent( QDropEvent * );
/*
* This function simply sets the lineedit text and
* highlights the text appropriately if the boolean
* value is set to true.
*
* @param text
* @param marked
*/
virtual void setCompletedText( const QString& /*text*/, bool /*marked*/ );
void setUserSelection( bool userSelection );
virtual void create( WId = 0, bool initializeWindow = true,
bool destroyOldWindow = true );
virtual void focusInEvent( QFocusEvent* );
virtual void focusOutEvent( QFocusEvent* );
bool autoSuggest() const;
private slots:
void completionMenuActivated( int id );
void tripleClickTimeout(); // resets possibleTripleClick
void slotRestoreSelectionColors();
void setTextWorkaround( const QString& text );
private:
// Constants that represent the ID's of the popup menu.
enum MenuID
{
Default = 42,
NoCompletion,
AutoCompletion,
ShellCompletion,
PopupCompletion,
ShortAutoCompletion,
PopupAutoCompletion
};
void init();
bool copySqueezedText( bool clipboard ) const;
bool overrideAccel (const QKeyEvent* e);
void setSqueezedText ();
bool m_bEnableMenu;
bool possibleTripleClick; // set in mousePressEvent, deleted in tripleClickTimeout
protected:
virtual void virtual_hook( int id, void* data );
private:
class KLineEditPrivate;
KLineEditPrivate *d;
};
#endif
KURL
KComboBox::create
virtual void create(WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
Reimplemented for internal reasons, the API is not affected.
Definition: kcombobox.cpp:236
KComboBox::setURLDropsEnabled
void setURLDropsEnabled(bool enable)
Enables/Disables handling of URL drops.
Definition: kcombobox.cpp:131
KCompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: kcompletionbox.h:43
KCompletionBase::setCompletedText
virtual void setCompletedText(const QString &text)=0
KComboBox::isContextMenuEnabled
bool isContextMenuEnabled() const
Returns true when the context menu is enabled.
Definition: kcombobox.h:270
KCompletionBase::setCompletionMode
virtual void setCompletionMode(KGlobalSettings::Completion mode)
KCompletion
KComboBox::isURLDropsEnabled
bool isURLDropsEnabled() const
Returns true when decoded URL drops are enabled.
Definition: kcombobox.cpp:137
KComboBox::returnPressed
void returnPressed()
Emitted when the user presses the Enter key.
KComboBox::setTrapReturnKey
void setTrapReturnKey(bool trap)
By default, KComboBox recognizes Key_Return and Key_Enter and emits the returnPressed() signals...
Definition: kcombobox.cpp:183
KCompletionBase
KComboBox::completion
void completion(const QString &)
Emitted when the completion key is pressed.
KLineEdit::isContextMenuEnabled
bool isContextMenuEnabled() const
Returns true when the context menu is enabled.
Definition: klineedit.h:228
KLineEdit::cursorAtEnd
void cursorAtEnd()
Puts the text cursor at the end of the string.
Definition: klineedit.h:197
KCompletionBase::setCompletedItems
virtual void setCompletedItems(const QStringList &items)=0
KLineEdit::setContextMenuEnabled
virtual void setContextMenuEnabled(bool showMenu)
Enables/disables the popup (context) menu.
Definition: klineedit.h:223
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:145
KComboBox::completionModeChanged
void completionModeChanged(KGlobalSettings::Completion)
Emitted whenever the completion mode is changed by the user through the context menu.
KComboBox::aboutToShowContextMenu
void aboutToShowContextMenu(QPopupMenu *p)
Emitted before the context menu is displayed.
KComboBox
An enhanced combo box.
Definition: kcombobox.h:144
KGlobalSettings::Completion
Completion
KCompletionBase::setCompletionObject
virtual void setCompletionObject(KCompletion *compObj, bool hsig=true)
KCompletionBase::KeyBindingType
KeyBindingType
KComboBox::rotateText
void rotateText(KCompletionBase::KeyBindingType type)
Iterates through all possible matches of the completed text or the history list.
Definition: kcombobox.cpp:171
KComboBox::textRotation
void textRotation(KCompletionBase::KeyBindingType)
Emitted when the text rotation key-bindings are pressed.
KComboBox::substringCompletion
void substringCompletion(const QString &)
Emitted when the shortcut for substring completion is pressed.
KComboBox::completionBox
KCompletionBox * completionBox(bool create=true)
Definition: kcombobox.cpp:228
KComboBox::trapReturnKey
bool trapReturnKey() const
KComboBox::eventFilter
virtual bool eventFilter(QObject *, QEvent *)
Re-implemented for internal reasons.
Definition: kcombobox.cpp:178
KComboBox::setContextMenuEnabled
virtual void setContextMenuEnabled(bool showMenu)
Enables or disable the popup (context) menu.
Definition: kcombobox.cpp:124
KLineEdit::slotAboutToShow
void slotAboutToShow()
Definition: klineedit.h:484
KComboBox::makeCompletion
virtual void makeCompletion(const QString &)
Completes text according to the completion mode.
Definition: kcombobox.cpp:155
KLineEdit::slotCancelled
void slotCancelled()
Definition: klineedit.h:489

KDE Home | KDE Accessibility Home | Description of Access Keys