Skip to content
Permalink
Browse files

[processing] more consistent naming for class members, setters and

getters
  • Loading branch information
alexbruy committed Aug 4, 2017
1 parent aad566e commit 9fe326dee2b899924d387e397289780ff1819318
@@ -1358,17 +1358,17 @@ class QgsProcessingParameterExpression : QgsProcessingParameterDefinition
virtual QStringList dependsOnOtherParameters() const;


QString parentLayerParameter() const;
QString parentLayerParameterName() const;
%Docstring
Returns the name of the parent layer parameter, or an empty string if this is not set.
.. seealso:: setParentLayerParameter()
.. seealso:: setParentLayerParameterName()
:rtype: str
%End

void setParentLayerParameter( const QString &parentLayerParameter );
void setParentLayerParameterName( const QString &parentLayerParameterName );
%Docstring
Sets the name of the parent layer parameter. Use an empty string if this is not required.
.. seealso:: parentLayerParameter()
.. seealso:: parentLayerParameterName()
%End

virtual QVariantMap toVariantMap() const;
@@ -1487,17 +1487,17 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition
virtual QStringList dependsOnOtherParameters() const;


QString parentLayerParameter() const;
QString parentLayerParameterName() const;
%Docstring
Returns the name of the parent layer parameter, or an empty string if this is not set.
.. seealso:: setParentLayerParameter()
.. seealso:: setParentLayerParameterName()
:rtype: str
%End

void setParentLayerParameter( const QString &parentLayerParameter );
void setParentLayerParameterName( const QString &parentLayerParameterName );
%Docstring
Sets the name of the parent layer parameter. Use an empty string if this is not required.
.. seealso:: parentLayerParameter()
.. seealso:: parentLayerParameterName()
%End

DataType dataType() const;
@@ -2006,17 +2006,17 @@ class QgsProcessingParameterBand : QgsProcessingParameterDefinition
virtual QStringList dependsOnOtherParameters() const;


QString parentLayerParameter() const;
QString parentLayerParameterName() const;
%Docstring
Returns the name of the parent layer parameter, or an empty string if this is not set.
.. seealso:: setParentLayerParameter()
.. seealso:: setParentLayerParameterName()
:rtype: str
%End

void setParentLayerParameter( const QString &parentLayerParameter );
void setParentLayerParameterName( const QString &parentLayerParameterName );
%Docstring
Sets the name of the parent layer parameter. Use an empty string if this is not required.
.. seealso:: parentLayerParameter()
.. seealso:: parentLayerParameterName()
%End

virtual QVariantMap toVariantMap() const;
@@ -992,7 +992,7 @@ class ExpressionWidgetWrapper(WidgetWrapper):

def createWidget(self):
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
if self.param.parentLayerParameter():
if self.param.parentLayerParameterName():
widget = QgsFieldExpressionWidget()
else:
widget = QgsExpressionLineEdit()
@@ -1010,7 +1010,7 @@ def createWidget(self):

def postInitialize(self, wrappers):
for wrapper in wrappers:
if wrapper.param.name() == self.param.parentLayerParameter():
if wrapper.param.name() == self.param.parentLayerParameterName():
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.setLayer(wrapper.value())
wrapper.widgetValueHasChanged.connect(self.parentLayerChanged)
@@ -1187,7 +1187,7 @@ def createWidget(self):

def postInitialize(self, wrappers):
for wrapper in wrappers:
if wrapper.param.name() == self.param.parentLayerParameter():
if wrapper.param.name() == self.param.parentLayerParameterName():
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.setLayer(wrapper.value())
wrapper.widgetValueHasChanged.connect(self.parentValueChanged)
@@ -1282,10 +1282,8 @@ def createWidget(self):
return widget

