QGIS API Documentation  2.14.0-Essen
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 
28 
29 class GUI_EXPORT QgsFieldValidator : public QValidator
30 {
31  Q_OBJECT
32 
33  public:
34  QgsFieldValidator( QObject *parent, const QgsField &field, const QString& defaultValue, const QString& dateFormat = "yyyy-MM-dd" );
36 
37  virtual State validate( QString &, int & ) const override;
38  virtual void fixup( QString & ) const override;
39 
40  QString dateFormat() const { return mDateFormat; }
41 
42  private:
43  // Disables copy constructing
44  Q_DISABLE_COPY( QgsFieldValidator )
45 
46  QValidator *mValidator;
47  QgsField mField;
48  QString mNullValue;
49  QString mDefaultValue;
50  QString mDateFormat;
51 };
52 
53 #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