update container visibilty on mode change

This commit is contained in:
signedav 2018-09-11 08:16:34 +02:00
parent 4da6e6975a
commit 05b1e83932
2 changed files with 20 additions and 2 deletions

View File

@ -77,9 +77,9 @@ QgsAttributeForm::QgsAttributeForm( QgsVectorLayer *vl, const QgsFeature &featur
connect( vl, &QgsVectorLayer::beforeAddingExpressionField, this, &QgsAttributeForm::preventFeatureRefresh );
connect( vl, &QgsVectorLayer::beforeRemovingExpressionField, this, &QgsAttributeForm::preventFeatureRefresh );
connect( vl, &QgsVectorLayer::selectionChanged, this, &QgsAttributeForm::layerSelectionChanged );
connect( this, &QgsAttributeForm::modeChanged, this, &QgsAttributeForm::updateContainersVisibility );
// constraints management
updateAllConstraints();
updateContainersVisibility();
}
QgsAttributeForm::~QgsAttributeForm()
@ -823,6 +823,7 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
synchronizeEnabledState();
mExpressionContext.setFeature( ft );
mExpressionContext << QgsExpressionContextUtils::formScope( ft, modeString( mMode ) );
// Recheck visibility for all containers which are controlled by this value
@ -834,6 +835,22 @@ void QgsAttributeForm::updateConstraints( QgsEditorWidgetWrapper *eww )
}
}
void QgsAttributeForm::updateContainersVisibility()
{
mExpressionContext << QgsExpressionContextUtils::formScope( QgsFeature( mFeature ), modeString( mMode ) );
const QVector<ContainerInformation *> infos = mContainerVisibilityInformation;
for ( ContainerInformation *info : infos )
{
info->apply( &mExpressionContext );
}
//and update the constraints
updateAllConstraints();
}
void QgsAttributeForm::updateConstraint( const QgsFeature &ft, QgsEditorWidgetWrapper *eww )
{
QgsFieldConstraints::ConstraintOrigin constraintOrigin = mLayer->isEditable() ? QgsFieldConstraints::ConstraintOriginNotSet : QgsFieldConstraints::ConstraintOriginLayer;

View File

@ -364,6 +364,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
//! constraints management
void updateAllConstraints();
void updateConstraints( QgsEditorWidgetWrapper *w );
void updateContainersVisibility();
void updateConstraint( const QgsFeature &ft, QgsEditorWidgetWrapper *eww );
bool currentFormFeature( QgsFeature &feature );
bool currentFormValidConstraints( QStringList &invalidFields, QStringList &descriptions );