Skip to content

Commit aba02f1

Browse files
committed
rename constraint to expression for method's name
1 parent 020d20a commit aba02f1

10 files changed

+31
-31
lines changed

python/core/qgseditformconfig.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,15 @@ class QgsEditFormConfig : QObject
482482
* @return the expression
483483
* @note added in QGIS 2.16
484484
*/
485-
QString constraint( int idx ) const;
485+
QString expression( int idx ) const;
486486

487487
/**
488488
* Set the constraint expression for a specific field
489489
* @param idx the field index
490490
* @param str the constraint expression
491491
* @note added in QGIS 2.16
492492
*/
493-
void setConstraint( int idx, const QString& str );
493+
void setExpression( int idx, const QString& str );
494494

495495
/**
496496
* Returns if the field at fieldidx should be treated as NOT NULL value

src/app/qgsattributetypedialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ bool QgsAttributeTypeDialog::notNull() const
185185
return notNullCheckBox->isChecked();
186186
}
187187

188-
void QgsAttributeTypeDialog::setConstraint( const QString &str )
188+
void QgsAttributeTypeDialog::setExpression( const QString &str )
189189
{
190190
constraintExpression->setField( str );
191191
}
192192

193-
QString QgsAttributeTypeDialog::constraint() const
193+
QString QgsAttributeTypeDialog::expression() const
194194
{
195195
return constraintExpression->asExpression();
196196
}

src/app/qgsattributetypedialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
9898
* Getter for the constraint expression
9999
* @note added in QGIS 2.16
100100
*/
101-
QString constraint() const;
101+
QString expression() const;
102102

103103
/**
104104
* Setter for the constraint expression
105105
* @note added in QGIS 2.16
106106
*/
107-
void setConstraint( const QString &str );
107+
void setExpression( const QString &str );
108108

109109
private slots:
110110
/**

src/app/qgsfieldsproperties.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ void QgsFieldsProperties::attributeTypeDialog()
528528
attributeTypeDialog.setFieldEditable( cfg.mEditable );
529529
attributeTypeDialog.setLabelOnTop( cfg.mLabelOnTop );
530530
attributeTypeDialog.setNotNull( cfg.mNotNull );
531-
attributeTypeDialog.setConstraint( cfg.mConstraint );
531+
attributeTypeDialog.setExpression( cfg.mConstraint );
532532

533533
attributeTypeDialog.setWidgetV2Config( cfg.mEditorWidgetV2Config );
534534
attributeTypeDialog.setWidgetV2Type( cfg.mEditorWidgetV2Type );
@@ -539,7 +539,7 @@ void QgsFieldsProperties::attributeTypeDialog()
539539
cfg.mEditable = attributeTypeDialog.fieldEditable();
540540
cfg.mLabelOnTop = attributeTypeDialog.labelOnTop();
541541
cfg.mNotNull = attributeTypeDialog.notNull();
542-
cfg.mConstraint = attributeTypeDialog.constraint();
542+
cfg.mConstraint = attributeTypeDialog.expression();
543543

544544
cfg.mEditorWidgetV2Type = attributeTypeDialog.editorWidgetV2Type();
545545
cfg.mEditorWidgetV2Config = attributeTypeDialog.editorWidgetV2Config();
@@ -913,7 +913,7 @@ void QgsFieldsProperties::apply()
913913
mLayer->editFormConfig()->setReadOnly( i, !cfg.mEditable );
914914
mLayer->editFormConfig()->setLabelOnTop( i, cfg.mLabelOnTop );
915915
mLayer->editFormConfig()->setNotNull( i, cfg.mNotNull );
916-
mLayer->editFormConfig()->setConstraint( i, cfg.mConstraint );
916+
mLayer->editFormConfig()->setExpression( i, cfg.mConstraint );
917917

918918
mLayer->editFormConfig()->setWidgetType( idx, cfg.mEditorWidgetV2Type );
919919
mLayer->editFormConfig()->setWidgetConfig( idx, cfg.mEditorWidgetV2Config );
@@ -993,7 +993,7 @@ QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx )
993993
&& layer->fields().fieldOrigin( idx ) != QgsFields::OriginExpression;
994994
mLabelOnTop = layer->editFormConfig()->labelOnTop( idx );
995995
mNotNull = layer->editFormConfig()->notNull( idx );
996-
mConstraint = layer->editFormConfig()->constraint( idx );
996+
mConstraint = layer->editFormConfig()->expression( idx );
997997
mEditorWidgetV2Type = layer->editFormConfig()->widgetType( idx );
998998
mEditorWidgetV2Config = layer->editFormConfig()->widgetConfig( idx );
999999

src/core/qgseditformconfig.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool QgsEditFormConfig::labelOnTop( int idx ) const
119119
return false;
120120
}
121121

122-
QString QgsEditFormConfig::constraint( int idx ) const
122+
QString QgsEditFormConfig::expression( int idx ) const
123123
{
124124
QString expr = "";
125125

@@ -129,7 +129,7 @@ QString QgsEditFormConfig::constraint( int idx ) const
129129
return expr;
130130
}
131131

132-
void QgsEditFormConfig::setConstraint( int idx, const QString& str )
132+
void QgsEditFormConfig::setExpression( int idx, const QString& str )
133133
{
134134
if ( idx >= 0 && idx < mFields.count() )
135135
mConstraints[ mFields.at( idx ).name()] = str;

src/core/qgseditformconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,15 @@ class CORE_EXPORT QgsEditFormConfig : public QObject
518518
* @return the expression
519519
* @note added in QGIS 2.16
520520
*/
521-
QString constraint( int idx ) const;
521+
QString expression( int idx ) const;
522522

