QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsfielddomain.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsfielddomain.h
3 ------------------
4 Date : January 2022
5 Copyright : (C) 2022 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsfielddomain.h"
17#include <memory>
18
19//
20// QgsFieldDomain
21//
22
23QgsFieldDomain::QgsFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType )
24 : mName( name )
25 , mDescription( description )
26 , mFieldType( fieldType )
27{
28
29}
30
32
33//
34// QgsCodedValue
35//
36bool QgsCodedValue::operator==( const QgsCodedValue &other ) const
37{
38 return other.mCode == mCode && other.mValue == mValue;
39}
40
41bool QgsCodedValue::operator!=( const QgsCodedValue &other ) const
42{
43 return !( *this == other );
44}
45
46//
47// QgsCodedFieldDomain
48//
49
50QgsCodedFieldDomain::QgsCodedFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType, const QList<QgsCodedValue> &values )
51 : QgsFieldDomain( name, description, fieldType )
52 , mValues( values )
53{
54
55}
56
61
63{
64 return QObject::tr( "Coded Values" );
65}
66
68{
69 std::unique_ptr< QgsCodedFieldDomain > res = std::make_unique< QgsCodedFieldDomain >( mName, mDescription, mFieldType, mValues );
70 res->mSplitPolicy = mSplitPolicy;
71 res->mMergePolicy = mMergePolicy;
72 return res.release();
73}
74
75//
76// QgsRangeFieldDomain
77//
78
79QgsRangeFieldDomain::QgsRangeFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType, const QVariant &minimum, bool minimumIsInclusive, const QVariant &maximum, bool maximumIsInclusive )
80 : QgsFieldDomain( name, description, fieldType )
81 , mMin( minimum )
82 , mMax( maximum )
83 , mMinIsInclusive( minimumIsInclusive )
84 , mMaxIsInclusive( maximumIsInclusive )
85{
86
87}
88
93
95{
96 return QObject::tr( "Range" );
97}
98
100{
101 std::unique_ptr< QgsRangeFieldDomain > res = std::make_unique< QgsRangeFieldDomain >( mName, mDescription, mFieldType, mMin, mMinIsInclusive, mMax, mMaxIsInclusive );
102 res->mSplitPolicy = mSplitPolicy;
103 res->mMergePolicy = mMergePolicy;
104 return res.release();
105}
106
107
108//
109// QgsGlobFieldDomain
110//
111
112QgsGlobFieldDomain::QgsGlobFieldDomain( const QString &name, const QString &description, QVariant::Type fieldType, const QString &glob )
113 : QgsFieldDomain( name, description, fieldType )
114 , mGlob( glob )
115{
116
117}
118
123
125{
126 return QObject::tr( "Glob" );
127}
128
130{
131 std::unique_ptr< QgsGlobFieldDomain > res = std::make_unique< QgsGlobFieldDomain >( mName, mDescription, mFieldType, mGlob );
132 res->mSplitPolicy = mSplitPolicy;
133 res->mMergePolicy = mMergePolicy;
134 return res.release();
135}
FieldDomainType
Types of field domain.
Definition qgis.h:2662
@ Coded
Coded field domain.
@ Range
Numeric range field domain (min/max)
@ Glob
Glob string pattern field domain.
Definition of a coded / enumerated field domain.
QgsCodedFieldDomain * clone() const override
Clones the field domain.
Qgis::FieldDomainType type() const override
Returns the type of field domain.
QgsCodedFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType, const QList< QgsCodedValue > &values)
Constructor for QgsCodedFieldDomain, with the associated name, description and fieldType.
QString typeName() const override
Returns a translated name of the field domain type.
Associates a code and a value.
bool operator==(const QgsCodedValue &other) const
bool operator!=(const QgsCodedValue &other) const
Base class for field domains.
Qgis::FieldDomainSplitPolicy mSplitPolicy
virtual ~QgsFieldDomain()
QgsFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType)
Constructor for QgsFieldDomain, with the specified name, description and fieldType.
Qgis::FieldDomainMergePolicy mMergePolicy
QVariant::Type mFieldType
Definition of a field domain for field content validated by a glob.
QString typeName() const override
Returns a translated name of the field domain type.
QgsGlobFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType, const QString &glob)
Constructor for QgsGlobFieldDomain, with the specified name, description and fieldType.
QgsGlobFieldDomain * clone() const override
Clones the field domain.
Qgis::FieldDomainType type() const override
Returns the type of field domain.
Definition of a numeric field domain with a range of validity for values.
Qgis::FieldDomainType type() const override
Returns the type of field domain.
QgsRangeFieldDomain * clone() const override
Clones the field domain.
QgsRangeFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType, const QVariant &minimum, bool minimumIsInclusive, const QVariant &maximum, bool maximumIsInclusive)
Constructor for QgsRangeFieldDomain, with the specified name, description and fieldType.
QString typeName() const override
Returns a translated name of the field domain type.