1 #include "QDS_Validator.h"
4 Class: QDS_IntegerValidator
7 QDS_IntegerValidator::QDS_IntegerValidator( QObject* p )
12 QDS_IntegerValidator::QDS_IntegerValidator( const QString& f, QObject* p )
18 QDS_IntegerValidator::~QDS_IntegerValidator()
22 QValidator::State QDS_IntegerValidator::validate( QString& input, int& pos ) const
24 State rgState = Acceptable;
25 State ivState = QIntValidator::validate( input, pos );
26 if ( ivState != Invalid && !myFilter.isEmpty() )
27 rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos );
29 ivState = QMIN( ivState, rgState );
35 Class: QDS_DoubleValidator
38 QDS_DoubleValidator::QDS_DoubleValidator( QObject* p )
39 : QDoubleValidator( p )
43 QDS_DoubleValidator::QDS_DoubleValidator( const QString& f, QObject* p )
44 : QDoubleValidator( p ),
49 QDS_DoubleValidator::~QDS_DoubleValidator()
53 QValidator::State QDS_DoubleValidator::validate( QString& input, int& pos ) const
55 State rgState = Acceptable;
56 State dvState = QDoubleValidator::validate( input, pos );
57 if ( dvState != Invalid && !myFilter.isEmpty() )
58 rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos );
60 dvState = QMIN( dvState, rgState );
66 Class: QDS_StringValidator
69 QDS_StringValidator::QDS_StringValidator( QObject* p )
75 QDS_StringValidator::QDS_StringValidator( const QString& f, QObject* p )
82 QDS_StringValidator::QDS_StringValidator( const QString& ft, const QString& fg, QObject* p )
90 QDS_StringValidator::~QDS_StringValidator()
94 int QDS_StringValidator::length() const
99 void QDS_StringValidator::setLength( const int l )
104 QValidator::State QDS_StringValidator::validate( QString& input, int& pos ) const
106 if ( input.isEmpty() )
109 QString orig = input;
110 if ( myFlags.contains( 'u', false ) )
111 input = input.upper();
112 if ( myFlags.contains( 'l', false ) )
113 input = input.lower();
115 State rgState = Acceptable;
116 State svState = orig == input ? Acceptable : Intermediate;
118 if ( myLen >= 0 && (int)input.length() > myLen )
119 svState = Intermediate;
121 if ( !myFilter.isEmpty() )
122 rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos );
124 svState = QMIN( svState, rgState );