diff --git a/python/core/qgseditformconfig.sip b/python/core/qgseditformconfig.sip index f776fd62d92..ee8e13674db 100644 --- a/python/core/qgseditformconfig.sip +++ b/python/core/qgseditformconfig.sip @@ -482,7 +482,7 @@ class QgsEditFormConfig : QObject * @return the expression * @note added in QGIS 2.16 */ - QString constraint( int idx ) const; + QString expression( int idx ) const; /** * Set the constraint expression for a specific field @@ -490,7 +490,7 @@ class QgsEditFormConfig : QObject * @param str the constraint expression * @note added in QGIS 2.16 */ - void setConstraint( int idx, const QString& str ); + void setExpression( int idx, const QString& str ); /** * Returns if the field at fieldidx should be treated as NOT NULL value diff --git a/src/app/qgsattributetypedialog.cpp b/src/app/qgsattributetypedialog.cpp index 2d7b09d608c..8b8cd2d1370 100644 --- a/src/app/qgsattributetypedialog.cpp +++ b/src/app/qgsattributetypedialog.cpp @@ -185,12 +185,12 @@ bool QgsAttributeTypeDialog::notNull() const return notNullCheckBox->isChecked(); } -void QgsAttributeTypeDialog::setConstraint( const QString &str ) +void QgsAttributeTypeDialog::setExpression( const QString &str ) { constraintExpression->setField( str ); } -QString QgsAttributeTypeDialog::constraint() const +QString QgsAttributeTypeDialog::expression() const { return constraintExpression->asExpression(); } diff --git a/src/app/qgsattributetypedialog.h b/src/app/qgsattributetypedialog.h index b7b3b43ef3a..53c5e88bf1a 100644 --- a/src/app/qgsattributetypedialog.h +++ b/src/app/qgsattributetypedialog.h @@ -98,13 +98,13 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut * Getter for the constraint expression * @note added in QGIS 2.16 */ - QString constraint() const; + QString expression() const; /** * Setter for the constraint expression * @note added in QGIS 2.16 */ - void setConstraint( const QString &str ); + void setExpression( const QString &str ); private slots: /** diff --git a/src/app/qgsfieldsproperties.cpp b/src/app/qgsfieldsproperties.cpp index 92015291070..0b026992ea8 100644 --- a/src/app/qgsfieldsproperties.cpp +++ b/src/app/qgsfieldsproperties.cpp @@ -528,7 +528,7 @@ void QgsFieldsProperties::attributeTypeDialog() attributeTypeDialog.setFieldEditable( cfg.mEditable ); attributeTypeDialog.setLabelOnTop( cfg.mLabelOnTop ); attributeTypeDialog.setNotNull( cfg.mNotNull ); - attributeTypeDialog.setConstraint( cfg.mConstraint ); + attributeTypeDialog.setExpression( cfg.mConstraint ); attributeTypeDialog.setWidgetV2Config( cfg.mEditorWidgetV2Config ); attributeTypeDialog.setWidgetV2Type( cfg.mEditorWidgetV2Type ); @@ -539,7 +539,7 @@ void QgsFieldsProperties::attributeTypeDialog() cfg.mEditable = attributeTypeDialog.fieldEditable(); cfg.mLabelOnTop = attributeTypeDialog.labelOnTop(); cfg.mNotNull = attributeTypeDialog.notNull(); - cfg.mConstraint = attributeTypeDialog.constraint(); + cfg.mConstraint = attributeTypeDialog.expression(); cfg.mEditorWidgetV2Type = attributeTypeDialog.editorWidgetV2Type(); cfg.mEditorWidgetV2Config = attributeTypeDialog.editorWidgetV2Config(); @@ -913,7 +913,7 @@ void QgsFieldsProperties::apply() mLayer->editFormConfig()->setReadOnly( i, !cfg.mEditable ); mLayer->editFormConfig()->setLabelOnTop( i, cfg.mLabelOnTop ); mLayer->editFormConfig()->setNotNull( i, cfg.mNotNull ); - mLayer->editFormConfig()->setConstraint( i, cfg.mConstraint ); + mLayer->editFormConfig()->setExpression( i, cfg.mConstraint ); mLayer->editFormConfig()->setWidgetType( idx, cfg.mEditorWidgetV2Type ); mLayer->editFormConfig()->setWidgetConfig( idx, cfg.mEditorWidgetV2Config ); @@ -993,7 +993,7 @@ QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx ) && layer->fields().fieldOrigin( idx ) != QgsFields::OriginExpression; mLabelOnTop = layer->editFormConfig()->labelOnTop( idx ); mNotNull = layer->editFormConfig()->notNull( idx ); - mConstraint = layer->editFormConfig()->constraint( idx ); + mConstraint = layer->editFormConfig()->expression( idx ); mEditorWidgetV2Type = layer->editFormConfig()->widgetType( idx ); mEditorWidgetV2Config = layer->editFormConfig()->widgetConfig( idx ); diff --git a/src/core/qgseditformconfig.cpp b/src/core/qgseditformconfig.cpp index 1311624d1b8..8e153e22582 100644 --- a/src/core/qgseditformconfig.cpp +++ b/src/core/qgseditformconfig.cpp @@ -119,7 +119,7 @@ bool QgsEditFormConfig::labelOnTop( int idx ) const return false; } -QString QgsEditFormConfig::constraint( int idx ) const +QString QgsEditFormConfig::expression( int idx ) const { QString expr = ""; @@ -129,7 +129,7 @@ QString QgsEditFormConfig::constraint( int idx ) const return expr; } -void QgsEditFormConfig::setConstraint( int idx, const QString& str ) +void QgsEditFormConfig::setExpression( int idx, const QString& str ) { if ( idx >= 0 && idx < mFields.count() ) mConstraints[ mFields.at( idx ).name()] = str; diff --git a/src/core/qgseditformconfig.h b/src/core/qgseditformconfig.h index 204600fc762..0371314fc03 100644 --- a/src/core/qgseditformconfig.h +++ b/src/core/qgseditformconfig.h @@ -518,7 +518,7 @@ class CORE_EXPORT QgsEditFormConfig : public QObject * @return the expression * @note added in QGIS 2.16 */ - QString constraint( int idx ) const; + QString expression( int idx ) const; /** * Set the constraint expression for a specific field @@ -526,7 +526,7 @@ class CORE_EXPORT QgsEditFormConfig : public QObject * @param str the constraint expression * @note added in QGIS 2.16 */ - void setConstraint( int idx, const QString& str ); + void setExpression( int idx, const QString& str ); /** * Returns if the field at fieldidx should be treated as NOT NULL value diff --git a/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp b/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp index d6d9eef4368..769294dae1d 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp @@ -252,7 +252,7 @@ void QgsEditorWidgetRegistry::readMapLayer( QgsMapLayer* mapLayer, const QDomEle vectorLayer->editFormConfig()->setReadOnly( idx, ewv2CfgElem.attribute( "fieldEditable", "1" ) != "1" ); vectorLayer->editFormConfig()->setLabelOnTop( idx, ewv2CfgElem.attribute( "labelOnTop", "0" ) == "1" ); vectorLayer->editFormConfig()->setNotNull( idx, ewv2CfgElem.attribute( "notNull", "0" ) == "1" ); - vectorLayer->editFormConfig()->setConstraint( idx, ewv2CfgElem.attribute( "constraint", "" ) ); + vectorLayer->editFormConfig()->setExpression( idx, ewv2CfgElem.attribute( "constraint", "" ) ); vectorLayer->editFormConfig()->setWidgetConfig( idx, cfg ); } @@ -311,7 +311,7 @@ void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement& ewv2CfgElem.setAttribute( "fieldEditable", !vectorLayer->editFormConfig()->readOnly( idx ) ); ewv2CfgElem.setAttribute( "labelOnTop", vectorLayer->editFormConfig()->labelOnTop( idx ) ); ewv2CfgElem.setAttribute( "notNull", vectorLayer->editFormConfig()->notNull( idx ) ); - ewv2CfgElem.setAttribute( "constraint", vectorLayer->editFormConfig()->constraint( idx ) ); + ewv2CfgElem.setAttribute( "constraint", vectorLayer->editFormConfig()->expression( idx ) ); mWidgetFactories[widgetType]->writeConfig( vectorLayer->editFormConfig()->widgetConfig( idx ), ewv2CfgElem, doc, vectorLayer, idx ); diff --git a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp index ef9959ad766..c076bf68223 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp @@ -107,7 +107,7 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsFeature &ft ) { bool toEmit( false ); QString errStr( "predicate is True" ); - QString expression = layer()->editFormConfig()->constraint( mFieldIdx ); + QString expression = layer()->editFormConfig()->expression( mFieldIdx ); QVariant value = ft.attribute( mFieldIdx ); if ( ! expression.isEmpty() ) diff --git a/src/gui/qgsattributeform.cpp b/src/gui/qgsattributeform.cpp index 81d38ed6c08..62f73de2430 100644 --- a/src/gui/qgsattributeform.cpp +++ b/src/gui/qgsattributeform.cpp @@ -930,7 +930,7 @@ void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper *w, if ( name != ewwName ) { // get expression and referencedColumns - QgsExpression expr = eww->layer()->editFormConfig()->constraint( eww->fieldIdx() ); + QgsExpression expr = eww->layer()->editFormConfig()->expression( eww->fieldIdx() ); Q_FOREACH ( const QString& colName, expr.referencedColumns() ) { diff --git a/tests/src/gui/testqgsattributeform.cpp b/tests/src/gui/testqgsattributeform.cpp index 07e14669689..4451bed428f 100644 --- a/tests/src/gui/testqgsattributeform.cpp +++ b/tests/src/gui/testqgsattributeform.cpp @@ -81,7 +81,7 @@ void TestQgsAttributeForm::testFieldConstraint() QString invalidLabel = "col0*"; // set constraint - layer->editFormConfig()->setConstraint( 0, "" ); + layer->editFormConfig()->setExpression( 0, "" ); // get wrapper QgsEditorWidgetWrapper *ww; @@ -92,7 +92,7 @@ void TestQgsAttributeForm::testFieldConstraint() QCOMPARE( label->text(), QString( "col0" ) ); // set a not null constraint - layer->editFormConfig()->setConstraint( 0, "col0 is not null" ); + layer->editFormConfig()->setExpression( 0, "col0 is not null" ); // set value to 1 ww->setValue( 1 ); @@ -126,10 +126,10 @@ void TestQgsAttributeForm::testFieldMultiConstraints() ft.setAttribute( "col3", 3 ); // set constraints for each field - layer->editFormConfig()->setConstraint( 0, "" ); - layer->editFormConfig()->setConstraint( 1, "" ); - layer->editFormConfig()->setConstraint( 2, "" ); - layer->editFormConfig()->setConstraint( 3, "" ); + layer->editFormConfig()->setExpression( 0, "" ); + layer->editFormConfig()->setExpression( 1, "" ); + layer->editFormConfig()->setExpression( 2, "" ); + layer->editFormConfig()->setExpression( 3, "" ); // build a form for this feature QgsAttributeForm form( layer ); @@ -160,10 +160,10 @@ void TestQgsAttributeForm::testFieldMultiConstraints() QCOMPARE( label3->text(), QString( "col3" ) ); // update constraint - layer->editFormConfig()->setConstraint( 0, "col0 < (col1 * col2)" ); - layer->editFormConfig()->setConstraint( 1, "" ); - layer->editFormConfig()->setConstraint( 2, "" ); - layer->editFormConfig()->setConstraint( 3, "col0 = 2" ); + layer->editFormConfig()->setExpression( 0, "col0 < (col1 * col2)" ); + layer->editFormConfig()->setExpression( 1, "" ); + layer->editFormConfig()->setExpression( 2, "" ); + layer->editFormConfig()->setExpression( 3, "col0 = 2" ); // change value ww0->setValue( 2 ); // update col0 @@ -212,7 +212,7 @@ void TestQgsAttributeForm::testOKButtonStatus() QSignalSpy spy3( layer, SIGNAL( editingStopped() ) ); // set constraint - layer->editFormConfig()->setConstraint( 0, "" ); + layer->editFormConfig()->setExpression( 0, "" ); // no constraint but layer not editable : OK button disabled QCOMPARE( layer->isEditable(), false ); @@ -225,12 +225,12 @@ void TestQgsAttributeForm::testOKButtonStatus() QCOMPARE( okButton->isEnabled(), true ); // invalid constraint and editable layer : OK button disabled - layer->editFormConfig()->setConstraint( 0, "col0 = 0" ); + layer->editFormConfig()->setExpression( 0, "col0 = 0" ); ww->setValue( 1 ); QCOMPARE( okButton->isEnabled(), false ); // valid constraint and editable layer : OK button enabled - layer->editFormConfig()->setConstraint( 0, "col0 = 2" ); + layer->editFormConfig()->setExpression( 0, "col0 = 2" ); ww->setValue( 2 ); QCOMPARE( okButton->isEnabled(), true );