QGIS API Documentation
3.4.15-Madeira (e83d02e274)
|
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... | |
enum | ConstraintStrength { ConstraintStrengthNotSet = 0, ConstraintStrengthHard, ConstraintStrengthSoft } |
Strength of constraints. More... | |
Public Member Functions | |
QgsFieldConstraints () | |
Constructor for QgsFieldConstraints. More... | |
QString | constraintDescription () const |
Returns the descriptive name for the constraint expression. More... | |
QString | constraintExpression () const |
Returns the constraint expression for the field, if set. More... | |
ConstraintOrigin | constraintOrigin (Constraint constraint) const |
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present on this field. More... | |
Constraints | constraints () const |
Returns any constraints which are present for the field. More... | |
ConstraintStrength | constraintStrength (Constraint constraint) const |
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not present on this field. More... | |
bool | operator== (const QgsFieldConstraints &other) const |
void | removeConstraint (Constraint constraint) |
Removes a constraint from the field. More... | |
void | setConstraint (Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer) |
Sets a constraint on the field. More... | |
void | setConstraintExpression (const QString &expression, const QString &description=QString()) |
Set the constraint expression for the field. More... | |
void | setConstraintStrength (Constraint constraint, ConstraintStrength strength) |
Sets the strength of a constraint. More... | |
Properties | |
Constraints | constraints |
Stores information about constraints which may be present on a field.
Definition at line 32 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 133 of file qgsfieldconstraints.h.
QString QgsFieldConstraints::constraintExpression | ( | ) | const |
Returns the constraint expression for the field, if set.
Definition at line 67 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 19 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.
Definition at line 27 of file qgsfieldconstraints.cpp.
bool QgsFieldConstraints::operator== | ( | const QgsFieldConstraints & | other | ) | const |
Definition at line 86 of file qgsfieldconstraints.cpp.
|
inline |
Removes a constraint from the field.
Definition at line 117 of file qgsfieldconstraints.h.
void QgsFieldConstraints::setConstraint | ( | QgsFieldConstraints::Constraint | constraint, |
QgsFieldConstraints::ConstraintOrigin | origin = ConstraintOriginLayer |
||
) |
Sets a constraint on the field.
Definition at line 48 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 72 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 36 of file qgsfieldconstraints.cpp.
|
read |
Definition at line 36 of file qgsfieldconstraints.h.