Salome HOME
Fixing a bug : Salome GUI style needs addLibraryPath() method to be called
[modules/gui.git] / src / Qtx / QtxComboBox.h
1 // File:      QtxComboBox.h
2 // Author:    Sergey TELKOV
3
4 #ifndef QTXCOMBOBOX_H
5 #define QTXCOMBOBOX_H
6
7 #include "Qtx.h"
8
9 #include <qmap.h>
10 #include <qcombobox.h>
11
12 #ifdef WIN32
13 #pragma warning( disable:4251 )
14 #endif
15
16 class QTX_EXPORT QtxComboBox : public QComboBox
17 {
18     Q_OBJECT
19
20     typedef QMap<int, int> IndexIdMap;
21
22 public:
23     QtxComboBox( QWidget* = 0, const char* = 0 );
24     QtxComboBox( bool, QWidget* = 0, const char* = 0 );
25     virtual ~QtxComboBox();
26
27     bool         isCleared() const;
28     void         setCleared( const bool );
29
30     virtual void setCurrentItem( int );
31     virtual void setCurrentText( const QString& );
32
33     int          currentId() const;
34     void         setCurrentId( int );
35
36     void         insertItem( const int, const QString&, int = -1 );
37     void         insertItem( const int, const QPixmap&, int = -1 );
38     void         insertItem( const int, const QPixmap&, const QString&, int = -1 );
39 //  void         insertStringList( const QIntList&, const QStringList&, int = -1 );
40
41 signals:
42     void         activatedId( int );
43     void         highlightedId( int );
44
45 private slots:
46     void         onActivated( int );
47     void         onActivated( const QString& );
48
49 protected:
50     virtual void paintEvent( QPaintEvent* );
51
52 private:
53     int          id( const int ) const;
54     int          index( const int ) const;
55
56     void         resetClear();
57     void         paintClear( QPaintEvent* );
58
59 private:
60     bool         myCleared;
61     IndexIdMap   myIndexId;
62 };
63
64 #ifdef WIN32
65 #pragma warning( default:4251 )
66 #endif
67
68 #endif