• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

kcombobox.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, 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   Q_PROPERTY( bool trapReturnKey READ trapReturnKey WRITE setTrapReturnKey )
00151 
00152 public:
00153 
00161     KComboBox( QWidget *parent=0, const char *name=0 );
00162 
00172     KComboBox( bool rw, QWidget *parent=0, const char *name=0 );
00173 
00177     virtual ~KComboBox();
00178 
00184     void setEditURL( const KURL& url );
00185 
00191     void insertURL( const KURL& url, int index = -1 );
00192 
00199     void insertURL( const QPixmap& pixmap, const KURL& url, int index = -1 );
00200 
00206     void changeURL( const KURL& url, int index );
00207 
00213     void changeURL( const QPixmap& pixmap, const KURL& url, int index );
00214 
00223     int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
00224 
00235     virtual void setAutoCompletion( bool autocomplete );
00236 
00246     bool autoCompletion() const {
00247         return completionMode() == KGlobalSettings::CompletionAuto;
00248     }
00249 
00265     virtual void setContextMenuEnabled( bool showMenu );
00266 
00270     bool isContextMenuEnabled() const { return m_bEnableMenu; }
00271 
00279     void setURLDropsEnabled( bool enable );
00280 
00284     bool isURLDropsEnabled() const;
00285 
00295     bool contains( const QString& text ) const;
00296 
00310     void setTrapReturnKey( bool trap );
00311 
00318     bool trapReturnKey() const;
00319 
00323     virtual bool eventFilter( QObject *, QEvent * );
00324 
00334     KCompletionBox * completionBox( bool create = true );
00335 
00342     virtual void setLineEdit( QLineEdit * );
00343 
00344 signals:
00350     void returnPressed();
00351 
00361     void returnPressed( const QString& );
00362 
00371     void completion( const QString& );
00372 
00376     void substringCompletion( const QString& );
00377 
00389     void textRotation( KCompletionBase::KeyBindingType );
00390 
00395     void completionModeChanged( KGlobalSettings::Completion );
00396 
00406     void aboutToShowContextMenu( QPopupMenu * p );
00407 
00408 public slots:
00409 
00427     void rotateText( KCompletionBase::KeyBindingType type );
00428 
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 );
00448 
00453     void setCurrentItem(int index) { QComboBox::setCurrentItem(index); }
00454 
00455 protected slots:
00456 
00460     virtual void itemSelected( QListBoxItem* ) {}
00461 
00473     virtual void makeCompletion( const QString& );
00474 
00475 protected:
00476     /*
00477     * This function simply sets the lineedit text and
00478     * highlights the text appropriately if the boolean
00479     * value is set to true.
00480     *
00481     * @param
00482     * @param
00483     */
00484     virtual void setCompletedText( const QString& /* */, bool /*marked*/ );
00485 
00489     virtual void create( WId = 0, bool initializeWindow = true,
00490                          bool destroyOldWindow = true );
00491 
00492     virtual void wheelEvent( QWheelEvent *ev );
00493 
00494 private slots:
00495     void lineEditDeleted();
00496 
00497 private:
00501     void init();
00502     bool m_bEnableMenu; // ### BCI: unused, remove in KDE4
00503     bool m_trapReturnKey; // ### BCI: unused, remove in KDE4
00504 
00505 protected:
00506     virtual void virtual_hook( int id, void* data );
00507 
00508 private:
00509     class KComboBoxPrivate;
00510     KComboBoxPrivate* const d;
00511 };
00512 
00513 
00514 class KPixmapProvider;
00515 
00533 class KDEUI_EXPORT KHistoryCombo : public KComboBox
00534 {
00535     Q_OBJECT
00536     Q_PROPERTY( QStringList historyItems READ historyItems WRITE setHistoryItems )
00537 
00538 public:
00558     KHistoryCombo( QWidget *parent = 0L, const char *name = 0L );
00559 
00560     // ### merge these two constructors
00567     KHistoryCombo( bool useCompletion,
00568            QWidget *parent = 0L, const char *name = 0L );
00569 
00573     ~KHistoryCombo();
00574 
00581     inline void setHistoryItems( QStringList items ) {
00582         setHistoryItems(items, false);
00583     }
00584 
00626     void setHistoryItems( QStringList items, bool setCompletionList );
00627 
00634     QStringList historyItems() const;
00635 
00643     bool removeFromHistory( const QString& item );
00644 
00657     void setPixmapProvider( KPixmapProvider *prov );
00658 
00664     KPixmapProvider * pixmapProvider() const { return myPixProvider; }
00665 
00670     void reset() { slotReset(); }
00671 
00672 public slots:
00692     void addToHistory( const QString& item );
00693 
00697     void clearHistory();
00698 
00699 signals:
00703     void cleared();
00704 
00705 protected:
00709     virtual void keyPressEvent( QKeyEvent * );
00710 
00714     virtual void wheelEvent( QWheelEvent *ev );
00715 
00724     void insertItems( const QStringList& items );
00725 
00729     bool useCompletion() const { return compObj(); }
00730 
00731 private slots:
00735     void slotReset();
00736 
00741     void slotClear();
00742 
00746     void addContextMenuItems( QPopupMenu* );
00747 
00748 private:
00749     void init( bool useCompletion );
00750     void rotateUp();
00751     void rotateDown();
00752 
00756     int myIterateIndex;
00757 
00761     QString myText;
00762 
00767     bool myRotated;
00768     KPixmapProvider *myPixProvider;
00769 
00770 protected:
00771     virtual void virtual_hook( int id, void* data );
00772 private:
00773     class KHistoryComboPrivate;
00774     KHistoryComboPrivate* const d;
00775 };
00776 
00777 
00778 #endif
00779 

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal