- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qvalidator.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    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; } // ### make inline for 5.0
    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