QGIS API Documentation  2.99.0-Master (a18066b)
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 "qgsfields.h"
27 #include "qgis_gui.h"
28 
32 class GUI_EXPORT QgsFieldValidator : public QValidator
33 {
34  Q_OBJECT
35 
36  public:
37  QgsFieldValidator( QObject *parent, const QgsField &field, const QString& defaultValue, const QString& dateFormat = "yyyy-MM-dd" );
39 
40  virtual State validate( QString &, int & ) const override;
41  virtual void fixup( QString & ) const override;
42 
43  QString dateFormat() const { return mDateFormat; }
44 
45  private:
46  // Disables copy constructing
47  Q_DISABLE_COPY( QgsFieldValidator )
48 
49  QValidator *mValidator = nullptr;
50  QgsField mField;
51  QString mNullValue;
52  QString mDefaultValue;
53  QString mDateFormat;
54 };
55 
56 #endif // QGSFIELDVALIDATOR_H
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:45
QString dateFormat() const