Skip to content

Commit 05b1e83

Browse files
committed
update container visibilty on mode change
1 parent 4da6e69 commit 05b1e83

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/gui/qgsattributeform.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ QgsAttributeForm::QgsAttributeForm( QgsVectorLayer *vl, const QgsFeature &featur
7777
connect( vl, &QgsVectorLayer::beforeAddingExpressionField, this, &QgsAttributeForm::preventFeatureRefresh );
7878
connect( vl, &QgsVectorLayer::beforeRemovingExpressionField, this, &QgsAttributeForm::preventFeatureRefresh );
7979
connect( vl, &QgsVectorLayer::selectionChanged, this, &QgsAttributeForm::layerSelectionChanged );
80+
connect( this, &QgsAttributeForm::modeChanged, this, &QgsAttributeForm::updateContainersVisibility );
8081

81-
// constraints management
82-
updateAllConstraints();
82+
updateContainersVisibility();
8383
}
8484

8585
QgsAttributeForm::~QgsAttributeForm()
@@ -823,6 +823,7 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
823823
synchronizeEnabledState();
824824

825825
mExpressionContext.setFeature( ft );
826+
826827
mExpressionContext << QgsExpressionContextUtils::formScope( ft, modeString( mMode ) );
827828

828829
// Recheck visibility for all containers which are controlled by this value
@@ -834,6 +835,22 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
834835
}
835836
}
836837

838+
void QgsAttributeForm::updateContainersVisibility()
839+
{
840+
841+
mExpressionContext << QgsExpressionContextUtils::formScope( QgsFeature( mFeature ), modeString( mMode ) );
842+
843+
const QVector<ContainerInformation *> infos = mContainerVisibilityInformation;
844+
845+
for ( ContainerInformation *info : infos )
846+
{
847+
info->apply( &mExpressionContext );
848+
}
849+
850+
//and update the constraints
851+
updateAllConstraints();
852+
}
853+
837854
void QgsAttributeForm::updateConstraint( const QgsFeature &ft, QgsEditorWidgetWrapper *eww )
838855
{
839856
QgsFieldConstraints::ConstraintOrigin constraintOrigin = mLayer->isEditable() ? QgsFieldConstraints::ConstraintOriginNotSet : QgsFieldConstraints::ConstraintOriginLayer;

src/gui/qgsattributeform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
364364
//! constraints management
365365
void updateAllConstraints();
366366
void updateConstraints( QgsEditorWidgetWrapper *w );
367+
void updateContainersVisibility();
367368
void updateConstraint( const QgsFeature &ft, QgsEditorWidgetWrapper *eww );
368369
bool currentFormFeature( QgsFeature &feature );
369370
bool currentFormValidConstraints( QStringList &invalidFields, QStringList &descriptions );

0 commit comments

Comments
 (0)