QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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
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 "qgis_gui.h"
24#include "qgsfields.h"
25
26#include <QSettings>
27#include <QValidator>
28#include <QVariant>
29
35class GUI_EXPORT QgsFieldValidator : public QValidator
36{
37 Q_OBJECT
38
39 public:
40 QgsFieldValidator( QObject *parent, const QgsField &field, const QString &defaultValue, const QString &dateFormat = "yyyy-MM-dd" );
41 ~QgsFieldValidator() override;
42
43 State validate( QString &s SIP_CONSTRAINED SIP_INOUT, int &i SIP_INOUT ) const override;
44 void fixup( QString &s SIP_CONSTRAINED ) const override;
45
46 QString dateFormat() const { return mDateFormat; }
47
48 private:
49 // Disables copy constructing
50 Q_DISABLE_COPY( QgsFieldValidator )
51
52 QValidator *mValidator = nullptr;
53 QgsField mField;
54 QString mNullValue;
55 QString mDefaultValue;
56 QString mDateFormat;
57};
58
59// clazy:excludeall=qstring-allocations
60
61#endif // QGSFIELDVALIDATOR_H
A QValidator for validation against a QgsField's constraints and field type.
State validate(QString &s, int &i) const override
QgsFieldValidator(QObject *parent, const QgsField &field, const QString &defaultValue, const QString &dateFormat="yyyy-MM-dd")
QString dateFormat() const
void fixup(QString &s) const override
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:54
#define SIP_INOUT
Definition qgis_sip.h:79
#define SIP_CONSTRAINED
Definition qgis_sip.h:119