1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
9 | contributed Qt objects |
11 \----------------------------------------------------------------------/
13 File: QY2CharValidator.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 This is a pure Qt object - it can be used independently of YaST2.
23 #include <qvalidator.h>
24 #include "QY2CharValidator.h"
28 QY2CharValidator::QY2CharValidator( const QString & initialValidChars,
31 : QValidator( parent )
32 , _validChars( initialValidChars )
38 QY2CharValidator::~QY2CharValidator()
45 QY2CharValidator::validate( QString & fieldContents, int & pos ) const
47 if ( validChars().isEmpty() || fieldContents.isEmpty() )
48 return QValidator::Acceptable;
51 // Check the entire field contents.
53 // There might be more than one new character - the user might have copied
54 // some longer text via the X clipboard.
56 for ( int i=0; i < fieldContents.length(); i++ )
58 if ( ! validChars().contains( fieldContents[i] ) )
59 return QValidator::Invalid;
62 return QValidator::Acceptable;
66 #include "QY2CharValidator.moc"