523523
/**
524524
* Set the constraint expression for a specific field
525525
* @param idx the field index
526526
* @param str the constraint expression
527527
* @note added in QGIS 2.16
528528
*/
529-
void setConstraint( int idx, const QString& str );
529+
void setExpression( int idx, const QString& str );
530530

531531
/**
532532
* Returns if the field at fieldidx should be treated as NOT NULL value

src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void QgsEditorWidgetRegistry::readMapLayer( QgsMapLayer* mapLayer, const QDomEle
252252
vectorLayer->editFormConfig()->setReadOnly( idx, ewv2CfgElem.attribute( "fieldEditable", "1" ) != "1" );
253253
vectorLayer->editFormConfig()->setLabelOnTop( idx, ewv2CfgElem.attribute( "labelOnTop", "0" ) == "1" );
254254
vectorLayer->editFormConfig()->setNotNull( idx, ewv2CfgElem.attribute( "notNull", "0" ) == "1" );
255-
vectorLayer->editFormConfig()->setConstraint( idx, ewv2CfgElem.attribute( "constraint", "" ) );
255+
vectorLayer->editFormConfig()->setExpression( idx, ewv2CfgElem.attribute( "constraint", "" ) );
256256

257257
vectorLayer->editFormConfig()->setWidgetConfig( idx, cfg );
258258
}
@@ -311,7 +311,7 @@ void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement&
311311
ewv2CfgElem.setAttribute( "fieldEditable", !vectorLayer->editFormConfig()->readOnly( idx ) );
312312
ewv2CfgElem.setAttribute( "labelOnTop", vectorLayer->editFormConfig()->labelOnTop( idx ) );
313313
ewv2CfgElem.setAttribute( "notNull", vectorLayer->editFormConfig()->notNull( idx ) );
314-
ewv2CfgElem.setAttribute( "constraint", vectorLayer->editFormConfig()->constraint( idx ) );
314+
ewv2CfgElem.setAttribute( "constraint", vectorLayer->editFormConfig()->expression( idx ) );
315315

316316
mWidgetFactories[widgetType]->writeConfig( vectorLayer->editFormConfig()->widgetConfig( idx ), ewv2CfgElem, doc, vectorLayer, idx );
317317

src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsFeature &ft )
107107
{
108108
bool toEmit( false );
109109
QString errStr( "predicate is True" );
110-
QString expression = layer()->editFormConfig()->constraint( mFieldIdx );
110+
QString expression = layer()->editFormConfig()->expression( mFieldIdx );
111111
QVariant value = ft.attribute( mFieldIdx );
112112

113113
if ( ! expression.isEmpty() )

src/gui/qgsattributeform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper *w,
930930
if ( name != ewwName )
931931
{
932932
// get expression and referencedColumns
933-
QgsExpression expr = eww->layer()->editFormConfig()->constraint( eww->fieldIdx() );
933+
QgsExpression expr = eww->layer()->editFormConfig()->expression( eww->fieldIdx() );
934934

935935
Q_FOREACH ( const QString& colName, expr.referencedColumns() )
936936
{

tests/src/gui/testqgsattributeform.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void TestQgsAttributeForm::testFieldConstraint()
8181
QString invalidLabel = "col0<font color=\"red\">*</font>";
8282

8383
// set constraint
84-
layer->editFormConfig()->setConstraint( 0, "" );
84+
layer->editFormConfig()->setExpression( 0, "" );
8585

8686
// get wrapper
8787
QgsEditorWidgetWrapper *ww;
@@ -92,7 +92,7 @@ void TestQgsAttributeForm::testFieldConstraint()
9292
QCOMPARE( label->text(), QString( "col0" ) );
9393

9494
// set a not null constraint
95-
layer->editFormConfig()->setConstraint( 0, "col0 is not null" );
95+
layer->editFormConfig()->setExpression( 0, "col0 is not null" );
9696

9797
// set value to 1
9898
ww->setValue( 1 );
@@ -126,10 +126,10 @@ void TestQgsAttributeForm::testFieldMultiConstraints()
126126
ft.setAttribute( "col3", 3 );
127127

128128
// set constraints for each field
129-
layer->editFormConfig()->setConstraint( 0, "" );
130-
layer->editFormConfig()->setConstraint( 1, "" );
131-
layer->editFormConfig()->setConstraint( 2, "" );
132-
layer->editFormConfig()->setConstraint( 3, "" );
129+
layer->editFormConfig()->setExpression( 0, "" );
130+
layer->editFormConfig()->setExpression( 1, "" );
131+
layer->editFormConfig()->setExpression( 2, "" );
132+
layer->editFormConfig()->setExpression( 3, "" );
133133

134134
// build a form for this feature
135135
QgsAttributeForm form( layer );
@@ -160,10 +160,10 @@ void TestQgsAttributeForm::testFieldMultiConstraints()
160160
QCOMPARE( label3->text(), QString( "col3" ) );
161161

162162
// update constraint
163-
layer->editFormConfig()->setConstraint( 0, "col0 < (col1 * col2)" );
164-
layer->editFormConfig()->setConstraint( 1, "" );
165-
layer->editFormConfig()->setConstraint( 2, "" );
166-
layer->editFormConfig()->setConstraint( 3, "col0 = 2" );
163+
layer->editFormConfig()->setExpression( 0, "col0 < (col1 * col2)" );
164+
layer->editFormConfig()->setExpression( 1, "" );
165+
layer->editFormConfig()->setExpression( 2, "" );
166+
layer->editFormConfig()->setExpression( 3, "col0 = 2" );
167167

168168
// change value
169169
ww0->setValue( 2 ); // update col0
@@ -212,7 +212,7 @@ void TestQgsAttributeForm::testOKButtonStatus()
212212
QSignalSpy spy3( layer, SIGNAL( editingStopped() ) );
213213

214214
// set constraint
215-
layer->editFormConfig()->setConstraint( 0, "" );
215+
layer->editFormConfig()->setExpression( 0, "" );
216216

217217
// no constraint but layer not editable : OK button disabled
218218
QCOMPARE( layer->isEditable(), false );
@@ -225,12 +225,12 @@ void TestQgsAttributeForm::testOKButtonStatus()
225225
QCOMPARE( okButton->isEnabled(), true );
226226

227227
// invalid constraint and editable layer : OK button disabled
228-
layer->editFormConfig()->setConstraint( 0, "col0 = 0" );
228+
layer->editFormConfig()->setExpression( 0, "col0 = 0" );
229229
ww->setValue( 1 );
230230
QCOMPARE( okButton->isEnabled(), false );
231231

232232
// valid constraint and editable layer : OK button enabled
233-
layer->editFormConfig()->setConstraint( 0, "col0 = 2" );
233+
layer->editFormConfig()->setExpression( 0, "col0 = 2" );
234234
ww->setValue( 2 );
235235
QCOMPARE( okButton->isEnabled(), true );
236236

0 commit comments

Comments
 (0)