moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / keduca / keducabuilder / ktagcombobox.h
blob4c92e9644b36a9cdc4a527bb529025053e7a2a48
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifndef __KTAGCOMBOBOX_H__
26 #define __KTAGCOMBOBOX_H__
28 #include <qcombobox.h>
29 #include <qiconset.h>
30 class QPopupMenu;
31 class QStringList;
34 * This class should be just like qcombobox, but it should be possible
35 * to have have a QIconSet for each entry, and each entry should have a tag.
37 * It has also support for sub menues.
39 class KTagComboBox : public QComboBox
41 Q_OBJECT
43 public:
44 KTagComboBox(QWidget *parent=0, const char *name=0);
45 ~KTagComboBox();
47 void insertItem(const QIconSet& icon, const QString &text, const QString &tag, const QString &submenu = QString::null, int index=-1 );
48 void insertItem(const QString &text, const QString &tag, const QString &submenu = QString::null, int index=-1 );
49 void insertSeparator(const QString &submenu = QString::null, int index=-1 );
50 void insertSubmenu(const QString &text, const QString &tag, const QString &submenu = QString::null, int index=-1);
51 void changeItem( const QString &text, int index );
53 int count() const;
54 void clear();
57 * Tag of the selected item
59 QString currentTag() const;
60 QString tag ( int i ) const;
61 bool containsTag (const QString &str ) const;
64 * Set the current item
66 int currentItem() const;
67 void setCurrentItem(int i);
68 void setCurrentItem(const QString &code);
70 // widget stuff
71 virtual void setFont( const QFont & );
73 signals:
74 void activated( int index );
75 void highlighted( int index );
77 private slots:
78 void internalActivate( int );
79 void internalHighlight( int );
81 protected:
82 void paintEvent( QPaintEvent * );
83 void mousePressEvent( QMouseEvent * );
84 void keyPressEvent( QKeyEvent *e );
85 void popupMenu();
87 private:
88 // work space for the new class
89 QStringList *_tags;
90 QPopupMenu *_popup;
91 int _current;
94 #endif