kcombobox.h
/* This file is part of the KDE libraries
Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org>
Copyright (c) 2000,2001 Carsten Pfeiffer <pfeiffer@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 _KCOMBOBOX_H
#define _KCOMBOBOX_H
#include <qlineedit.h>
#include <qcombobox.h>
#include <kcompletion.h>
class QListBoxItem;
class QPopupMenu;
class QLineEdit;
class KCompletionBox;
class KURL;
class KDEUI_EXPORT KComboBox : public QComboBox, public KCompletionBase
{
Q_OBJECT
Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
Q_PROPERTY( bool trapReturnKey READ trapReturnKey WRITE setTrapReturnKey )
public:
KComboBox( QWidget *parent=0, const char *name=0 );
KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
virtual ~KComboBox();
void setEditURL( const KURL& url );
void insertURL( const KURL& url, int index = -1 );
void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
void changeURL( const KURL& url, int index );
void changeURL( const QPixmap& pixmap, const KURL& url, int index );
int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
virtual void setAutoCompletion( bool autocomplete );
bool autoCompletion() const {
return completionMode() == KGlobalSettings::CompletionAuto;
}
virtual void setContextMenuEnabled( bool showMenu );
bool isContextMenuEnabled() const { return m_bEnableMenu; }
void setURLDropsEnabled( bool enable );
bool isURLDropsEnabled() const;
bool contains( const QString& text ) const;
void setTrapReturnKey( bool trap );
bool trapReturnKey() const;
virtual bool eventFilter( QObject *, QEvent * );
KCompletionBox * completionBox( bool create = true );
virtual void setLineEdit( QLineEdit * );
signals:
void returnPressed();
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:
void rotateText( KCompletionBase::KeyBindingType type );
virtual void setCompletedText( const QString& );
void setCompletedItems( const QStringList& items );
void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
protected slots:
virtual void itemSelected( QListBoxItem* ) {}
virtual void makeCompletion( const QString& );
protected:
/*
* This function simply sets the lineedit text and
* highlights the text appropriately if the boolean
* value is set to true.
*
* @param
* @param
*/
virtual void setCompletedText( const QString& /* */, bool /*marked*/ );
virtual void create( WId = 0, bool initializeWindow = true,
bool destroyOldWindow = true );
virtual void wheelEvent( QWheelEvent *ev );
private slots:
void lineEditDeleted();
private:
void init();
bool m_bEnableMenu; // ### BCI: unused, remove in KDE4
bool m_trapReturnKey; // ### BCI: unused, remove in KDE4
protected:
virtual void virtual_hook( int id, void* data );
private:
class KComboBoxPrivate;
KComboBoxPrivate* const d;
};
class KPixmapProvider;
class KDEUI_EXPORT KHistoryCombo : public KComboBox
{
Q_OBJECT
Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
public:
KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
// ### merge these two constructors
KHistoryCombo( bool useCompletion,
QWidget *parent = 0L, const char *name = 0L );
~KHistoryCombo();
inline void setHistoryItems( QStringList items ) {
setHistoryItems(items, false);
}
void setHistoryItems( QStringList items, bool setCompletionList );
QStringList historyItems() const;
bool removeFromHistory( const QString& item );
void setPixmapProvider( KPixmapProvider *prov );
KPixmapProvider * pixmapProvider() const { return myPixProvider; }
void reset() { slotReset(); }
public slots:
void addToHistory( const QString& item );
void clearHistory();
signals:
void cleared();
protected:
virtual void keyPressEvent( QKeyEvent * );
virtual void wheelEvent( QWheelEvent *ev );
void insertItems( const QStringList& items );
bool useCompletion() const { return compObj(); }
private slots:
void slotReset();
void slotClear();
void addContextMenuItems( QPopupMenu* );
private:
void init( bool useCompletion );
void rotateUp();
void rotateDown();
int myIterateIndex;
QString myText;
bool myRotated;
KPixmapProvider *myPixProvider;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KHistoryComboPrivate;
KHistoryComboPrivate* const d;
};
#endif
KURL
KHistoryCombo::useCompletion
bool useCompletion() const
Definition: kcombobox.h:729
KHistoryCombo::pixmapProvider
KPixmapProvider * pixmapProvider() const
Definition: kcombobox.h:664
KCompletionBox
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
Definition: kcompletionbox.h:43
KHistoryCombo::setHistoryItems
void setHistoryItems(QStringList items)
Inserts items into the combobox.
Definition: kcombobox.h:581
KCompletionBase::setCompletedText
virtual void setCompletedText(const QString &text)=0
KComboBox::cursorPosition
int cursorPosition() const
Returns the current cursor position.
Definition: kcombobox.h:223
KComboBox::isContextMenuEnabled
bool isContextMenuEnabled() const
Returns true when the context menu is enabled.
Definition: kcombobox.h:270
KHistoryCombo::reset
void reset()
Resets the current position of the up/down history.
Definition: kcombobox.h:670
KGlobalSettings::CompletionAuto
KComboBox::autoCompletion
bool autoCompletion() const
Re-implemented from QComboBox.
Definition: kcombobox.h:246
KComboBox::setCurrentItem
void setCurrentItem(int index)
Simply calls QComboBox' implementation.
Definition: kcombobox.h:453
KCompletionBase
KCompletionBase::setCompletedItems
virtual void setCompletedItems(const QStringList &items)=0
KComboBox
An enhanced combo box.
Definition: kcombobox.h:144
KGlobalSettings::Completion
Completion
KCompletionBase::KeyBindingType
KeyBindingType
KHistoryCombo
A combobox for offering a history and completion.
Definition: kcombobox.h:533
KPixmapProvider
KCompletionBase::completionMode
KGlobalSettings::Completion completionMode() const
KCompletionBase::compObj
KCompletion * compObj() const
KComboBox::itemSelected
virtual void itemSelected(QListBoxItem *)
Definition: kcombobox.h:460

KDE Home | KDE Accessibility Home | Description of Access Keys