QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Properties | List of all members
QgsFieldConstraints Class Reference

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< ConstraintConstraints
 
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
 

Detailed Description

Stores information about constraints which may be present on a field.

Definition at line 32 of file qgsfieldconstraints.h.

Member Typedef Documentation

◆ Constraints

Definition at line 49 of file qgsfieldconstraints.h.

Member Enumeration Documentation

◆ Constraint

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.

◆ ConstraintOrigin

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.

◆ ConstraintStrength

Strength of constraints.

Enumerator
ConstraintStrengthNotSet 

Constraint is not set.

ConstraintStrengthHard 

Constraint must be honored before feature can be accepted.

ConstraintStrengthSoft 

User is warned if constraint is violated but feature can still be accepted.

Definition at line 64 of file qgsfieldconstraints.h.

Constructor & Destructor Documentation

◆ QgsFieldConstraints()

QgsFieldConstraints::QgsFieldConstraints ( )
default

Constructor for QgsFieldConstraints.

Member Function Documentation

◆ constraintDescription()

QString QgsFieldConstraints::constraintDescription ( ) const
inline

Returns the descriptive name for the constraint expression.

See also
constraints()
constraintExpression()
setConstraintExpression()

Definition at line 134 of file qgsfieldconstraints.h.

◆ constraintExpression()

QString QgsFieldConstraints::constraintExpression ( ) const

Returns the constraint expression for the field, if set.

See also
constraints()
constraintDescription()
setConstraintExpression()

Definition at line 68 of file qgsfieldconstraints.cpp.

◆ constraintOrigin()

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.

See also
constraints()

Definition at line 20 of file qgsfieldconstraints.cpp.

◆ constraints()

Constraints QgsFieldConstraints::constraints ( ) const
inline

Returns any constraints which are present for the field.

See also
setConstraint()
constraintOrigin()

Definition at line 81 of file qgsfieldconstraints.h.

◆ constraintStrength()

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.

See also
constraints()
setConstraintStrength()

Definition at line 28 of file qgsfieldconstraints.cpp.

◆ domainName()

QString QgsFieldConstraints::domainName ( ) const
inline

Returns the associated field domain name, for providers which support field domains.

See also
setDomainName()
Since
QGIS 3.26

Definition at line 151 of file qgsfieldconstraints.h.

◆ operator==()

bool QgsFieldConstraints::operator== ( const QgsFieldConstraints other) const

Definition at line 87 of file qgsfieldconstraints.cpp.

◆ removeConstraint()

void QgsFieldConstraints::removeConstraint ( Constraint  constraint)
inline

Removes a constraint from the field.

See also
setConstraint()
constraints()

Definition at line 118 of file qgsfieldconstraints.h.

◆ setConstraint()

void QgsFieldConstraints::setConstraint ( QgsFieldConstraints::Constraint  constraint,
QgsFieldConstraints::ConstraintOrigin  origin = ConstraintOriginLayer 
)

Sets a constraint on the field.

See also
constraints()
removeConstraint()

Definition at line 49 of file qgsfieldconstraints.cpp.

◆ setConstraintExpression()

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.

See also
constraintExpression()
constraintDescription()
constraints()

Definition at line 73 of file qgsfieldconstraints.cpp.

◆ setConstraintStrength()

void QgsFieldConstraints::setConstraintStrength ( QgsFieldConstraints::Constraint  constraint,
QgsFieldConstraints::ConstraintStrength  strength 
)

Sets the strength of a constraint.

Constraints default to ConstraintStrengthHard unless explicitly changed.

See also
constraintStrength()

Definition at line 37 of file qgsfieldconstraints.cpp.

◆ setDomainName()

void QgsFieldConstraints::setDomainName ( const QString &  domain)
inline

Sets the associated field domain name, for providers which support field domains.

See also
domainName()
Since
QGIS 3.26

Definition at line 159 of file qgsfieldconstraints.h.

Property Documentation

◆ constraints

Constraints QgsFieldConstraints::constraints
read

Definition at line 36 of file qgsfieldconstraints.h.


The documentation for this class was generated from the following files: