Skip to content
Permalink
Browse files

Config interface for apply on update default values

  • Loading branch information
m-kuhn committed Sep 29, 2017
1 parent 8928959 commit cf77ffe85b64ec0d114037b1f5b84d33a610a212
@@ -308,6 +308,16 @@ QgsExpressionContext QgsAttributeTypeDialog::createExpressionContext() const
return context;
}

bool QgsAttributeTypeDialog::applyDefaultValueOnUpdate() const
{
return mApplyDefaultValueOnUpdateCheckBox->isChecked();
}

void QgsAttributeTypeDialog::setApplyDefaultValueOnUpdate(bool applyDefaultValueOnUpdate)
{
mApplyDefaultValueOnUpdateCheckBox->setChecked( applyDefaultValueOnUpdate );
}

QString QgsAttributeTypeDialog::constraintExpression() const
{
return constraintExpressionWidget->asExpression();
@@ -164,8 +164,13 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
*/
void setDefaultValueExpression( const QString &expression );



QgsExpressionContext createExpressionContext() const override;

bool applyDefaultValueOnUpdate() const;
void setApplyDefaultValueOnUpdate(bool applyDefaultValueOnUpdate);

private slots:

/**
@@ -575,6 +575,7 @@ void QgsFieldsProperties::attributeTypeDialog()
attributeTypeDialog.setConstraintExpressionDescription( cfg.mConstraintDescription );
attributeTypeDialog.setConstraintExpressionEnforced( cfg.mConstraintStrength.value( QgsFieldConstraints::ConstraintExpression, QgsFieldConstraints::ConstraintStrengthHard ) == QgsFieldConstraints::ConstraintStrengthHard );
attributeTypeDialog.setDefaultValueExpression( mLayer->defaultValueDefinition( index ).expression() );
attributeTypeDialog.setApplyDefaultValueOnUpdate( mLayer->defaultValueDefinition( index ).applyOnUpdate() );

attributeTypeDialog.setEditorWidgetConfig( cfg.mEditorWidgetConfig );
attributeTypeDialog.setEditorWidgetType( cfg.mEditorWidgetType );
@@ -601,7 +602,7 @@ void QgsFieldsProperties::attributeTypeDialog()

cfg.mConstraintDescription = attributeTypeDialog.constraintExpressionDescription();
cfg.mConstraint = attributeTypeDialog.constraintExpression();
mLayer->setDefaultValueDefinition( index, attributeTypeDialog.defaultValueExpression() );
mLayer->setDefaultValueDefinition( index, QgsDefaultValue( attributeTypeDialog.defaultValueExpression(), attributeTypeDialog.applyDefaultValueOnUpdate() ) );

cfg.mEditorWidgetType = attributeTypeDialog.editorWidgetType();
cfg.mEditorWidgetConfig = attributeTypeDialog.editorWidgetConfig();
@@ -139,10 +139,10 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<item row="3" column="1">
<widget class="QLabel" name="mDefaultPreviewLabel">
<property name="text">
<string>Preview</string>
<string/>
</property>
</widget>
</item>
@@ -153,10 +153,20 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="mDefaultPreviewLabel">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
<string>Preview</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="mApplyDefaultValueOnUpdateCheckBox">
<property name="toolTip">
<string>&lt;p&gt;With this option checked, the default value will not only be used when the feature is first created, but also whenever a feature's attribute or geometry is changed.&lt;/p&gt;&lt;p&gt;This is often useful for a last_modified timestamp or to record the username that last modified the feature.&lt;/p&gt;</string>
</property>
<property name="text">
<string>Apply default value on update</string>
</property>
</widget>
</item>

0 comments on commit cf77ffe

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