kcompletionbox.h
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 00004 2000 Stefan Schimanski <1Stein@gmx.de> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License (LGPL) as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #ifndef KCOMPLETIONBOX_H 00023 #define KCOMPLETIONBOX_H 00024 00025 class QEvent; 00026 #include <qstringlist.h> 00027 #include <klistbox.h> 00028 00041 class KCompletionBox : public KListBox 00042 { 00043 Q_OBJECT 00044 Q_PROPERTY( bool isTabHandling READ isTabHandling WRITE setTabHandling ) 00045 Q_PROPERTY(QString cancelledText READ cancelledText WRITE setCancelledText) 00046 00047 public: 00054 KCompletionBox( QWidget *parent, const char *name = 0 ); 00055 00059 ~KCompletionBox(); 00060 00061 virtual QSize sizeHint() const; 00062 00063 public slots: 00067 QStringList items() const; 00068 00074 void insertItems( const QStringList& items, int index = -1 ); 00075 00079 void setItems( const QStringList& items ); 00080 00092 virtual void popup(); 00093 00103 void setTabHandling( bool enable ); 00104 00113 bool isTabHandling() const; 00114 00125 void setCancelledText( const QString& ); 00126 00130 QString cancelledText() const; 00131 00135 void down(); 00136 00140 void up(); 00141 00145 void pageDown(); 00146 00150 void pageUp(); 00151 00155 void home(); 00156 00160 void end(); 00161 00165 virtual void show(); 00166 00170 virtual void hide(); 00171 00172 signals: 00177 void activated( const QString& ); 00178 00183 void userCancelled( const QString& ); 00184 00185 protected: 00190 virtual bool eventFilter( QObject *, QEvent * ); 00191 00192 protected slots: 00197 virtual void slotActivated( QListBoxItem * ); 00198 00199 private slots: 00200 void slotSetCurrentItem( QListBoxItem *i ) { setCurrentItem( i ); } // grrr 00201 void slotCurrentChanged(); 00202 void cancelled(); 00203 void slotItemClicked( QListBoxItem * ); 00204 00205 protected: 00206 virtual void virtual_hook( int id, void* data ); 00207 00208 private: 00209 class KCompletionBoxPrivate; 00210 KCompletionBoxPrivate* d; 00211 }; 00212 00213 00214 #endif // KCOMPLETIONBOX_H