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, name )
32 , _validChars( initialValidChars )
37 QY2CharValidator::~QY2CharValidator()
44 QY2CharValidator::validate( QString & fieldContents, int & pos ) const
46 if ( validChars().isEmpty() || fieldContents.isEmpty() )
47 return QValidator::Acceptable;
50 // Check the entire field contents.
52 // There might be more than one new character - the user might have copied
53 // some longer text via the X clipboard.
55 for ( int i=0; i < fieldContents.length(); i++ )
57 if ( ! validChars().contains( fieldContents[i] ) )
58 return QValidator::Invalid;
61 return QValidator::Acceptable;
65 #include "QY2CharValidator.moc"