def postInitialize(self, wrappers):
print(self.param)
print(self.param.parentLayerParameter)
for wrapper in wrappers:
if wrapper.param.name() == self.param.parentLayerParameter():
if wrapper.param.name() == self.param.parentLayerParameterName():
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.setLayer(wrapper.value())
wrapper.widgetValueHasChanged.connect(self.parentValueChanged)
@@ -144,7 +144,7 @@ def setupUi(self):
if isinstance(definition, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer)):
self.parentCombo.addItem(definition.description(), definition.name())
if self.param is not None:
if self.param.parentLayerParameter() == definition.name():
if self.param.parentLayerParameterName() == definition.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
@@ -180,7 +180,7 @@ def setupUi(self):
if isinstance(definition, (QgsProcessingParameterRasterLayer)):
self.parentCombo.addItem(definition.description(), definition.name())
if self.param is not None:
if self.param.parentLayerParameter() == definition.name():
if self.param.parentLayerParameterName() == definition.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
@@ -246,7 +246,7 @@ def setupUi(self):
if isinstance(definition, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer)):
self.parentCombo.addItem(definition.description(), definition.name())
if self.param is not None:
if self.param.parentLayerParameter() == definition.name():
if self.param.parentLayerParameterName() == definition.name():
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
@@ -103,8 +103,8 @@ def paintModel(self, model, controls=True):
for input_name in list(model.parameterComponents().keys()):
idx = 0
parameter_def = model.parameterDefinition(input_name)
if hasattr(parameter_def, 'parentLayerParameter') and parameter_def.parentLayerParameter():
parent_name = parameter_def.parentLayerParameter()
if hasattr(parameter_def, 'parentLayerParameterName') and parameter_def.parentLayerParameterName():
parent_name = parameter_def.parentLayerParameterName()
if input_name in self.paramItems and parent_name in self.paramItems:
input_item = self.paramItems[input_name]
parent_item = self.paramItems[parent_name]
@@ -2048,7 +2048,7 @@ QgsProcessingParameterString *QgsProcessingParameterString::fromScriptCode( cons

QgsProcessingParameterExpression::QgsProcessingParameterExpression( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayerParameterName, bool optional )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
, mParentLayerParameter( parentLayerParameterName )
, mParentLayerParameterName( parentLayerParameterName )
{

}
@@ -2066,32 +2066,32 @@ QString QgsProcessingParameterExpression::valueAsPythonString( const QVariant &v
QStringList QgsProcessingParameterExpression::dependsOnOtherParameters() const
{
QStringList depends;
if ( !mParentLayerParameter.isEmpty() )
depends << mParentLayerParameter;
if ( !mParentLayerParameterName.isEmpty() )
depends << mParentLayerParameterName;
return depends;
}

QString QgsProcessingParameterExpression::parentLayerParameter() const
QString QgsProcessingParameterExpression::parentLayerParameterName() const
{
return mParentLayerParameter;
return mParentLayerParameterName;
}

void QgsProcessingParameterExpression::setParentLayerParameter( const QString &parentLayerParameter )
void QgsProcessingParameterExpression::setParentLayerParameterName( const QString &parentLayerParameterName )
{
mParentLayerParameter = parentLayerParameter;
mParentLayerParameterName = parentLayerParameterName;
}

QVariantMap QgsProcessingParameterExpression::toVariantMap() const
{
QVariantMap map = QgsProcessingParameterDefinition::toVariantMap();
map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameter );
map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameterName );
return map;
}

bool QgsProcessingParameterExpression::fromVariantMap( const QVariantMap &map )
{
QgsProcessingParameterDefinition::fromVariantMap( map );
mParentLayerParameter = map.value( QStringLiteral( "parent_layer" ) ).toString();
mParentLayerParameterName = map.value( QStringLiteral( "parent_layer" ) ).toString();
return true;
}

@@ -2188,7 +2188,7 @@ QgsProcessingParameterVectorLayer *QgsProcessingParameterVectorLayer::fromScript

