23 #include <QRegExpValidator>
33 : QValidator( parent )
35 , mDateFormat( dateFormat )
43 QString re = QString(
"-?\\d{0,%1}" ).arg(
mField.
length() );
44 mValidator =
new QRegExpValidator( QRegExp( re ), parent );
53 case QVariant::Double:
58 mValidator =
new QRegExpValidator( QRegExp( re ), parent );
62 QString re = QString(
"-?\\d{0,%1}" ).arg(
mField.
length() );
63 mValidator =
new QRegExpValidator( QRegExp( re ), parent );
67 QString re = QString(
"-?\\d*(\\.\\d{0,%1})?" ).arg(
mField.
precision() );
68 mValidator =
new QRegExpValidator( QRegExp( re ), parent );
77 case QVariant::LongLong :
86 mNullValue = settings.value(
"qgis/nullValue",
"NULL" ).toString();
111 QValidator::State result =
mValidator->validate( s, i );
132 return QDate::fromString( s,
mDateFormat ).isValid() ? Acceptable : Intermediate;
int precision() const
Gets the precision of the field.
QgsFieldValidator(QObject *parent, const QgsField &field, QString dateFormat="yyyy-MM-dd")
Encapsulate a field in an attribute table or data source.
virtual void fixup(QString &) const
int length() const
Gets the length of the field.
virtual State validate(QString &, int &) const
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.