Skip to content
Permalink
Browse files

update container visibilty on mode change

  • Loading branch information
signedav committed Sep 11, 2018
1 parent 4da6e69 commit 05b1e83932ad8eab783b9f53c6bd784e84a46da3
Showing with 20 additions and 2 deletions.
  1. +19 −2 src/gui/qgsattributeform.cpp
  2. +1 −0 src/gui/qgsattributeform.h
@@ -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;
@@ -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 );

0 comments on commit 05b1e83

Please sign in to comment.
You can’t perform that action at this time.