16 #ifndef QGSFIELDCONSTRAINTS_H
17 #define QGSFIELDCONSTRAINTS_H
23 #include "qgis_core.h"
36 Q_PROPERTY( Constraints constraints READ constraints )
45 ConstraintNotNull = 1,
46 ConstraintUnique = 1 << 1,
47 ConstraintExpression = 1 << 2,
49 Q_DECLARE_FLAGS( Constraints, Constraint )
56 ConstraintOriginNotSet = 0,
66 ConstraintStrengthNotSet = 0,
88 ConstraintOrigin constraintOrigin( Constraint constraint )
const;
96 ConstraintStrength constraintStrength( Constraint constraint )
const;
103 void setConstraintStrength( Constraint constraint, ConstraintStrength strength );
110 void setConstraint( Constraint constraint, ConstraintOrigin origin = ConstraintOriginLayer );
125 QString constraintExpression()
const;
142 void setConstraintExpression(
const QString &expression,
const QString &description = QString() );
150 Constraints mConstraints;
153 QHash< Constraint, ConstraintOrigin > mConstraintOrigins;
156 QHash< Constraint, ConstraintStrength > mConstraintStrengths;
159 QString mExpressionConstraint;
162 QString mExpressionConstraintDescription;
Stores information about constraints which may be present on a field.
ConstraintStrength
Strength of constraints.
@ ConstraintStrengthSoft
User is warned if constraint is violated but feature can still be accepted.
@ ConstraintStrengthHard
Constraint must be honored before feature can be accepted.
ConstraintOrigin
Origin of constraints.
@ ConstraintOriginProvider
Constraint was set at data provider.
@ ConstraintOriginLayer
Constraint was set by layer.
Constraint
Constraints which may be present on a field.
Constraints constraints() const
Returns any constraints which are present for the field.
void removeConstraint(Constraint constraint)
Removes a constraint from the field.
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
QgsFieldConstraints()
Constructor for QgsFieldConstraints.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.