00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef _KCOMBOBOX_H
00023
#define _KCOMBOBOX_H
00024
00025
#include <qlineedit.h>
00026
#include <qcombobox.h>
00027
00028
#include <kcompletion.h>
00029
00030
class QListBoxItem;
00031
class QPopupMenu;
00032
class QLineEdit;
00033
00034
class KCompletionBox;
00035
class KURL;
00036
00127 class KComboBox :
public QComboBox,
public KCompletionBase
00128 {
00129 Q_OBJECT
00130 Q_PROPERTY(
bool autoCompletion READ autoCompletion WRITE
setAutoCompletion )
00131 Q_PROPERTY(
bool contextMenuEnabled READ
isContextMenuEnabled WRITE
setContextMenuEnabled )
00132 Q_PROPERTY(
bool urlDropsEnabled READ
isURLDropsEnabled WRITE
setURLDropsEnabled )
00133
00134
public:
00135
00143
KComboBox(
QWidget *parent=0,
const char *name=0 );
00144
00154
KComboBox(
bool rw,
QWidget *parent=0,
const char *name=0 );
00155
00159
virtual ~KComboBox();
00160
00166
void setEditURL(
const KURL& url );
00167
00173
void insertURL(
const KURL& url,
int index = -1 );
00174
00181
void insertURL(
const QPixmap& pixmap,
const KURL& url,
int index = -1 );
00182
00188
void changeURL(
const KURL& url,
int index );
00189
00195
void changeURL(
const QPixmap& pixmap,
const KURL& url,
int index );
00196
00205 int cursorPosition()
const {
return (
lineEdit() ) ?
lineEdit()->cursorPosition() : -1; }
00206
00217
virtual void setAutoCompletion(
bool autocomplete );
00218
00228 bool autoCompletion()
const {
00229
return completionMode() == KGlobalSettings::CompletionAuto;
00230 }
00231
00247
virtual void setContextMenuEnabled(
bool showMenu );
00248
00252 bool isContextMenuEnabled()
const {
return m_bEnableMenu; }
00253
00261
void setURLDropsEnabled(
bool enable );
00262
00266
bool isURLDropsEnabled() const;
00267
00277
bool contains( const
QString& text ) const;
00278
00293
void setTrapReturnKey(
bool trap );
00294
00301
bool trapReturnKey() const;
00302
00306 virtual
bool eventFilter(
QObject *,
QEvent * );
00307
00317
KCompletionBox * completionBox(
bool create = true );
00318
00325 virtual
void setLineEdit(
QLineEdit * );
00326
00327 signals:
00333
void returnPressed();
00334
00344
void returnPressed( const
QString& );
00345
00354
void completion( const QString& );
00355
00359
void substringCompletion( const QString& );
00360
00372
void textRotation(
KCompletionBase::KeyBindingType );
00373
00378
void completionModeChanged(
KGlobalSettings::Completion );
00379
00389
void aboutToShowContextMenu(
QPopupMenu * p );
00390
00391 public slots:
00392
00410
void rotateText(
KCompletionBase::KeyBindingType type );
00411
00418 virtual
void setCompletedText( const QString& );
00419
00424
void setCompletedItems( const
QStringList& items );
00425
00431
void setCurrentItem( const QString& item,
bool insert = false,
int index = -1 );
00436 void setCurrentItem(
int index) {
QComboBox::setCurrentItem(index); }
00437
00438
protected slots:
00439
00443 virtual void itemSelected(
QListBoxItem* ) {};
00444
00456
virtual void makeCompletion(
const QString& );
00457
00458
protected:
00459
00460
00461
00462
00463
00464
00465
00466
00467
virtual void setCompletedText(
const QString& ,
bool );
00468
00472
virtual void create( WId = 0,
bool initializeWindow =
true,
00473
bool destroyOldWindow =
true );
00474
00475
virtual void wheelEvent(
QWheelEvent *ev );
00476
00477
private slots:
00478
void lineEditDeleted();
00479
00480
private:
00484
void init();
00485
bool m_bEnableMenu;
00486
bool m_trapReturnKey;
00487
00488
protected:
00489
virtual void virtual_hook(
int id,
void* data );
00490
00491
private:
00492
class KComboBoxPrivate;
00493 KComboBoxPrivate *d;
00494 };
00495
00496
00497
class KPixmapProvider;
00498
00515 class KHistoryCombo :
public KComboBox
00516 {
00517 Q_OBJECT
00518 Q_PROPERTY(
QStringList historyItems READ historyItems WRITE
setHistoryItems )
00519
00520
public:
00540
KHistoryCombo(
QWidget *parent = 0L,
const char *name = 0L );
00541
00542
00549
KHistoryCombo(
bool useCompletion,
00550
QWidget *parent = 0L,
const char *name = 0L );
00551
00555
~KHistoryCombo();
00556
00563 inline void setHistoryItems(
QStringList items ) {
00564
setHistoryItems(items,
false);
00565 }
00566
00608
void setHistoryItems(
QStringList items,
bool setCompletionList );
00609
00616
QStringList historyItems() const;
00617
00625
bool removeFromHistory( const
QString& item );
00626
00639
void setPixmapProvider(
KPixmapProvider *prov );
00640
00646 KPixmapProvider * pixmapProvider()
const {
return myPixProvider; }
00647
00652 void reset() { slotReset(); }
00653
00654
public slots:
00674
void addToHistory(
const QString& item );
00675
00679
void clearHistory();
00680
00681 signals:
00685
void cleared();
00686
00687
protected:
00691
virtual void keyPressEvent(
QKeyEvent * );
00692
00696
virtual void wheelEvent(
QWheelEvent *ev );
00697
00706
void insertItems(
const QStringList& items );
00707
00711 bool useCompletion()
const {
return compObj() != 0L; }
00712
00713
private slots:
00717
void slotReset();
00718
00723
void slotClear();
00724
00728
void addContextMenuItems(
QPopupMenu* );
00729
00730
private:
00731
void init(
bool useCompletion );
00732
void rotateUp();
00733
void rotateDown();
00734
00738
int myIterateIndex;
00739
00743
QString myText;
00744
00749
bool myRotated;
00750
KPixmapProvider *myPixProvider;
00751
00752
protected:
00753
virtual void virtual_hook(
int id,
void* data );
00754
private:
00755
class KHistoryComboPrivate;
00756 KHistoryComboPrivate *d;
00757 };
00758
00759
00760
#endif
00761