mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
rename constraint to expression for method's name
This commit is contained in:
parent
020d20a968
commit
aba02f11e0
@ -482,7 +482,7 @@ class QgsEditFormConfig : QObject
|
|||||||
* @return the expression
|
* @return the expression
|
||||||
* @note added in QGIS 2.16
|
* @note added in QGIS 2.16
|
||||||
*/
|
*/
|
||||||
QString constraint( int idx ) const;
|
QString expression( int idx ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the constraint expression for a specific field
|
* Set the constraint expression for a specific field
|
||||||
@ -490,7 +490,7 @@ class QgsEditFormConfig : QObject
|
|||||||
* @param str the constraint expression
|
* @param str the constraint expression
|
||||||
* @note added in QGIS 2.16
|
* @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
|
* Returns if the field at fieldidx should be treated as NOT NULL value
|
||||||
|
@ -185,12 +185,12 @@ bool QgsAttributeTypeDialog::notNull() const
|
|||||||
return notNullCheckBox->isChecked();
|
return notNullCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAttributeTypeDialog::setConstraint( const QString &str )
|
void QgsAttributeTypeDialog::setExpression( const QString &str )
|
||||||
{
|
{
|
||||||
constraintExpression->setField( str );
|
constraintExpression->setField( str );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsAttributeTypeDialog::constraint() const
|
QString QgsAttributeTypeDialog::expression() const
|
||||||
{
|
{
|
||||||
return constraintExpression->asExpression();
|
return constraintExpression->asExpression();
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,13 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
|
|||||||
* Getter for the constraint expression
|
* Getter for the constraint expression
|
||||||
* @note added in QGIS 2.16
|
* @note added in QGIS 2.16
|
||||||
*/
|
*/
|
||||||
QString constraint() const;
|
QString expression() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the constraint expression
|
* Setter for the constraint expression
|
||||||
* @note added in QGIS 2.16
|
* @note added in QGIS 2.16
|
||||||
*/
|
*/
|
||||||
void setConstraint( const QString &str );
|
void setExpression( const QString &str );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
/**
|
||||||
|
@ -528,7 +528,7 @@ void QgsFieldsProperties::attributeTypeDialog()
|
|||||||
attributeTypeDialog.setFieldEditable( cfg.mEditable );
|
attributeTypeDialog.setFieldEditable( cfg.mEditable );
|
||||||
attributeTypeDialog.setLabelOnTop( cfg.mLabelOnTop );
|
attributeTypeDialog.setLabelOnTop( cfg.mLabelOnTop );
|
||||||
attributeTypeDialog.setNotNull( cfg.mNotNull );
|
attributeTypeDialog.setNotNull( cfg.mNotNull );
|
||||||
attributeTypeDialog.setConstraint( cfg.mConstraint );
|
attributeTypeDialog.setExpression( cfg.mConstraint );
|
||||||
|
|
||||||
attributeTypeDialog.setWidgetV2Config( cfg.mEditorWidgetV2Config );
|
attributeTypeDialog.setWidgetV2Config( cfg.mEditorWidgetV2Config );
|
||||||
attributeTypeDialog.setWidgetV2Type( cfg.mEditorWidgetV2Type );
|
attributeTypeDialog.setWidgetV2Type( cfg.mEditorWidgetV2Type );
|
||||||
@ -539,7 +539,7 @@ void QgsFieldsProperties::attributeTypeDialog()
|
|||||||
cfg.mEditable = attributeTypeDialog.fieldEditable();
|
cfg.mEditable = attributeTypeDialog.fieldEditable();
|
||||||
cfg.mLabelOnTop = attributeTypeDialog.labelOnTop();
|
cfg.mLabelOnTop = attributeTypeDialog.labelOnTop();
|
||||||
cfg.mNotNull = attributeTypeDialog.notNull();
|
cfg.mNotNull = attributeTypeDialog.notNull();
|
||||||
cfg.mConstraint = attributeTypeDialog.constraint();
|
cfg.mConstraint = attributeTypeDialog.expression();
|
||||||
|
|
||||||
cfg.mEditorWidgetV2Type = attributeTypeDialog.editorWidgetV2Type();
|
cfg.mEditorWidgetV2Type = attributeTypeDialog.editorWidgetV2Type();
|
||||||
cfg.mEditorWidgetV2Config = attributeTypeDialog.editorWidgetV2Config();
|
cfg.mEditorWidgetV2Config = attributeTypeDialog.editorWidgetV2Config();
|
||||||
@ -913,7 +913,7 @@ void QgsFieldsProperties::apply()
|
|||||||
mLayer->editFormConfig()->setReadOnly( i, !cfg.mEditable );
|
mLayer->editFormConfig()->setReadOnly( i, !cfg.mEditable );
|
||||||
mLayer->editFormConfig()->setLabelOnTop( i, cfg.mLabelOnTop );
|
mLayer->editFormConfig()->setLabelOnTop( i, cfg.mLabelOnTop );
|
||||||
mLayer->editFormConfig()->setNotNull( i, cfg.mNotNull );
|
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()->setWidgetType( idx, cfg.mEditorWidgetV2Type );
|
||||||
mLayer->editFormConfig()->setWidgetConfig( idx, cfg.mEditorWidgetV2Config );
|
mLayer->editFormConfig()->setWidgetConfig( idx, cfg.mEditorWidgetV2Config );
|
||||||
@ -993,7 +993,7 @@ QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx )
|
|||||||
&& layer->fields().fieldOrigin( idx ) != QgsFields::OriginExpression;
|
&& layer->fields().fieldOrigin( idx ) != QgsFields::OriginExpression;
|
||||||
mLabelOnTop = layer->editFormConfig()->labelOnTop( idx );
|
mLabelOnTop = layer->editFormConfig()->labelOnTop( idx );
|
||||||
mNotNull = layer->editFormConfig()->notNull( idx );
|
mNotNull = layer->editFormConfig()->notNull( idx );
|
||||||
mConstraint = layer->editFormConfig()->constraint( idx );
|
mConstraint = layer->editFormConfig()->expression( idx );
|
||||||
mEditorWidgetV2Type = layer->editFormConfig()->widgetType( idx );
|
mEditorWidgetV2Type = layer->editFormConfig()->widgetType( idx );
|
||||||
mEditorWidgetV2Config = layer->editFormConfig()->widgetConfig( idx );
|
mEditorWidgetV2Config = layer->editFormConfig()->widgetConfig( idx );
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ bool QgsEditFormConfig::labelOnTop( int idx ) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsEditFormConfig::constraint( int idx ) const
|
QString QgsEditFormConfig::expression( int idx ) const
|
||||||
{
|
{
|
||||||
QString expr = "";
|
QString expr = "";
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ QString QgsEditFormConfig::constraint( int idx ) const
|
|||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsEditFormConfig::setConstraint( int idx, const QString& str )
|
void QgsEditFormConfig::setExpression( int idx, const QString& str )
|
||||||
{
|
{
|
||||||
if ( idx >= 0 && idx < mFields.count() )
|
if ( idx >= 0 && idx < mFields.count() )
|
||||||
mConstraints[ mFields.at( idx ).name()] = str;
|
mConstraints[ mFields.at( idx ).name()] = str;
|
||||||
|
@ -518,7 +518,7 @@ class CORE_EXPORT QgsEditFormConfig : public QObject
|
|||||||
* @return the expression
|
* @return the expression
|
||||||
* @note added in QGIS 2.16
|
* @note added in QGIS 2.16
|
||||||
*/
|
*/
|
||||||
QString constraint( int idx ) const;
|
QString expression( int idx ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the constraint expression for a specific field
|
* Set the constraint expression for a specific field
|
||||||
@ -526,7 +526,7 @@ class CORE_EXPORT QgsEditFormConfig : public QObject
|
|||||||
* @param str the constraint expression
|
* @param str the constraint expression
|
||||||
* @note added in QGIS 2.16
|
* @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
|
* Returns if the field at fieldidx should be treated as NOT NULL value
|
||||||
|
@ -252,7 +252,7 @@ void QgsEditorWidgetRegistry::readMapLayer( QgsMapLayer* mapLayer, const QDomEle
|
|||||||
vectorLayer->editFormConfig()->setReadOnly( idx, ewv2CfgElem.attribute( "fieldEditable", "1" ) != "1" );
|
vectorLayer->editFormConfig()->setReadOnly( idx, ewv2CfgElem.attribute( "fieldEditable", "1" ) != "1" );
|
||||||
vectorLayer->editFormConfig()->setLabelOnTop( idx, ewv2CfgElem.attribute( "labelOnTop", "0" ) == "1" );
|
vectorLayer->editFormConfig()->setLabelOnTop( idx, ewv2CfgElem.attribute( "labelOnTop", "0" ) == "1" );
|
||||||
vectorLayer->editFormConfig()->setNotNull( idx, ewv2CfgElem.attribute( "notNull", "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 );
|
vectorLayer->editFormConfig()->setWidgetConfig( idx, cfg );
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement&
|
|||||||
ewv2CfgElem.setAttribute( "fieldEditable", !vectorLayer->editFormConfig()->readOnly( idx ) );
|
ewv2CfgElem.setAttribute( "fieldEditable", !vectorLayer->editFormConfig()->readOnly( idx ) );
|
||||||
ewv2CfgElem.setAttribute( "labelOnTop", vectorLayer->editFormConfig()->labelOnTop( idx ) );
|
ewv2CfgElem.setAttribute( "labelOnTop", vectorLayer->editFormConfig()->labelOnTop( idx ) );
|
||||||
ewv2CfgElem.setAttribute( "notNull", vectorLayer->editFormConfig()->notNull( 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 );
|
mWidgetFactories[widgetType]->writeConfig( vectorLayer->editFormConfig()->widgetConfig( idx ), ewv2CfgElem, doc, vectorLayer, idx );
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsFeature &ft )
|
|||||||
{
|
{
|
||||||
bool toEmit( false );
|
bool toEmit( false );
|
||||||
QString errStr( "predicate is True" );
|
QString errStr( "predicate is True" );
|
||||||
QString expression = layer()->editFormConfig()->constraint( mFieldIdx );
|
QString expression = layer()->editFormConfig()->expression( mFieldIdx );
|
||||||
QVariant value = ft.attribute( mFieldIdx );
|
QVariant value = ft.attribute( mFieldIdx );
|
||||||
|
|
||||||
if ( ! expression.isEmpty() )
|
if ( ! expression.isEmpty() )
|
||||||
|
@ -930,7 +930,7 @@ void QgsAttributeForm::constraintDependencies( QgsEditorWidgetWrapper *w,
|
|||||||
if ( name != ewwName )
|
if ( name != ewwName )
|
||||||
{
|
{
|
||||||
// get expression and referencedColumns
|
// 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() )
|
Q_FOREACH ( const QString& colName, expr.referencedColumns() )
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ void TestQgsAttributeForm::testFieldConstraint()
|
|||||||
QString invalidLabel = "col0<font color=\"red\">*</font>";
|
QString invalidLabel = "col0<font color=\"red\">*</font>";
|
||||||
|
|
||||||
// set constraint
|
// set constraint
|
||||||
layer->editFormConfig()->setConstraint( 0, "" );
|
layer->editFormConfig()->setExpression( 0, "" );
|
||||||
|
|
||||||
// get wrapper
|
// get wrapper
|
||||||
QgsEditorWidgetWrapper *ww;
|
QgsEditorWidgetWrapper *ww;
|
||||||
@ -92,7 +92,7 @@ void TestQgsAttributeForm::testFieldConstraint()
|
|||||||
QCOMPARE( label->text(), QString( "col0" ) );
|
QCOMPARE( label->text(), QString( "col0" ) );
|
||||||
|
|
||||||
// set a not null constraint
|
// 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
|
// set value to 1
|
||||||
ww->setValue( 1 );
|
ww->setValue( 1 );
|
||||||
@ -126,10 +126,10 @@ void TestQgsAttributeForm::testFieldMultiConstraints()
|
|||||||
ft.setAttribute( "col3", 3 );
|
ft.setAttribute( "col3", 3 );
|
||||||
|
|
||||||
// set constraints for each field
|
// set constraints for each field
|
||||||
layer->editFormConfig()->setConstraint( 0, "" );
|
layer->editFormConfig()->setExpression( 0, "" );
|
||||||
layer->editFormConfig()->setConstraint( 1, "" );
|
layer->editFormConfig()->setExpression( 1, "" );
|
||||||
layer->editFormConfig()->setConstraint( 2, "" );
|
layer->editFormConfig()->setExpression( 2, "" );
|
||||||
layer->editFormConfig()->setConstraint( 3, "" );
|
layer->editFormConfig()->setExpression( 3, "" );
|
||||||
|
|
||||||
// build a form for this feature
|
// build a form for this feature
|
||||||
QgsAttributeForm form( layer );
|
QgsAttributeForm form( layer );
|
||||||
@ -160,10 +160,10 @@ void TestQgsAttributeForm::testFieldMultiConstraints()
|
|||||||
QCOMPARE( label3->text(), QString( "col3" ) );
|
QCOMPARE( label3->text(), QString( "col3" ) );
|
||||||
|
|
||||||
// update constraint
|
// update constraint
|
||||||
layer->editFormConfig()->setConstraint( 0, "col0 < (col1 * col2)" );
|
layer->editFormConfig()->setExpression( 0, "col0 < (col1 * col2)" );
|
||||||
layer->editFormConfig()->setConstraint( 1, "" );
|
layer->editFormConfig()->setExpression( 1, "" );
|
||||||
layer->editFormConfig()->setConstraint( 2, "" );
|
layer->editFormConfig()->setExpression( 2, "" );
|
||||||
layer->editFormConfig()->setConstraint( 3, "col0 = 2" );
|
layer->editFormConfig()->setExpression( 3, "col0 = 2" );
|
||||||
|
|
||||||
// change value
|
// change value
|
||||||
ww0->setValue( 2 ); // update col0
|
ww0->setValue( 2 ); // update col0
|
||||||
@ -212,7 +212,7 @@ void TestQgsAttributeForm::testOKButtonStatus()
|
|||||||
QSignalSpy spy3( layer, SIGNAL( editingStopped() ) );
|
QSignalSpy spy3( layer, SIGNAL( editingStopped() ) );
|
||||||
|
|
||||||
// set constraint
|
// set constraint
|
||||||
layer->editFormConfig()->setConstraint( 0, "" );
|
layer->editFormConfig()->setExpression( 0, "" );
|
||||||
|
|
||||||
// no constraint but layer not editable : OK button disabled
|
// no constraint but layer not editable : OK button disabled
|
||||||
QCOMPARE( layer->isEditable(), false );
|
QCOMPARE( layer->isEditable(), false );
|
||||||
@ -225,12 +225,12 @@ void TestQgsAttributeForm::testOKButtonStatus()
|
|||||||
QCOMPARE( okButton->isEnabled(), true );
|
QCOMPARE( okButton->isEnabled(), true );
|
||||||
|
|
||||||
// invalid constraint and editable layer : OK button disabled
|
// invalid constraint and editable layer : OK button disabled
|
||||||
layer->editFormConfig()->setConstraint( 0, "col0 = 0" );
|
layer->editFormConfig()->setExpression( 0, "col0 = 0" );
|
||||||
ww->setValue( 1 );
|
ww->setValue( 1 );
|
||||||
QCOMPARE( okButton->isEnabled(), false );
|
QCOMPARE( okButton->isEnabled(), false );
|
||||||
|
|
||||||
// valid constraint and editable layer : OK button enabled
|
// valid constraint and editable layer : OK button enabled
|
||||||
layer->editFormConfig()->setConstraint( 0, "col0 = 2" );
|
layer->editFormConfig()->setExpression( 0, "col0 = 2" );
|
||||||
ww->setValue( 2 );
|
ww->setValue( 2 );
|
||||||
QCOMPARE( okButton->isEnabled(), true );
|
QCOMPARE( okButton->isEnabled(), true );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user