libyui-qt  2.46.13
QY2CharValidator.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: QY2CharValidator.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23  This is a pure Qt object - it can be used independently of YaST2.
24 
25 /-*/
26 
27 
28 #ifndef QY2CharValidator_h
29 #define QY2CharValidator_h
30 
31 #include <qvalidator.h>
32 
33 
34 class QY2CharValidator : public QValidator
35 {
36  Q_OBJECT
37 
38 public:
39 
40  /**
41  * Constructor.
42  *
43  * Create a validator object that checks for input characters being any one
44  * of 'validChars'. If this is empty, any input is accepted.
45  **/
46  QY2CharValidator( const QString & initialValidChars,
47  QObject * parent = 0,
48  const char * name = 0 );
49 
50  /**
51  * Destructor.
52  **/
54 
55  /**
56  * Check user input.
57  *
58  * Reimplemented from @ref QValidator.
59  **/
60  virtual State validate( QString & input, int & pos ) const;
61 
62  /**
63  * Set the valid input characters.
64  * If 'newValidChars' is empty, any input is accepted.
65  **/
66  void setValidChars( const QString & newValidChars )
67  { _validChars = newValidChars; }
68 
69  /**
70  * Retrieve the valid input characters.
71  **/
72  QString validChars() const { return _validChars; }
73 
74 protected:
75 
76  QString _validChars;
77 };
78 
79 #endif // QY2CharValidator_h
QY2CharValidator(const QString &initialValidChars, QObject *parent=0, const char *name=0)
Constructor.
virtual State validate(QString &input, int &pos) const
Check user input.
void setValidChars(const QString &newValidChars)
Set the valid input characters.
QString validChars() const
Retrieve the valid input characters.
~QY2CharValidator()
Destructor.