1 // Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
19 #include "QDS_Validator.h"
22 Class: QDS_IntegerValidator
25 QDS_IntegerValidator::QDS_IntegerValidator( QObject* p )
30 QDS_IntegerValidator::QDS_IntegerValidator( const QString& f, QObject* p )
36 QDS_IntegerValidator::~QDS_IntegerValidator()
40 QValidator::State QDS_IntegerValidator::validate( QString& input, int& pos ) const
42 State rgState = Acceptable;
43 State ivState = QIntValidator::validate( input, pos );
44 if ( ivState != Invalid && !myFilter.isEmpty() )
45 rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos );
47 ivState = QMIN( ivState, rgState );
53 Class: QDS_DoubleValidator
56 QDS_DoubleValidator::QDS_DoubleValidator( QObject* p )
57 : QDoubleValidator( p )
61 QDS_DoubleValidator::QDS_DoubleValidator( const QString& f, QObject* p )
62 : QDoubleValidator( p ),
67 QDS_DoubleValidator::~QDS_DoubleValidator()
71 QValidator::State QDS_DoubleValidator::validate( QString& input, int& pos ) const
73 State rgState = Acceptable;
74 State dvState = QDoubleValidator::validate( input, pos );
75 if ( dvState != Invalid && !myFilter.isEmpty() )
76 rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos );
78 dvState = QMIN( dvState, rgState );
84 Class: QDS_StringValidator
87 QDS_StringValidator::QDS_StringValidator( QObject* p )
93 QDS_StringValidator::QDS_StringValidator( const QString& f, QObject* p )
100 QDS_StringValidator::QDS_StringValidator( const QString& ft, const QString& fg, QObject* p )
108 QDS_StringValidator::~QDS_StringValidator()
112 int QDS_StringValidator::length() const
117 void QDS_StringValidator::setLength( const int l )
122 QValidator::State QDS_StringValidator::validate( QString& input, int& pos ) const
124 if ( input.isEmpty() )
127 QString orig = input;
128 if ( myFlags.contains( 'u', false ) )
129 input = input.upper();
130 if ( myFlags.contains( 'l', false ) )
131 input = input.lower();
133 State rgState = Acceptable;
134 State svState = orig == input ? Acceptable : Intermediate;
136 if ( myLen >= 0 && (int)input.length() > myLen )
137 svState = Intermediate;
139 if ( !myFilter.isEmpty() )
140 rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos );
142 svState = QMIN( svState, rgState );