28   , mFieldIdx( fieldIdx )
    29   , mValidConstraint( true )
    30   , mIsBlockingCommit( false )
    42   if ( vl && mFieldIdx < vl->fields().count() )
    65     wdg->setEnabled( enabled );
    72   QVariantList newAdditionalFieldValues;
    74   for ( 
const QString &fieldName : constAdditionalFields )
    75     newAdditionalFieldValues << feature.
attribute( fieldName );
    81   isRunningDeprecatedSetValue = 
true;
    82   updateValues( value, QVariantList() );
    83   isRunningDeprecatedSetValue = 
false;
    88   updateValues( value, additionalValues );
   101   if ( !mConstraintResultVisible )
   103     widget()->setStyleSheet( QString() );
   107     switch ( mConstraintResult )
   110         widget()->setStyleSheet( QString() );
   114         widget()->setStyleSheet( QStringLiteral( 
"background-color: #FFE0B2;" ) );
   118         widget()->setStyleSheet( QStringLiteral( 
"background-color: #FFECB3;" ) );
   126   return mFormFeature.
setAttribute( attributeName, attributeValue );
   129 void QgsEditorWidgetWrapper::updateValues( 
const QVariant &
value, 
const QVariantList &additionalValues )
   132   Q_UNUSED( additionalValues );
   135   if ( !isRunningDeprecatedSetValue )
   142   return mConstraintResult;
   147   return mConstraintResultVisible;
   152   if ( mConstraintResultVisible == constraintResultVisible )
   170   QStringList softErrors;
   171   QStringList expressions;
   172   QStringList descriptions;
   173   bool toEmit( 
false );
   174   bool hardConstraintsOk( 
true );
   175   bool softConstraintsOk( 
true );
   182     if ( ! expression.isEmpty() )
   184       expressions << expression;
   191       descriptions << tr( 
"Not NULL" );
   192       if ( !expression.isEmpty() )
   194         expressions << field.
name() + QStringLiteral( 
" IS NOT NULL" );
   198         expressions << QStringLiteral( 
"IS NOT NULL" );
   205       descriptions << tr( 
"Unique" );
   206       if ( !expression.isEmpty() )
   208         expressions << field.
name() + QStringLiteral( 
" IS UNIQUE" );
   212         expressions << QStringLiteral( 
"IS UNIQUE" );
   220     errors << softErrors;
   224     if ( ! expression.isEmpty() )
   226       hardConstraintsOk = 
true;
   227       softConstraintsOk = 
false;
   229       errors << QStringLiteral( 
"Invalid feature" );
   235   mValidConstraint = hardConstraintsOk && softConstraintsOk;
   236   mIsBlockingCommit = !hardConstraintsOk;
   238   mConstraintFailureReason = errors.join( QStringLiteral( 
", " ) );
   242     QString errStr = errors.isEmpty() ? tr( 
"Constraint checks passed" ) : mConstraintFailureReason;
   244     QString description = descriptions.join( QStringLiteral( 
", " ) );
   245     QString expressionDesc;
   246     if ( expressions.size() > 1 )
   247       expressionDesc = 
"( " + expressions.join( QStringLiteral( 
" ) AND ( " ) ) + 
" )";
   248     else if ( !expressions.isEmpty() )
   249       expressionDesc = expressions.at( 0 );
   254     mConstraintResult = result;
   262   return mValidConstraint;
   267   return mIsBlockingCommit;
   273   return mConstraintFailureReason;
   278   if ( !parent ) 
return false;
   279   if ( qobject_cast<const QTableView *>( parent ) ) 
return true;
   280   return isInTable( parent->parentWidget() );
   285   widget()->setToolTip( hintText );
 bool isValid() const
Returns the validity of this feature. 
 
ConstraintOrigin
Origin of constraints. 
 
#define Q_NOWARN_DEPRECATED_PUSH
 
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index. 
 
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
 
static bool validateAttribute(const QgsVectorLayer *layer, const QgsFeature &feature, int attributeIndex, QStringList &errors, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthNotSet, QgsFieldConstraints::ConstraintOrigin origin=QgsFieldConstraints::ConstraintOriginNotSet)
Tests an attribute value to check whether it passes all constraints which are present on the correspo...
 
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1) 
 
QgsFields fields() const FINAL
Returns the list of fields of this layer. 
 
QString constraintDescription() const
Returns the descriptive name for the constraint expression. 
 
virtual QString defaultValueClause(int fieldIndex) const
Returns any default value clauses which are present at the provider for a specified field index...
 
Encapsulate a field in an attribute table or data source. 
 
User is warned if constraint is violated but feature can still be accepted. 
 
#define Q_NOWARN_DEPRECATED_POP
 
QgsFieldConstraints constraints
 
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr. 
 
QString constraintExpression() const
Returns the constraint expression for the field, if set. 
 
Represents a vector layer which manages a vector based data sets. 
 
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name. 
 
Constraint must be honored before feature can be accepted. 
 
Field must have a unique value.