QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
23 QgsFieldDomain::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 //
36 bool QgsCodedValue::operator==( const QgsCodedValue &other ) const
37 {
38  return other.mCode == mCode && other.mValue == mValue;
39 }
40 
41 bool QgsCodedValue::operator!=( const QgsCodedValue &other ) const
42 {
43  return !( *this == other );
44 }
45 
46 //
47 // QgsCodedFieldDomain
48 //
49 
50 QgsCodedFieldDomain::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 
58 {
60 }
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 
79 QgsRangeFieldDomain::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 
90 {
92 }
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 
112 QgsGlobFieldDomain::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 
120 {
122 }
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 }
QgsRangeFieldDomain::QgsRangeFieldDomain
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.
Definition: qgsfielddomain.cpp:79
Qgis::FieldDomainType::Glob
@ Glob
Glob string pattern field domain.
QgsRangeFieldDomain::type
Qgis::FieldDomainType type() const override
Returns the type of field domain.
Definition: qgsfielddomain.cpp:89
Qgis::FieldDomainType
FieldDomainType
Types of field domain.
Definition: qgis.h:1731
QgsGlobFieldDomain::clone
QgsGlobFieldDomain * clone() const override
Clones the field domain.
Definition: qgsfielddomain.cpp:129
QgsCodedFieldDomain
Definition of a coded / enumerated field domain.
Definition: qgsfielddomain.h:225
QgsRangeFieldDomain::typeName
QString typeName() const override
Returns a translated name of the field domain type.
Definition: qgsfielddomain.cpp:94
QgsCodedFieldDomain::typeName
QString typeName() const override
Returns a translated name of the field domain type.
Definition: qgsfielddomain.cpp:62
QgsGlobFieldDomain
Definition of a field domain for field content validated by a glob.
Definition: qgsfielddomain.h:422
QgsRangeFieldDomain::clone
QgsRangeFieldDomain * clone() const override
Clones the field domain.
Definition: qgsfielddomain.cpp:99
QgsFieldDomain::mSplitPolicy
Qgis::FieldDomainSplitPolicy mSplitPolicy
Definition: qgsfielddomain.h:159
qgsfielddomain.h
QgsCodedFieldDomain::QgsCodedFieldDomain
QgsCodedFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType, const QList< QgsCodedValue > &values)
Constructor for QgsCodedFieldDomain, with the associated name, description and fieldType.
Definition: qgsfielddomain.cpp:50
QgsFieldDomain::mMergePolicy
Qgis::FieldDomainMergePolicy mMergePolicy
Definition: qgsfielddomain.h:160
QgsCodedValue::operator==
bool operator==(const QgsCodedValue &other) const
Definition: qgsfielddomain.cpp:36
QgsCodedFieldDomain::type
Qgis::FieldDomainType type() const override
Returns the type of field domain.
Definition: qgsfielddomain.cpp:57
QgsCodedValue::operator!=
bool operator!=(const QgsCodedValue &other) const
Definition: qgsfielddomain.cpp:41
QgsGlobFieldDomain::QgsGlobFieldDomain
QgsGlobFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType, const QString &glob)
Constructor for QgsGlobFieldDomain, with the specified name, description and fieldType.
Definition: qgsfielddomain.cpp:112
QgsCodedFieldDomain::clone
QgsCodedFieldDomain * clone() const override
Clones the field domain.
Definition: qgsfielddomain.cpp:67
QgsFieldDomain::QgsFieldDomain
QgsFieldDomain(const QString &name, const QString &description, QVariant::Type fieldType)
Constructor for QgsFieldDomain, with the specified name, description and fieldType.
Definition: qgsfielddomain.cpp:23
QgsGlobFieldDomain::type
Qgis::FieldDomainType type() const override
Returns the type of field domain.
Definition: qgsfielddomain.cpp:119
Qgis::FieldDomainType::Range
@ Range
Numeric range field domain (min/max)
QgsRangeFieldDomain
Definition of a numeric field domain with a range of validity for values.
Definition: qgsfielddomain.h:289
QgsFieldDomain
Base class for field domains.
Definition: qgsfielddomain.h:33
QgsFieldDomain::~QgsFieldDomain
virtual ~QgsFieldDomain()
QgsFieldDomain::mName
QString mName
Definition: qgsfielddomain.h:155
QgsFieldDomain::mDescription
QString mDescription
Definition: qgsfielddomain.h:156
Qgis::FieldDomainType::Coded
@ Coded
Coded field domain.
QgsFieldDomain::mFieldType
QVariant::Type mFieldType
Definition: qgsfielddomain.h:158
QgsCodedValue
Associates a code and a value.
Definition: qgsfielddomain.h:170
QgsGlobFieldDomain::typeName
QString typeName() const override
Returns a translated name of the field domain type.
Definition: qgsfielddomain.cpp:124