QgsProcessingParameterField::QgsProcessingParameterField( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayerParameterName, DataType type, bool allowMultiple, bool optional )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
, mParentLayerParameter( parentLayerParameterName )
, mParentLayerParameterName( parentLayerParameterName )
, mDataType( type )
, mAllowMultiple( allowMultiple )
{
@@ -2282,7 +2282,7 @@ QString QgsProcessingParameterField::asScriptCode() const
if ( mAllowMultiple )
code += QStringLiteral( "multiple " );

code += mParentLayerParameter + ' ';
code += mParentLayerParameterName + ' ';

code += mDefault.toString();
return code.trimmed();
@@ -2291,19 +2291,19 @@ QString QgsProcessingParameterField::asScriptCode() const
QStringList QgsProcessingParameterField::dependsOnOtherParameters() const
{
QStringList depends;
if ( !mParentLayerParameter.isEmpty() )
depends << mParentLayerParameter;
if ( !mParentLayerParameterName.isEmpty() )
depends << mParentLayerParameterName;
return depends;
}

QString QgsProcessingParameterField::parentLayerParameter() const
QString QgsProcessingParameterField::parentLayerParameterName() const
{
return mParentLayerParameter;
return mParentLayerParameterName;
}

void QgsProcessingParameterField::setParentLayerParameter( const QString &parentLayerParameter )
void QgsProcessingParameterField::setParentLayerParameterName( const QString &parentLayerParameterName )
{
mParentLayerParameter = parentLayerParameter;
mParentLayerParameterName = parentLayerParameterName;
}

QgsProcessingParameterField::DataType QgsProcessingParameterField::dataType() const
@@ -2329,7 +2329,7 @@ void QgsProcessingParameterField::setAllowMultiple( bool allowMultiple )
QVariantMap QgsProcessingParameterField::toVariantMap() const
{
QVariantMap map = QgsProcessingParameterDefinition::toVariantMap();
map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameter );
map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameterName );
map.insert( QStringLiteral( "data_type" ), mDataType );
map.insert( QStringLiteral( "allow_multiple" ), mAllowMultiple );
return map;
@@ -2338,7 +2338,7 @@ QVariantMap QgsProcessingParameterField::toVariantMap() const
bool QgsProcessingParameterField::fromVariantMap( const QVariantMap &map )
{
QgsProcessingParameterDefinition::fromVariantMap( map );
mParentLayerParameter = map.value( QStringLiteral( "parent_layer" ) ).toString();
mParentLayerParameterName = map.value( QStringLiteral( "parent_layer" ) ).toString();
mDataType = static_cast< DataType >( map.value( QStringLiteral( "data_type" ) ).toInt() );
mAllowMultiple = map.value( QStringLiteral( "allow_multiple" ) ).toBool();
return true;
@@ -3152,7 +3152,7 @@ QgsProcessingParameterVectorDestination *QgsProcessingParameterVectorDestination

QgsProcessingParameterBand::QgsProcessingParameterBand( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayerParameterName, bool optional )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
, mParentLayerParameter( parentLayerParameterName )
, mParentLayerParameterName( parentLayerParameterName )
{

}
@@ -3191,7 +3191,7 @@ QString QgsProcessingParameterBand::asScriptCode() const
code += QStringLiteral( "optional " );
code += QStringLiteral( "band " );

code += mParentLayerParameter + ' ';
code += mParentLayerParameterName + ' ';

code += mDefault.toString();
return code.trimmed();
@@ -3200,32 +3200,32 @@ QString QgsProcessingParameterBand::asScriptCode() const
QStringList QgsProcessingParameterBand::dependsOnOtherParameters() const
{
QStringList depends;
if ( !mParentLayerParameter.isEmpty() )
depends << mParentLayerParameter;
if ( !mParentLayerParameterName.isEmpty() )
depends << mParentLayerParameterName;
return depends;
}

QString QgsProcessingParameterBand::parentLayerParameter() const
QString QgsProcessingParameterBand::parentLayerParameterName() const
{
return mParentLayerParameter;
return mParentLayerParameterName;
}

void QgsProcessingParameterBand::setParentLayerParameter( const QString &parentLayerParameter )
void QgsProcessingParameterBand::setParentLayerParameterName( const QString &parentLayerParameterName )
{
mParentLayerParameter = parentLayerParameter;
mParentLayerParameterName = parentLayerParameterName;
}

QVariantMap QgsProcessingParameterBand::toVariantMap() const
{
QVariantMap map = QgsProcessingParameterDefinition::toVariantMap();
map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameter );
map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameterName );
return map;
}

bool QgsProcessingParameterBand::fromVariantMap( const QVariantMap &map )
{
QgsProcessingParameterDefinition::fromVariantMap( map );
mParentLayerParameter = map.value( QStringLiteral( "parent_layer" ) ).toString();
mParentLayerParameterName = map.value( QStringLiteral( "parent_layer" ) ).toString();
return true;
}

0 comments on commit 9fe326d

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