Eneboo - Documentación para desarrolladores
src/qt/include/qvalidator.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qvalidator.h   3.3.8   edited Jan 11 14:39 $
00003 **
00004 ** Definition of validator classes
00005 **
00006 ** Created : 970610
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the widgets module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QVALIDATOR_H
00039 #define QVALIDATOR_H
00040 
00041 #ifndef QT_H
00042 #include "qobject.h"
00043 #include "qstring.h" // char*->QString conversion
00044 #include "qregexp.h" // QString->QRegExp conversion
00045 #endif // QT_H
00046 
00047 #ifndef QT_NO_VALIDATOR
00048 
00049 
00050 class Q_EXPORT QValidator : public QObject
00051 {
00052     Q_OBJECT
00053 public:
00054     QValidator( QObject * parent, const char *name = 0 );
00055     ~QValidator();
00056 
00057     enum State { Invalid, Intermediate, Valid=Intermediate, Acceptable };
00058 
00059     virtual State validate( QString &, int & ) const = 0;
00060     virtual void fixup( QString & ) const;
00061 
00062 private:
00063 #if defined(Q_DISABLE_COPY)
00064     QValidator( const QValidator & );
00065     QValidator& operator=( const QValidator & );
00066 #endif
00067 };
00068 
00069 
00070 class Q_EXPORT QIntValidator : public QValidator
00071 {
00072     Q_OBJECT
00073     Q_PROPERTY( int bottom READ bottom WRITE setBottom )
00074     Q_PROPERTY( int top READ top WRITE setTop )
00075 
00076 public:
00077     QIntValidator( QObject * parent, const char *name = 0 );
00078     QIntValidator( int bottom, int top,
00079                    QObject * parent, const char *name = 0 );
00080     ~QIntValidator();
00081 
00082     QValidator::State validate( QString &, int & ) const;
00083 
00084     void setBottom( int );
00085     void setTop( int );
00086     virtual void setRange( int bottom, int top );
00087 
00088     int bottom() const { return b; }
00089     int top() const { return t; }
00090 
00091 private:
00092 #if defined(Q_DISABLE_COPY)
00093     QIntValidator( const QIntValidator & );
00094     QIntValidator& operator=( const QIntValidator & );
00095 #endif
00096 
00097     int b, t;
00098 };
00099 
00100 #ifndef QT_NO_REGEXP
00101 
00102 class Q_EXPORT QDoubleValidator : public QValidator
00103 {
00104     Q_OBJECT
00105     Q_PROPERTY( double bottom READ bottom WRITE setBottom )
00106     Q_PROPERTY( double top READ top WRITE setTop )
00107     Q_PROPERTY( int decimals READ decimals WRITE setDecimals )
00108 
00109 public:
00110     QDoubleValidator( QObject * parent, const char *name = 0 );
00111     QDoubleValidator( double bottom, double top, int decimals,
00112                       QObject * parent, const char *name = 0 );
00113     ~QDoubleValidator();
00114 
00115     QValidator::State validate( QString &, int & ) const;
00116 
00117     virtual void setRange( double bottom, double top, int decimals = 0 );
00118     void setBottom( double );
00119     void setTop( double );
00120     void setDecimals( int );
00121 
00122     double bottom() const { return b; }
00123     double top() const { return t; }
00124     int decimals() const { return d; }
00125 
00126 private:
00127 #if defined(Q_DISABLE_COPY)
00128     QDoubleValidator( const QDoubleValidator & );
00129     QDoubleValidator& operator=( const QDoubleValidator & );
00130 #endif
00131 
00132     double b, t;
00133     int d;
00134 };
00135 
00136 
00137 class Q_EXPORT QRegExpValidator : public QValidator
00138 {
00139     Q_OBJECT
00140     // Q_PROPERTY( QRegExp regExp READ regExp WRITE setRegExp )
00141 
00142 public:
00143     QRegExpValidator( QObject *parent, const char *name = 0 );
00144     QRegExpValidator( const QRegExp& rx, QObject *parent,
00145                       const char *name = 0 );
00146     ~QRegExpValidator();
00147 
00148     virtual QValidator::State validate( QString& input, int& pos ) const;
00149 
00150     void setRegExp( const QRegExp& rx );
00151     const QRegExp& regExp() const { return r; }
00152 
00153 private:
00154 #if defined(Q_DISABLE_COPY)
00155     QRegExpValidator( const QRegExpValidator& );
00156     QRegExpValidator& operator=( const QRegExpValidator& );
00157 #endif
00158 
00159     QRegExp r;
00160 };
00161 #endif // QT_NO_REGEXP
00162 
00163 
00164 #endif // QT_NO_VALIDATOR
00165 
00166 #endif // QVALIDATOR_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'