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: 00059 KCompletionBox( QWidget *parent, const char *name = 0 ); 00060 00064 ~KCompletionBox(); 00065 00066 virtual QSize sizeHint() const; 00067 00068 public slots: 00072 QStringList items() const; 00073 00079 void insertItems( const QStringList& items, int index = -1 ); 00080 00084 void setItems( const QStringList& items ); 00085 00097 virtual void popup(); 00098 00108 void setTabHandling( bool enable ); 00109 00118 bool isTabHandling() const; 00119 00130 void setCancelledText( const QString& ); 00131 00135 QString cancelledText() const; 00136 00140 void down(); 00141 00145 void up(); 00146 00150 void pageDown(); 00151 00155 void pageUp(); 00156 00160 void home(); 00161 00165 void end(); 00166 00170 virtual void show(); 00171 00175 virtual void hide(); 00176 00177 signals: 00182 void activated( const QString& ); 00183 00188 void userCancelled( const QString& ); 00189 00190 protected: 00195 virtual bool eventFilter( QObject *, QEvent * ); 00196 00197 protected slots: 00202 virtual void slotActivated( QListBoxItem * ); 00203 00204 private slots: 00205 void slotSetCurrentItem( QListBoxItem *i ) { setCurrentItem( i ); } // grrr 00206 void slotCurrentChanged(); 00207 void cancelled(); 00208 void slotItemClicked( QListBoxItem * ); 00209 00210 protected: 00211 virtual void virtual_hook( int id, void* data ); 00212 00213 private: 00214 class KCompletionBoxPrivate; 00215 KCompletionBoxPrivate* d; 00216 }; 00217 00218 00219 #endif // KCOMPLETIONBOX_H