kdeui Library API Documentation

kcombobox.h

00001 /* This file is part of the KDE libraries
00002 
00003    Copyright (c) 2000,2001 Dawit Alemayehu <adawit@kde.org>
00004    Copyright (c) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser 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    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser 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 _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 
00144 class KDEUI_EXPORT KComboBox : public QComboBox, public KCompletionBase
00145 {
00146   Q_OBJECT
00147   Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
00148   Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
00149   Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
00150 
00151 public:
00152 
00160     KComboBox( QWidget *parent=0, const char *name=0 );
00161 
00171     KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
00172 
00176     virtual ~KComboBox();
00177 
00183     void setEditURL( const KURL& url );
00184 
00190     void insertURL( const KURL& url, int index = -1 );
00191 
00198     void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
00199 
00205     void changeURL( const KURL& url, int index );
00206 
00212     void changeURL( const QPixmap& pixmap, const KURL& url, int index );
00213 
00222     int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
00223 
00234     virtual void setAutoCompletion( bool autocomplete );
00235 
00245     bool autoCompletion() const {
00246         return completionMode() == KGlobalSettings::CompletionAuto;
00247     }
00248 
00264     virtual void setContextMenuEnabled( bool showMenu );
00265 
00269     bool isContextMenuEnabled() const { return m_bEnableMenu; }
00270 
00278     void setURLDropsEnabled( bool enable );
00279 
00283     bool isURLDropsEnabled() const;
00284 
00294     bool contains( const QString& text ) const;
00295 
00309     void setTrapReturnKey( bool trap );
00310 
00317     bool trapReturnKey() const;
00318 
00322     virtual bool eventFilter( QObject *, QEvent * );
00323 
00333     KCompletionBox * completionBox( bool create = true );
00334 
00341     virtual void setLineEdit( QLineEdit * );
00342 
00343 signals:
00349     void returnPressed();
00350 
00360     void returnPressed( const QString& );
00361 
00370     void completion( const QString& );
00371 
00375     void substringCompletion( const QString& );
00376 
00388     void textRotation( KCompletionBase::KeyBindingType );
00389 
00394     void completionModeChanged( KGlobalSettings::Completion );
00395 
00405     void aboutToShowContextMenu( QPopupMenu * p );
00406 
00407 public slots:
00408 
00426     void rotateText( KCompletionBase::KeyBindingType type );
00427 
00434     virtual void setCompletedText( const QString& );
00435 
00440     void setCompletedItems( const QStringList& items );
00441 
00447     void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
00452     void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
00453 
00454 protected slots:
00455 
00459     virtual void itemSelected( QListBoxItem* ) {};
00460 
00472     virtual void makeCompletion( const QString& );
00473 
00474 protected:
00475     /*
00476     * This function simply sets the lineedit text and
00477     * highlights the text appropriately if the boolean
00478     * value is set to true.
00479     *
00480     * @param
00481     * @param
00482     */
00483     virtual void setCompletedText( const QString& /* */, bool /*marked*/ );
00484 
00488     virtual void create( WId = 0, bool initializeWindow = true,
00489                          bool destroyOldWindow = true );
00490 
00491     virtual void wheelEvent( QWheelEvent *ev );
00492 
00493 private slots:
00494     void lineEditDeleted();
00495 
00496 private:
00500     void init();
00501     bool m_bEnableMenu; // ### BCI: unused, remove in KDE4
00502     bool m_trapReturnKey; // ### BCI: unused, remove in KDE4
00503 
00504 protected:
00505     virtual void virtual_hook( int id, void* data );
00506 
00507 private:
00508     class KComboBoxPrivate;
00509     KComboBoxPrivate* d;
00510 };
00511 
00512 
00513 class KPixmapProvider;
00514 
00532 class KDEUI_EXPORT KHistoryCombo : public KComboBox
00533 {
00534     Q_OBJECT
00535     Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
00536 
00537 public:
00557     KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
00558 
00559     // ### merge these two constructors
00566     KHistoryCombo( bool useCompletion,
00567            QWidget *parent = 0L, const char *name = 0L );
00568 
00572     ~KHistoryCombo();
00573 
00580     inline void setHistoryItems( QStringList items ) {
00581         setHistoryItems(items, false);
00582     }
00583 
00625     void setHistoryItems( QStringList items, bool setCompletionList );
00626 
00633     QStringList historyItems() const;
00634 
00642     bool removeFromHistory( const QString& item );
00643 
00656     void setPixmapProvider( KPixmapProvider *prov );
00657 
00663     KPixmapProvider * pixmapProvider() const { return myPixProvider; }
00664 
00669     void reset() { slotReset(); }
00670 
00671 public slots:
00691     void addToHistory( const QString& item );
00692 
00696     void clearHistory();
00697 
00698 signals:
00702     void cleared();
00703 
00704 protected:
00708     virtual void keyPressEvent( QKeyEvent * );
00709 
00713     virtual void wheelEvent( QWheelEvent *ev );
00714 
00723     void insertItems( const QStringList& items );
00724 
00728     bool useCompletion() const { return compObj(); }
00729 
00730 private slots:
00734     void slotReset();
00735 
00740     void slotClear();
00741 
00745     void addContextMenuItems( QPopupMenu* );
00746 
00747 private:
00748     void init( bool useCompletion );
00749     void rotateUp();
00750     void rotateDown();
00751 
00755     int myIterateIndex;
00756 
00760     QString myText;
00761 
00766     bool myRotated;
00767     KPixmapProvider *myPixProvider;
00768 
00769 protected:
00770     virtual void virtual_hook( int id, void* data );
00771 private:
00772     class KHistoryComboPrivate;
00773     KHistoryComboPrivate* d;
00774 };
00775 
00776 
00777 #endif
00778 
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:11:59 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003