]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/QY2CharValidator.h
disabling the style for now as the theming causes terrible
[duncan/yast2-qt4.git] / src / QY2CharValidator.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                          contributed Qt objects                      |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       QY2CharValidator.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   This is a pure Qt object - it can be used independently of YaST2.
18
19 /-*/
20
21
22 #ifndef QY2CharValidator_h
23 #define QY2CharValidator_h
24
25 #include <qvalidator.h>
26
27
28 class QY2CharValidator : public QValidator
29 {
30     Q_OBJECT
31
32 public:
33
34     /**
35      * Constructor.
36      *
37      * Create a validator object that checks for input characters being any one
38      * of 'validChars'. If this is empty, any input is accepted.
39      **/
40     QY2CharValidator( const QString &   initialValidChars,
41                       QObject *         parent  = 0,
42                       const char *      name    = 0 );
43
44     /**
45      * Destructor.
46      **/
47     ~QY2CharValidator();
48
49     /**
50      * Check user input.
51      *
52      * Reimplemented from @ref QValidator.
53      **/
54     virtual State validate( QString & input, int & pos ) const;
55
56     /**
57      * Set the valid input characters.
58      * If 'newValidChars' is empty, any input is accepted.
59      **/
60     void setValidChars( const QString & newValidChars )
61         { _validChars = newValidChars; }
62
63     /**
64      * Retrieve the valid input characters.
65      **/
66     QString validChars() const { return _validChars; }
67
68 protected:
69
70     QString _validChars;
71 };
72
73 #endif // QY2CharValidator_h