summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/knumvalidator.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kdeui/knumvalidator.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'microkde/kdeui/knumvalidator.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/knumvalidator.h209
1 files changed, 209 insertions, 0 deletions
diff --git a/microkde/kdeui/knumvalidator.h b/microkde/kdeui/knumvalidator.h
new file mode 100644
index 0000000..2f0a937
--- a/dev/null
+++ b/microkde/kdeui/knumvalidator.h
@@ -0,0 +1,209 @@
1/**********************************************************************
2**
3** $Id$
4**
5** Copyright (C) 1999 Glen Parker <glenebob@nwlink.com>
6** Copyright (C) 2002 Marc Mutz <mutz@kde.org>
7**
8** This library is free software; you can redistribute it and/or
9** modify it under the terms of the GNU Library General Public
10** License as published by the Free Software Foundation; either
11** version 2 of the License, or (at your option) any later version.
12**
13** This library is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16** Library General Public License for more details.
17**
18** You should have received a copy of the GNU Library General Public
19** License along with this library; if not, write to the Free
20** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21**
22*****************************************************************************/
23
24#ifndef __KNUMVALIDATOR_H
25#define __KNUMVALIDATOR_H
26
27#include <qvalidator.h>
28
29class QWidget;
30class QString;
31
32/**
33 * @ref QValidator for integers.
34
35 This can be used by @ref QLineEdit or subclass to provide validated
36 text entry. Can be provided with a base value (default is 10), to allow
37 the proper entry of hexadecimal, octal, or any other base numeric data.
38
39 @author Glen Parker <glenebob@nwlink.com>
40 @version 0.0.1
41*/
42class KIntValidator : public QValidator {
43
44 public:
45 /**
46 Constuctor. Also sets the base value.
47 */
48 KIntValidator ( QWidget * parent, int base = 10, const char * name = 0 );
49 /**
50 * Constructor. Also sets the minimum, maximum, and numeric base values.
51 */
52 KIntValidator ( int bottom, int top, QWidget * parent, int base = 10, const char * name = 0 );
53 /**
54 * Destructs the validator.
55 */
56 virtual ~KIntValidator ();
57 /**
58 * Validates the text, and return the result. Does not modify the parameters.
59 */
60 virtual State validate ( QString &, int & ) const;
61 /**
62 * Fixes the text if possible, providing a valid string. The parameter may be modified.
63 */
64 virtual void fixup ( QString & ) const;
65 /**
66 * Sets the minimum and maximum values allowed.
67 */
68 virtual void setRange ( int bottom, int top );
69 /**
70 * Sets the numeric base value.
71 */
72 virtual void setBase ( int base );
73 /**
74 * Returns the current minimum value allowed.
75 */
76 virtual int bottom () const;
77 /**
78 * Returns the current maximum value allowed.
79 */
80 virtual int top () const;
81 /**
82 * Returns the current numeric base.
83 */
84 virtual int base () const;
85
86 private:
87 int _base;
88 int _min;
89 int _max;
90
91};
92
93class KFloatValidatorPrivate;
94
95/**
96 @obsolete Use @ref KDoubleValidator
97
98 @ref QValidator for floating point entry.
99 Extends the QValidator class to properly validate double numeric data.
100 This can be used by @ref QLineEdit or subclass to provide validated
101 text entry.
102
103 @author Glen Parker <glenebob@nwlink.com>
104 @version 0.0.1
105*/
106class KFloatValidator : public QValidator {
107
108 public:
109 /**
110 * Constructor.
111 */
112 KFloatValidator ( QWidget * parent, const char * name = 0 );
113 /**
114 * Constructor. Also sets the minimum and maximum values.
115 */
116 KFloatValidator ( double bottom, double top, QWidget * parent, const char * name = 0 );
117 /**
118 * Constructor. Sets the validator to be locale aware if @p localeAware is true.
119 */
120 KFloatValidator ( double bottom, double top, bool localeAware, QWidget * parent, const char * name = 0 );
121 /**
122 * Destructs the validator.
123 */
124 virtual ~KFloatValidator ();
125 /**
126 * Validates the text, and return the result. Does not modify the parameters.
127 */
128 virtual State validate ( QString &, int & ) const;
129 /**
130 * Fixes the text if possible, providing a valid string. The parameter may be modified.
131 */
132 virtual void fixup ( QString & ) const;
133 /**
134 * Sets the minimum and maximum value allowed.
135 */
136 virtual void setRange ( double bottom, double top );
137 /**
138 * Returns the current minimum value allowed.
139 */
140 virtual double bottom () const;
141 /**
142 * Returns the current maximum value allowed.
143 */
144 virtual double top () const;
145 /**
146 * Sets the validator to be locale aware if @p is true. In this case, the
147 * character KLocale::decimalSymbol() from the global locale is recognized
148 * as decimal separator.
149 */
150 void setAcceptLocalizedNumbers(bool b);
151 /**
152 * Returns true if the validator is locale aware.
153 * @see setAcceptLocalizedNumbers().
154 */
155 bool acceptLocalizedNumbers() const;
156
157 private:
158 double _min;
159 double _max;
160
161 KFloatValidatorPrivate *d;
162};
163
164/**
165 KDoubleValidator extends @ref QDoubleValidator to be
166 locale-aware. That means that - subject to not being disabled -
167 @ref KLocale::decimalPoint(), @ref KLocale::thousandsSeparator()
168 and @ref KLocale::positiveSign() and @ref KLocale::negativeSign()
169 are respected.
170
171 @short A locale-aware @ref QDoubleValidator
172 @author Marc Mutz <mutz@kde.org>
173 @version $Id$
174 @see KIntValidator
175 @since 3.1
176**/
177
178class KDoubleValidator : public QDoubleValidator {
179 Q_OBJECT
180 Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
181public:
182 /** Constuct a locale-aware KDoubleValidator with default range
183 (whatever @ref QDoubleValidator uses for that) and parent @p
184 parent */
185 KDoubleValidator( QObject * parent, const char * name=0 );
186 /** Constuct a locale-aware KDoubleValidator for range [@p bottom,@p
187 top] and a precision of @p decimals decimals after the decimal
188 point. */
189 KDoubleValidator( double bottom, double top, int decimals,
190 QObject * parent, const char * name=0 );
191 /** Destructs the validator.
192 */
193 virtual ~KDoubleValidator();
194
195 /** Overloaded for internal reasons. The API is not affected. */
196 virtual QValidator::State validate( QString & input, int & pos ) const;
197
198 /** @return whether localized numbers are accepted (default: true) */
199 bool acceptLocalizedNumbers() const;
200 /** Sets whether to accept localized numbers (default: true) */
201 void setAcceptLocalizedNumbers( bool accept );
202
203private:
204 typedef QDoubleValidator base;
205 class Private;
206 Private * d;
207};
208
209#endif