| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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
    00121 class KComboBox : public QComboBox, public KCompletionBase
    00122 {
    00123   Q_OBJECT
    00124   Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
    00125   Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
    00126   Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
    00127
    00128 public:
    00129
    00137     KComboBox( QWidget *parent=0, const char *name=0 );
    00138
    00148     KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
    00149
    00153     virtual ~KComboBox();
    00154
    00160     void setEditURL( const KURL& url );
    00161
    00167     void insertURL( const KURL& url, int index = -1 );
    00168
    00175     void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
    00176
    00182     void changeURL( const KURL& url, int index );
    00183
    00189     void changeURL( const QPixmap& pixmap, const KURL& url, int index );
    00190
    00199     int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
    00200
    00211     virtual void setAutoCompletion( bool autocomplete );
    00212
    00222     bool autoCompletion() const {
    00223         return completionMode() == KGlobalSettings::CompletionAuto;
    00224     }
    00225
    00242     virtual void setContextMenuEnabled( bool showMenu );
    00243
    00247     bool isContextMenuEnabled() const { return m_bEnableMenu; }
    00248
    00256     void setURLDropsEnabled( bool enable );
    00257
    00261     bool isURLDropsEnabled() const;
    00262
    00272     bool contains( const QString& text ) const;
    00273
    00288     void setTrapReturnKey( bool trap );
    00289
    00296     bool trapReturnKey() const;
    00297
    00303     virtual bool eventFilter( QObject *, QEvent * );
    00304
    00314     KCompletionBox * completionBox( bool create = true );
    00315
    00316     virtual void setLineEdit( QLineEdit * );
    00317
    00318 signals:
    00325     void returnPressed();
    00326
    00339     void returnPressed( const QString& );
    00340
    00352     void completion( const QString& );
    00353
    00357     void substringCompletion( const QString& );
    00358
    00371     void textRotation( KCompletionBase::KeyBindingType );
    00372
    00377     void completionModeChanged( KGlobalSettings::Completion );
    00378
    00391     void aboutToShowContextMenu( QPopupMenu * );
    00392
    00393 public slots:
    00394
    00412     void rotateText( KCompletionBase::KeyBindingType /* type */ );
    00413
    00420     virtual void setCompletedText( const QString& );
    00421
    00426     void setCompletedItems( const QStringList& items );
    00427
    00433     void setCurrentItem( const QString& item, bool insert = false, int index = -1 );
    00434     void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
    00435
    00436 protected slots:
    00437
    00441     virtual void itemSelected( QListBoxItem* ) {};
    00442
    00454     virtual void makeCompletion( const QString& );
    00455
    00456 protected:
    00457     /*
    00458     * This function simply sets the lineedit text and
    00459     * highlights the text appropriately if the boolean
    00460     * value is set to true.
    00461     *
    00462     * @param
    00463     * @param
    00464     */
    00465     virtual void setCompletedText( const QString& /* */, bool /*marked*/ );
    00466
    00470     virtual void create( WId = 0, bool initializeWindow = true,
    00471                          bool destroyOldWindow = true );
    00472
    00473     virtual void wheelEvent( QWheelEvent *ev );
    00474
    00475 private slots:
    00476     void lineEditDeleted();
    00477
    00478 private:
    00479     // Constants that represent the ID's of the popup menu.
    00480     // TODO: See if we can replace this mess with KActionMenu
    00481     // in the future though this is working lovely.
    00482     enum MenuID {
    00483         Default=0,
    00484         Cut,
    00485         Copy,
    00486         Paste,
    00487         Clear,
    00488         Unselect,
    00489         SelectAll,
    00490         NoCompletion,
    00491         AutoCompletion,
    00492         ShellCompletion,
    00493         PopupCompletion,
    00494         SemiAutoCompletion
    00495     };
    00496
    00500     void init();
    00501
    00502     // BC: No longer needed...
    00503     bool m_bEnableMenu;
    00504
    00505     // Flag to determine whether return-key events should be propagated...
    00506     bool m_trapReturnKey; // ### BCI: unused, remove in KDE4
    00507
    00508 protected:
    00509     virtual void virtual_hook( int id, void* data );
    00510
    00511 private:
    00512     class KComboBoxPrivate;
    00513     KComboBoxPrivate *d;
    00514 };
    00515
    00516
    00517 class KPixmapProvider;
    00518
    00535 class KHistoryCombo : public KComboBox
    00536 {
    00537     Q_OBJECT
    00538     Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
    00539
    00540 public:
    00560     KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
    00561
    00562     // ### merge these two constructors
    00569     KHistoryCombo( bool useCompletion,
    00570                    QWidget *parent = 0L, const char *name = 0L );
    00571
    00575     ~KHistoryCombo();
    00576
    00583     inline void setHistoryItems( QStringList items ) {
    00584         setHistoryItems(items, false);
    00585     }
    00586
    00628     void setHistoryItems( QStringList items, bool setCompletionList );
    00629
    00636     QStringList historyItems() const;
    00637
    00645     bool removeFromHistory( const QString& item );
    00646
    00659     void setPixmapProvider( KPixmapProvider *prov );
    00660
    00666     KPixmapProvider * pixmapProvider() const { return myPixProvider; }
    00667
    00672     void reset() { slotReset(); }
    00673
    00674 public slots:
    00694     void addToHistory( const QString& item );
    00695
    00699     void clearHistory();
    00700
    00701 signals:
    00705     void cleared();
    00706
    00707 protected:
    00711     virtual void keyPressEvent( QKeyEvent * );
    00712
    00716     virtual void wheelEvent( QWheelEvent *ev );
    00717
    00726     void insertItems( const QStringList& items );
    00727
    00731     bool useCompletion() const { return compObj() != 0L; }
    00732
    00733 private slots:
    00737     void slotReset();
    00738
    00743     void slotClear();
    00744
    00748     void addContextMenuItems( QPopupMenu* );
    00749
    00750 private:
    00751     void init( bool useCompletion );
    00752     void rotateUp();
    00753     void rotateDown();
    00754
    00758     int myIterateIndex;
    00759
    00763     QString myText;
    00764
    00769     bool myRotated;
    00770     KPixmapProvider *myPixProvider;
    00771
    00772 protected:
    00773     virtual void virtual_hook( int id, void* data );
    00774 private:
    00775     class KHistoryComboPrivate;
    00776     KHistoryComboPrivate *d;
    00777 };
    00778
    00779
    00780 #endif
    00781

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:22 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001