QGIS API Documentation 3.41.0-Master (d5b93354e9c)
|
Stores information about constraints which may be present on a field. More...
#include <qgsfieldconstraints.h>
Public Types | |
enum | Constraint { ConstraintNotNull = 1 , ConstraintUnique = 1 << 1 , ConstraintExpression = 1 << 2 } |
Constraints which may be present on a field. More... | |
enum | ConstraintOrigin { ConstraintOriginNotSet = 0 , ConstraintOriginProvider , ConstraintOriginLayer } |
Origin of constraints. More... | |
typedef QFlags< Constraint > | Constraints |
enum | ConstraintStrength { ConstraintStrengthNotSet = 0 , ConstraintStrengthHard , ConstraintStrengthSoft } |
Strength of constraints. More... | |
Public Member Functions | |
QgsFieldConstraints () | |
Constructor for QgsFieldConstraints. | |
QString | constraintDescription () const |
Returns the descriptive name for the constraint expression. | |
QString | constraintExpression () const |
Returns the constraint expression for the field, if set. | |
ConstraintOrigin | constraintOrigin (Constraint constraint) const |
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present on this field. | |
Constraints | constraints () const |
Returns any constraints which are present for the field. | |
ConstraintStrength | constraintStrength (Constraint constraint) const |
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not present on this field. | |
QString | domainName () const |
Returns the associated field domain name, for providers which support field domains. | |
bool | operator== (const QgsFieldConstraints &other) const |
void | removeConstraint (Constraint constraint) |
Removes a constraint from the field. | |
void | setConstraint (Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer) |
Sets a constraint on the field. | |
void | setConstraintExpression (const QString &expression, const QString &description=QString()) |
Set the constraint expression for the field. | |
void | setConstraintStrength (Constraint constraint, ConstraintStrength strength) |
Sets the strength of a constraint. | |
void | setDomainName (const QString &domain) |
Sets the associated field domain name, for providers which support field domains. | |
Properties | |
Constraints | constraints |
Stores information about constraints which may be present on a field.
Definition at line 32 of file qgsfieldconstraints.h.
typedef QFlags< Constraint > QgsFieldConstraints::Constraints |
Definition at line 49 of file qgsfieldconstraints.h.
Constraints which may be present on a field.
Enumerator | |
---|---|
ConstraintNotNull | Field may not be null. |
ConstraintUnique | Field must have a unique value. |
ConstraintExpression | Field has an expression constraint set. See constraintExpression(). |
Definition at line 43 of file qgsfieldconstraints.h.
Origin of constraints.
Enumerator | |
---|---|
ConstraintOriginNotSet | Constraint is not set. |
ConstraintOriginProvider | Constraint was set at data provider. |
ConstraintOriginLayer | Constraint was set by layer. |
Definition at line 54 of file qgsfieldconstraints.h.
Strength of constraints.
Definition at line 64 of file qgsfieldconstraints.h.
|
default |
Constructor for QgsFieldConstraints.
|
inline |
Returns the descriptive name for the constraint expression.
Definition at line 134 of file qgsfieldconstraints.h.
QString QgsFieldConstraints::constraintExpression | ( | ) | const |
Returns the constraint expression for the field, if set.
Definition at line 68 of file qgsfieldconstraints.cpp.
QgsFieldConstraints::ConstraintOrigin QgsFieldConstraints::constraintOrigin | ( | QgsFieldConstraints::Constraint | constraint | ) | const |
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present on this field.
Definition at line 20 of file qgsfieldconstraints.cpp.
|
inline |
Returns any constraints which are present for the field.
Definition at line 81 of file qgsfieldconstraints.h.
QgsFieldConstraints::ConstraintStrength QgsFieldConstraints::constraintStrength | ( | QgsFieldConstraints::Constraint | constraint | ) | const |
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not present on this field.
If the strength is not set returns ConstraintStrengthNotSet for anything but ConstraintExpression which returns ConstraintStrengthHard.
Definition at line 28 of file qgsfieldconstraints.cpp.
|
inline |
Returns the associated field domain name, for providers which support field domains.
Definition at line 151 of file qgsfieldconstraints.h.
bool QgsFieldConstraints::operator== | ( | const QgsFieldConstraints & | other | ) | const |
Definition at line 87 of file qgsfieldconstraints.cpp.
|
inline |
Removes a constraint from the field.
Definition at line 118 of file qgsfieldconstraints.h.
void QgsFieldConstraints::setConstraint | ( | QgsFieldConstraints::Constraint | constraint, |
QgsFieldConstraints::ConstraintOrigin | origin = ConstraintOriginLayer |
||
) |
Sets a constraint on the field.
Definition at line 49 of file qgsfieldconstraints.cpp.
void QgsFieldConstraints::setConstraintExpression | ( | const QString & | expression, |
const QString & | description = QString() |
||
) |
Set the constraint expression for the field.
An optional descriptive name for the constraint can also be set. Setting an empty expression will clear any existing expression constraint.
Definition at line 73 of file qgsfieldconstraints.cpp.
void QgsFieldConstraints::setConstraintStrength | ( | QgsFieldConstraints::Constraint | constraint, |
QgsFieldConstraints::ConstraintStrength | strength | ||
) |
Sets the strength of a constraint.
Constraints default to ConstraintStrengthHard unless explicitly changed.
Definition at line 37 of file qgsfieldconstraints.cpp.
|
inline |
Sets the associated field domain name, for providers which support field domains.
Definition at line 159 of file qgsfieldconstraints.h.
|
read |
Definition at line 36 of file qgsfieldconstraints.h.