1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: QtxValidator.cxx
23 // Author: Alexandre SOLOVYOV
25 #include "QtxValidator.h"
28 \class QtxIntValidator
29 \brief Validator for integer numbers with possibility to fix up the invalid value.
34 \param parent parent object
36 QtxIntValidator::QtxIntValidator( QObject* parent )
37 : QIntValidator( parent )
43 \param bot minimum possible value
44 \param top maximum possible value
45 \param parent parent object
47 QtxIntValidator::QtxIntValidator( const int bot, const int top, QObject* parent )
48 : QIntValidator( bot, top, parent )
55 QtxIntValidator::~QtxIntValidator()
60 \brief Validate the input and fixup it if necessary.
62 If the string represents integer value less then minimum value, it becomes equal to the minimum.
63 if the string represents integer value more then mazimum value, it becomes equal to the maximum.
64 If the string is not evaluated as integer it becomes equal to \c 0.
66 \param str the string to be validated
68 void QtxIntValidator::fixup( QString& str ) const
71 int i = str.toInt( &ok );
75 str = QString::number( bottom() );
77 str = QString::number( top() );
80 str = QString ( "0" );
84 \class QtxDoubleValidator
85 \brief Validator for double numbers with possibility to fix up the invalid value.
90 \param parent parent object
92 QtxDoubleValidator::QtxDoubleValidator( QObject* parent )
93 : QDoubleValidator( parent )
99 \param bot minimum possible value
100 \param top maximum possible value
101 \param dec precision (number of digits after dot)
102 \param parent parent object
104 QtxDoubleValidator::QtxDoubleValidator( const double bot, const double top,
105 const int dec, QObject* parent )
106 : QDoubleValidator( bot, top, dec, parent )
113 QtxDoubleValidator::~QtxDoubleValidator()
118 \brief Validate the input and fixup it if necessary.
120 If the string represents double value less then minimum value, it becomes equal to the minimum.
121 if the string represents double value more then mazimum value, it becomes equal to the maximum.
122 If the string is not evaluated as double it becomes equal to \c 0.
124 \param str the string to be validated
126 void QtxDoubleValidator::fixup( QString& str ) const
129 double d = str.toDouble( &ok );
133 str = QString::number( bottom() );
134 else if ( d > top() )
135 str = QString::number( top() );
138 str = QString( "0" );