QGIS API Documentation  2.17.0-Master (8784312)
qgsfieldvalidator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldvalidator.h - description
3  -------------------
4  begin : March 2011
5  copyright : (C) 2011 by SunilRajKiran-kCube
6  email : [email protected]
7 
8  adapted version of QValidator for QgsField
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #ifndef QGSFIELDVALIDATOR_H
21 #define QGSFIELDVALIDATOR_H
22 
23 #include <QValidator>
24 #include <QVariant>
25 #include <QSettings>
26 #include "qgsfield.h"
27 
31 class GUI_EXPORT QgsFieldValidator : public QValidator
32 {
33  Q_OBJECT
34 
35  public:
36  QgsFieldValidator( QObject *parent, const QgsField &field, const QString& defaultValue, const QString& dateFormat = "yyyy-MM-dd" );
38 
39  virtual State validate( QString &, int & ) const override;
40  virtual void fixup( QString & ) const override;
41 
42  QString dateFormat() const { return mDateFormat; }
43 
44  private:
45  // Disables copy constructing
46  Q_DISABLE_COPY( QgsFieldValidator )
47 
48  QValidator *mValidator;
49  QgsField mField;
50  QString mNullValue;
51  QString mDefaultValue;
52  QString mDateFormat;
53 };
54 
55 #endif // QGSFIELDVALIDATOR_H
virtual void fixup(QString &input) const
QString dateFormat() const
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
virtual State validate(QString &input, int &pos) const =0