Back to index

salome-gui  6.5.0
SalomeApp_IntSpinBox.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File:      SalomeApp_IntSpinBox.h
00021 // Author:    Oleg UVAROV
00022 //
00023 #ifndef SALOMEAPP_INTSPINBOX_H
00024 #define SALOMEAPP_INTSPINBOX_H
00025 
00026 #include "SalomeApp.h"
00027 
00028 #include <QtxIntSpinBox.h>
00029 
00030 #include <QValidator>
00031 
00032 class SALOMEAPP_EXPORT SalomeApp_IntSpinBox : public QtxIntSpinBox
00033 {
00034   Q_OBJECT
00035 
00036   enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
00037   enum SearchState { NotFound = 0, IncorrectType, Found };
00038 
00039 public:
00040   SalomeApp_IntSpinBox( QWidget* = 0 );
00041   SalomeApp_IntSpinBox( int, int, int = 1, QWidget* = 0, bool = true, bool = true );
00042   virtual ~SalomeApp_IntSpinBox();
00043 
00044   virtual void              stepBy( int );
00045 
00046   virtual int               valueFromText( const QString& ) const;
00047   virtual QString           textFromValue( int ) const;
00048 
00049   virtual QValidator::State validate( QString&, int& ) const;
00050 
00051   virtual bool              isValid( QString& msg, bool = false );
00052 
00053   virtual void              setDefaultValue( const int );
00054 
00055   virtual void              setValue( int );
00056 
00057   virtual void              setText(const QString& );
00058 
00059   void                      setAcceptNames( const bool );
00060   bool                      isAcceptNames() const;
00061 
00062   void                      setShowTipOnValidate( const bool );
00063   bool                      isShowTipOnValidate() const;
00064 
00065 signals:
00066   void                      textChanged( const QString& );
00067 
00068 protected:
00069   State                     isValid( const QString&, int& ) const;
00070 
00071   int                       defaultValue() const;
00072   bool                      checkRange( const int ) const;
00073 
00074   SearchState               findVariable( const QString&, int& ) const;
00075 
00076 protected:
00077   virtual void              keyPressEvent( QKeyEvent* );
00078   virtual void              showEvent( QShowEvent* );
00079 
00080 protected slots:
00081   void                      onEditingFinished();
00082   void                      onTextChanged( const QString& );
00083 
00084 private:
00085   void                      connectSignalsAndSlots();
00086 
00087 private:
00088   int                       myDefaultValue; 
00089 
00090   QString                   myCorrectValue;
00091   QString                   myTextValue;
00092 
00093   bool                      myAcceptNames;
00094   bool                      myShowTip;
00095 };
00096 
00097 #endif