Warning: That file was not part of the compilation database. It may have many parsing errors.

1/*
2 kstringvalidator.h
3
4 Copyright (c) 2001 Marc Mutz <mutz@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; version 2.0
9 of the License.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the Free
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA
20*/
21
22#ifndef KSTRINGVALIDATOR_H
23#define KSTRINGVALIDATOR_H
24
25#include <kdeui_export.h>
26
27#include <QtCore/QStringList>
28#include <QtGui/QValidator>
29
30/**
31 * @short A QValidator to (dis)allow certain strings
32 *
33 * This validator allows you to accept only certain or to accept all
34 * but certain strings.
35 *
36 * When used in rejecting mode, accepts only strings not in the
37 * stringlist. This mode is the default and comes in handy when asking
38 * the user for a name of some listed entity. Set the list of already
39 * used names to prevent the user from entering duplicate names.
40 *
41 * When used in non-rejecting mode, accepts only strings that appear
42 * in the stringlist. Use with care! From a user's point of view this
43 * mode is hard to grasp.
44 *
45 * This validator can also fix strings. In rejecting mode, a number
46 * will be appended to the string until it is Acceptable. E.g. if
47 * "foo" and "foo 1" are in the stringlist, then fixup will change
48 * "foo" to "foo 2", provided "foo 2" isn't in the list of forbidden
49 * strings.
50 *
51 * In accepting mode, when the input starts with an Acceptable
52 * substring, truncates to the longest Acceptable string. When the
53 * input is the start of an Acceptable string, completes to the
54 * shortest Acceptable string.
55 *
56 * NOTE: fixup isn't yet implemented.
57 *
58 * @author Marc Mutz <mutz@kde.org>
59 **/
60class KDEUI_EXPORT KStringListValidator : public QValidator
61{
62 Q_OBJECT
63 Q_PROPERTY( QStringList stringList READ stringList WRITE setStringList )
64 Q_PROPERTY( bool rejecting READ isRejecting WRITE setRejecting )
65 Q_PROPERTY( bool fixupEnabled READ isFixupEnabled WRITE setFixupEnabled )
66
67 public:
68 /**
69 * Creates a new string validator.
70 *
71 * @param list The list of strings to (dis)allow.
72 * @param rejecting Selects the validator's mode
73 * (rejecting: true; accepting: false)
74 * @param fixupEnabled Selects whether to fix strings or not.
75 * @param parent Passed to lower level constructor.
76 *
77 **/
78 explicit KStringListValidator( const QStringList &list = QStringList(),
79 bool rejecting = true, bool fixupEnabled = false,
80 QObject *parent = 0 );
81
82 /**
83 * Destroys the string validator.
84 */
85 ~KStringListValidator();
86
87 /**
88 * Sets whether the string validator is in rejecting mode or not.
89 * If in rejecting mode, the strings from @see stringList are not
90 * allowed to appear in the validation string.
91 */
92 void setRejecting( bool rejecting );
93
94 /**
95 * Returns whether the string validator is in rejecting mode.
96 */
97 bool isRejecting() const;
98
99 /**
100 * Sets the fixup flag. If enabled, wrong input is corrected
101 * automatically.
102 */
103 void setFixupEnabled( bool fixupEnabled );
104
105 /**
106 * Returns whether the fixup flag is set.
107 */
108 bool isFixupEnabled() const;
109
110 /**
111 * Sets the @param list of string which is used as black or
112 * white list, depending on the rejecting mode (@see isRejecting()).
113 */
114 void setStringList( const QStringList & list );
115
116 /**
117 * Returns the string list of the validator.
118 */
119 QStringList stringList() const;
120
121 /**
122 * Reimplemented from @see QValidator.
123 */
124 virtual State validate( QString & input, int & pos ) const;
125
126 /**
127 * Reimplemented from @see QValidator.
128 */
129 virtual void fixup( QString & input ) const;
130
131 private:
132 class Private;
133 Private* const d;
134};
135
136/**
137 * @short A QValidator for mime types.
138 *
139 * This validator allows you to validate mimetype names
140 * (e.g. text/plain, image/jpeg). Note that the validation is only
141 * syntactically. It will e.g. not reject "foo/bar", although that
142 * particular mime type isn't yet registered. It suffices for the name
143 * to adhere to the production
144 *
145 * \code
146 * mime-type := token "/" token ; 'token' is defined in rfc2045
147 * \endcode
148 *
149 * The fixup will simply remove all non-token characters.
150 *
151 * @deprecated
152 * @author Marc Mutz <mutz@kde.org>
153 **/
154class KDEUI_EXPORT_DEPRECATED KMimeTypeValidator : public QValidator
155{
156 Q_OBJECT
157
158 public:
159 /**
160 * Creates a new mime type validator.
161 */
162 explicit KMimeTypeValidator( QObject* parent = 0 );
163
164 /**
165 * Destroys the mime type validator.
166 */
167 ~KMimeTypeValidator();
168
169 /**
170 * Checks for well-formed mimetype. Returns
171 * @li Acceptable iff input ~= /^[:allowed chars:]+\/[:allowed chars:]+$/
172 * @li Intermediate iff input ~= /^[:allowed chars:]*\/?[:allowed chars:]*$/
173 * @li Invalid else
174 */
175 virtual State validate( QString & input, int & pos ) const;
176
177 /**
178 * Removes all characters that are forbidden in mimetypes.
179 */
180 virtual void fixup( QString & input ) const;
181
182 private:
183 class Private;
184 Private* const d;
185};
186
187#endif // KSTRINGVALIDATOR_H
188

Warning: That file was not part of the compilation database. It may have many parsing errors.