Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / khelpcenter / htmlsearch / ktagcombobox.h
blobccf9712f8302026f1d835e19ca05a375c2f62434
1 /*
2 * ktagcombobox.h - A combobox with support for submenues, icons and tags
4 * Copyright (c) 1999-2000 Hans Petter Bieker <bieker@kde.org>
6 * Requires the Qt widget libraries, available at no cost at
7 * http://www.troll.no/
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #ifndef __KTAGCOMBOBOX_H__
26 #define __KTAGCOMBOBOX_H__
28 #include <QComboBox>
30 class QPopupMenu;
33 * This class should be just like qcombobox, but it should be possible
34 * to have have a QIcon for each entry, and each entry should have a tag.
36 * It has also support for sub menus.
38 class KTagComboBox : public QComboBox
40 Q_OBJECT
42 public:
43 explicit KTagComboBox(QWidget *parent=0, const char *name=0);
44 ~KTagComboBox();
46 void insertItem(const QIcon& icon, const QString &text, const QString &tag, const QString &submenu = QString(), int index=-1 );
47 void insertItem(const QString &text, const QString &tag, const QString &submenu = QString(), int index=-1 );
48 void insertSeparator(const QString &submenu = QString(), int index=-1 );
49 void insertSubmenu(const QString &text, const QString &tag, const QString &submenu = QString(), int index=-1);
51 int count() const;
52 void clear();
55 * Tag of the selected item
57 QString currentTag() const;
58 QString tag ( int i ) const;
59 bool containsTag (const QString &str ) const;
62 * Set the current item
64 int currentItem() const;
65 void setCurrentItem(int i);
66 void setCurrentItem(const QString &code);
68 // widget stuff
69 virtual void setFont( const QFont & );
71 Q_SIGNALS:
72 void activated( int index );
73 void highlighted( int index );
75 private Q_SLOTS:
76 void internalActivate( int );
77 void internalHighlight( int );
79 protected:
80 void paintEvent( QPaintEvent * );
81 void mousePressEvent( QMouseEvent * );
82 void keyPressEvent( QKeyEvent *e );
83 void popupMenu();
85 private:
86 // work space for the new class
87 QStringList tags;
88 QPopupMenu *popup, *old_popup;
89 int current;
92 #endif