Skip to content

Commit

Permalink
rename constraint to expression for method's name
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed May 31, 2016
1 parent 020d20a commit aba02f1
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions python/core/qgseditformconfig.sip
Expand Up @@ -482,15 +482,15 @@ 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
* @param idx the field index
* @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
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributetypedialog.cpp
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributetypedialog.h
Expand Up @@ -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:
/**
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsfieldsproperties.cpp
Expand Up @@ -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 );
Expand All @@ -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();
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgseditformconfig.cpp
Expand Up @@ -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 = "";

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgseditformconfig.h
Expand Up @@ -518,15 +518,15 @@ 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
* @param idx the field index
* @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
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
Expand Up @@ -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() )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsattributeform.cpp
Expand Up @@ -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() )
{
Expand Down
26 changes: 13 additions & 13 deletions tests/src/gui/testqgsattributeform.cpp
Expand Up @@ -81,7 +81,7 @@ void TestQgsAttributeForm::testFieldConstraint()
QString invalidLabel = "col0<font color=\"red\">*</font>";

// set constraint
layer->editFormConfig()->setConstraint( 0, "" );
layer->editFormConfig()->setExpression( 0, "" );

// get wrapper
QgsEditorWidgetWrapper *ww;
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );

Expand Down

0 comments on commit aba02f1

Please sign in to comment.