Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / QDS / QDS_ComboBox.h
1 // Copyright (C) 2005  CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef QDS_COMBOBOX_H
20 #define QDS_COMBOBOX_H
21
22 #include "QDS_Datum.h"
23
24 #include <qmap.h>
25 #include <qpixmap.h>
26 #include <qstringlist.h>
27
28 #include <QtxComboBox.h>
29
30 #ifdef WNT
31 #pragma warning( disable:4251 )
32 #endif
33
34 class QDS_EXPORT QDS_ComboBox : public QDS_Datum
35 {
36   Q_OBJECT
37
38 public:
39   QDS_ComboBox( const QString&, QWidget* = 0, const int = All, const QString& = QString::null );
40   virtual ~QDS_ComboBox();
41
42   bool                       editable() const;
43   void                       setEditable( const bool );
44
45   int                        count( bool = false ) const;
46   void                       values( QValueList<int>&, bool = false ) const;
47
48   virtual int                integerValue() const;
49   virtual double             doubleValue() const;
50   virtual void               setIntegerValue( const int );
51   virtual void               setDoubleValue( const double );
52
53   bool                       state( const int ) const;
54   void                       setState( const bool, const int, const bool = true );
55   void                       setState( const bool, const QValueList<int>&, const bool = true );
56   void                       setValues( const QValueList<int>&, const QStringList& );
57   void                       setValues( const QStringList& );
58
59   virtual void               reset();
60
61   int                        stringToValue( const QString& ) const;
62   QString                    valueToString( const int ) const;
63
64 signals:
65   void                       activated( int );
66   void                       activated( const QString& );
67
68 protected slots:
69   virtual void               onActivated( int );
70   virtual void               onTextChanged( const QString& );
71
72 protected:
73   QtxComboBox*               comboBox() const;
74   virtual QWidget*           createControl( QWidget* );
75
76   virtual QString            getString() const;
77   virtual void               setString( const QString& );
78
79   virtual void               unitSystemChanged( const QString& );
80
81 private:
82   int                        getId( const int ) const;
83   int                        getId( const QString& ) const;
84   int                        getIndex( const int ) const;
85   int                        getIndex( const QString& ) const;
86
87   void                       updateComboBox();
88
89 private:
90   typedef QMap<int, QPixmap> IdIconsMap;
91   typedef QMap<int, QString> IdValueMap;
92   typedef QMap<int, bool>    IdStateMap;
93   typedef QMap<int, int>     IdIndexMap;
94
95 private:
96   IdValueMap                 myValue;
97   IdStateMap                 myState;
98   IdIndexMap                 myIndex;
99   IdIconsMap                 myIcons;
100
101   QIntList                   myDataIds;
102   QIntList                   myUserIds;
103   QStringList                myUserNames;
104 };
105
106 #ifdef WNT
107 #pragma warning( default:4251 )
108 #endif
109
110 #endif