Back to index

salome-gui  6.5.0
QDS_ComboBox.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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 as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
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
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef QDS_COMBOBOX_H
00024 #define QDS_COMBOBOX_H
00025 
00026 #include "QDS_Datum.h"
00027 
00028 #include <QMap>
00029 #include <QPixmap>
00030 #include <QStringList>
00031 
00032 #include <Qtx.h>
00033 
00034 class QtxComboBox;
00035 
00036 #ifdef WIN32
00037 #pragma warning( disable:4251 )
00038 #endif
00039 
00040 class QDS_EXPORT QDS_ComboBox : public QDS_Datum
00041 {
00042   Q_OBJECT
00043 
00044 public:
00045   QDS_ComboBox( const QString&, QWidget* = 0, const int = All, const QString& = QString() );
00046   virtual ~QDS_ComboBox();
00047 
00048   bool                       editable() const;
00049   void                       setEditable( const bool );
00050 
00051   int                        count( bool = false ) const;
00052   void                       values( QList<int>&, bool = false ) const;
00053 
00054   virtual int                integerValue() const;
00055   virtual double             doubleValue() const;
00056   virtual void               setIntegerValue( const int );
00057   virtual void               setDoubleValue( const double );
00058 
00059   bool                       state( const int ) const;
00060   void                       setState( const bool, const int, const bool = true );
00061   void                       setState( const bool, const QList<int>&, const bool = true );
00062   void                       setValues( const QList<int>&, const QStringList& );
00063   void                       setValues( const QStringList& );
00064 
00065   virtual void               reset();
00066 
00067   int                        stringToValue( const QString& ) const;
00068   QString                    valueToString( const int ) const;
00069 
00070 signals:
00071   void                       activated( int );
00072   void                       activated( const QString& );
00073 
00074 protected slots:
00075   virtual void               onActivated( int );
00076   virtual void               onTextChanged( const QString& );
00077 
00078 protected:
00079   QtxComboBox*               comboBox() const;
00080   virtual QWidget*           createControl( QWidget* );
00081 
00082   virtual QString            getString() const;
00083   virtual void               setString( const QString& );
00084 
00085   virtual void               unitSystemChanged( const QString& );
00086 
00087 private:
00088   int                        getId( const int ) const;
00089   int                        getId( const QString& ) const;
00090   int                        getIndex( const int ) const;
00091   int                        getIndex( const QString& ) const;
00092 
00093   void                       updateComboBox();
00094 
00095 private:
00096   typedef QMap<int, QPixmap> IdIconsMap;
00097   typedef QMap<int, QString> IdValueMap;
00098   typedef QMap<int, bool>    IdStateMap;
00099   typedef QMap<int, int>     IdIndexMap;
00100 
00101 private:
00102   IdValueMap                 myValue;
00103   IdStateMap                 myState;
00104   IdIndexMap                 myIndex;
00105   IdIconsMap                 myIcons;
00106 
00107   QIntList                   myDataIds;
00108   QIntList                   myUserIds;
00109   QStringList                myUserNames;
00110 };
00111 
00112 #ifdef WIN32
00113 #pragma warning( default:4251 )
00114 #endif
00115 
00116 #endif