Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QVALIDATOR_H
00043 #define QVALIDATOR_H
00044
00045 #include <QtCore/qobject.h>
00046 #include <QtCore/qstring.h>
00047 #include <QtCore/qregexp.h>
00048 #include <QtCore/qlocale.h>
00049
00050 QT_BEGIN_HEADER
00051
00052 QT_BEGIN_NAMESPACE
00053
00054 QT_MODULE(Gui)
00055
00056 #ifndef QT_NO_VALIDATOR
00057
00058 class QValidatorPrivate;
00059
00060 class Q_GUI_EXPORT QValidator : public QObject
00061 {
00062 Q_OBJECT
00063 public:
00064 explicit QValidator(QObject * parent = 0);
00065 ~QValidator();
00066
00067 enum State {
00068 Invalid,
00069 Intermediate,
00070 Acceptable
00071
00072 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
00073 , Valid = Intermediate
00074 #endif
00075 };
00076
00077 void setLocale(const QLocale &locale);
00078 QLocale locale() const;
00079
00080 virtual State validate(QString &, int &) const = 0;
00081 virtual void fixup(QString &) const;
00082
00083 #ifdef QT3_SUPPORT
00084 public:
00085 QT3_SUPPORT_CONSTRUCTOR QValidator(QObject * parent, const char *name);
00086 #endif
00087 protected:
00088 QValidator(QObjectPrivate &d, QObject *parent);
00089 QValidator(QValidatorPrivate &d, QObject *parent);
00090
00091 private:
00092 Q_DISABLE_COPY(QValidator)
00093 Q_DECLARE_PRIVATE(QValidator)
00094 };
00095
00096 class Q_GUI_EXPORT QIntValidator : public QValidator
00097 {
00098 Q_OBJECT
00099 Q_PROPERTY(int bottom READ bottom WRITE setBottom)
00100 Q_PROPERTY(int top READ top WRITE setTop)
00101
00102 public:
00103 explicit QIntValidator(QObject * parent = 0);
00104 QIntValidator(int bottom, int top, QObject * parent);
00105 ~QIntValidator();
00106
00107 QValidator::State validate(QString &, int &) const;
00108 void fixup(QString &input) const;
00109
00110 void setBottom(int);
00111 void setTop(int);
00112 virtual void setRange(int bottom, int top);
00113
00114 int bottom() const { return b; }
00115 int top() const { return t; }
00116
00117 #ifdef QT3_SUPPORT
00118 public:
00119 QT3_SUPPORT_CONSTRUCTOR QIntValidator(QObject * parent, const char *name);
00120 QT3_SUPPORT_CONSTRUCTOR QIntValidator(int bottom, int top, QObject * parent, const char *name);
00121 #endif
00122
00123 private:
00124 Q_DISABLE_COPY(QIntValidator)
00125
00126 int b;
00127 int t;
00128 };
00129
00130 #ifndef QT_NO_REGEXP
00131
00132 class QDoubleValidatorPrivate;
00133
00134 class Q_GUI_EXPORT QDoubleValidator : public QValidator
00135 {
00136 Q_OBJECT
00137 Q_PROPERTY(double bottom READ bottom WRITE setBottom)
00138 Q_PROPERTY(double top READ top WRITE setTop)
00139 Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
00140 Q_ENUMS(Notation)
00141 Q_PROPERTY(Notation notation READ notation WRITE setNotation)
00142
00143 public:
00144 explicit QDoubleValidator(QObject * parent = 0);
00145 QDoubleValidator(double bottom, double top, int decimals, QObject * parent);
00146 ~QDoubleValidator();
00147
00148 enum Notation {
00149 StandardNotation,
00150 ScientificNotation
00151 };
00152
00153 QValidator::State validate(QString &, int &) const;
00154
00155 virtual void setRange(double bottom, double top, int decimals = 0);
00156 void setBottom(double);
00157 void setTop(double);
00158 void setDecimals(int);
00159 void setNotation(Notation);
00160
00161 double bottom() const { return b; }
00162 double top() const { return t; }
00163 int decimals() const { return dec; }
00164 Notation notation() const;
00165
00166 #ifdef QT3_SUPPORT
00167 public:
00168 QT3_SUPPORT_CONSTRUCTOR QDoubleValidator(QObject * parent, const char *name);
00169 QT3_SUPPORT_CONSTRUCTOR QDoubleValidator(double bottom, double top, int decimals,
00170 QObject * parent, const char *name);
00171 #endif
00172 private:
00173 Q_DECLARE_PRIVATE(QDoubleValidator)
00174 Q_DISABLE_COPY(QDoubleValidator)
00175
00176 double b;
00177 double t;
00178 int dec;
00179 };
00180
00181
00182 class Q_GUI_EXPORT QRegExpValidator : public QValidator
00183 {
00184 Q_OBJECT
00185 Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
00186
00187 public:
00188 explicit QRegExpValidator(QObject *parent = 0);
00189 QRegExpValidator(const QRegExp& rx, QObject *parent);
00190 ~QRegExpValidator();
00191
00192 virtual QValidator::State validate(QString& input, int& pos) const;
00193
00194 void setRegExp(const QRegExp& rx);
00195 const QRegExp& regExp() const { return r; }
00196
00197 #ifdef QT3_SUPPORT
00198 public:
00199 QT3_SUPPORT_CONSTRUCTOR QRegExpValidator(QObject *parent, const char *name);
00200 QT3_SUPPORT_CONSTRUCTOR QRegExpValidator(const QRegExp& rx, QObject *parent, const char *name);
00201 #endif
00202
00203 private:
00204 Q_DISABLE_COPY(QRegExpValidator)
00205
00206 QRegExp r;
00207 };
00208
00209 #endif // QT_NO_REGEXP
00210
00211 #endif // QT_NO_VALIDATOR
00212
00213 QT_END_NAMESPACE
00214
00215 QT_END_HEADER
00216
00217 #endif // QVALIDATOR_H