23 #include <QRegExpValidator> 35 , mDefaultValue( defaultValue )
36 , mDateFormat( dateFormat )
38 switch ( mField.
type() )
54 case QVariant::Double:
78 case QVariant::LongLong :
87 mNullValue = settings.
value(
"qgis/nullValue",
"NULL" ).
toString();
99 ( mField.
type() == QVariant::Double
100 || mField.
type() == QVariant::Int
101 || mField.
type() == QVariant::LongLong
102 || mField.
type() == QVariant::Date
109 if ( s == mDefaultValue )
115 QValidator::State result = mValidator->
validate( s, i );
118 else if ( mField.
type() == QVariant::String )
128 if ( s == mNullValue )
134 else if ( mField.
type() == QVariant::Date )
151 mValidator->
fixup( s );
153 else if ( mField.
type() == QVariant::String && mField.
length() > 0 && s.
size() > mField.
length() && s != mDefaultValue )
158 else if ( mField.
type() == QVariant::Date )
virtual State validate(QString &, int &) const override
virtual void fixup(QString &input) const
QgsFieldValidator(QObject *parent, const QgsField &field, const QString &defaultValue, const QString &dateFormat="yyyy-MM-dd")
QDate fromString(const QString &string, Qt::DateFormat format)
virtual void fixup(QString &) const override
Encapsulate a field in an attribute table or data source.
virtual State validate(QString &input, int &pos) const=0
QVariant value(const QString &key, const QVariant &defaultValue) const
QString left(int n) const
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const