code layout, loop improvements, dox, const correction

This commit is contained in:
Denis Rouzaud 2019-12-05 06:09:29 +01:00
parent a4fda0ac01
commit a3a7b5f447
6 changed files with 21 additions and 12 deletions

View File

@ -297,7 +297,7 @@ Get parameter from its id
.. versionadded:: 3.12 .. versionadded:: 3.12
%End %End
const QgsProcessingParameterDefinitions parameterDefinitions() const; QgsProcessingParameterDefinitions parameterDefinitions() const;
%Docstring %Docstring
List of parameters List of parameters
@ -328,9 +328,15 @@ Copy the parameters (shall be used in clone implementation)
Format the number according to label properties Format the number according to label properties
%End %End
void addParameter( QgsProcessingParameterDefinition *definition ); void addParameter( QgsProcessingParameterDefinition *definition /Transfer/ );
%Docstring %Docstring
Add parameter Add a parameter to the method.
The paramaeter is a processing parameter which will allow its configuration in the GUI.
.. note::
Only parameters having their widget implementation in C++ are supported. i.e. pure
Python parameters are not supported.
.. versionadded:: 3.12 .. versionadded:: 3.12
%End %End

View File

@ -22,7 +22,7 @@
QgsClassificationLogarithmic::QgsClassificationLogarithmic() QgsClassificationLogarithmic::QgsClassificationLogarithmic()
: QgsClassificationMethod( NoFlag, 0 ) : QgsClassificationMethod( NoFlag, 0 )
{ {
QgsProcessingParameterBoolean *param = new QgsProcessingParameterBoolean( QStringLiteral( "FILTER_ZERO_NEG_VALUES" ), QObject::tr( "Filter values <= 0" ), false ); QgsProcessingParameterBoolean *param = new QgsProcessingParameterBoolean( QStringLiteral( "FILTER_ZERO_NEG_VALUES" ), QObject::tr( "Filter values 0" ), false );
addParameter( param ); addParameter( param );
} }

View File

@ -188,11 +188,11 @@ const QgsProcessingParameterDefinition *QgsClassificationMethod::parameterDefini
void QgsClassificationMethod::setParameterValues( const QVariantMap &values ) void QgsClassificationMethod::setParameterValues( const QVariantMap &values )
{ {
mParameterValues = values; mParameterValues = values;
for ( const QString &paramName : mParameterValues.keys() ) // todo is this ok? for ( auto it = mParameterValues.begin(); it != mParameterValues.end(); ++it )
{ {
if ( !parameterDefinition( paramName ) ) if ( !parameterDefinition( it.key() ) )
{ {
QgsMessageLog::logMessage( name(), QObject::tr( "Parameter %1 does not exist in the method" ).arg( paramName ) ); QgsMessageLog::logMessage( name(), QObject::tr( "Parameter %1 does not exist in the method" ).arg( it.key() ) );
} }
} }
} }

View File

@ -281,7 +281,7 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
* List of parameters * List of parameters
* \since QGIS 3.12 * \since QGIS 3.12
*/ */
const QgsProcessingParameterDefinitions parameterDefinitions() const {return mParameters;} QgsProcessingParameterDefinitions parameterDefinitions() const {return mParameters;}
/** /**
* Set values of the additional parameters * Set values of the additional parameters
@ -303,10 +303,13 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
QString formatNumber( double value ) const; QString formatNumber( double value ) const;
/** /**
* Add parameter * Add a parameter to the method.
* The paramaeter is a processing parameter which will allow its configuration in the GUI.
* \note Only parameters having their widget implementation in C++ are supported. i.e. pure
* Python parameters are not supported.
* \since QGIS 3.12 * \since QGIS 3.12
*/ */
void addParameter( QgsProcessingParameterDefinition *definition ); void addParameter( QgsProcessingParameterDefinition *definition SIP_TRANSFER );
/** /**
* Get the parameter value * Get the parameter value

View File

@ -832,7 +832,7 @@ void QgsGraduatedSymbolRendererWidget::updateMethodParameters()
// todo need more? // todo need more?
QgsProcessingContext context; QgsProcessingContext context;
for ( const auto *def : method->parameterDefinitions() ) for ( const QgsProcessingParameterDefinition *def : method->parameterDefinitions() )
{ {
QgsAbstractProcessingParameterWidgetWrapper *ppww = QgsGui::processingGuiRegistry()->createParameterWidgetWrapper( def, QgsProcessingGui::Standard ); QgsAbstractProcessingParameterWidgetWrapper *ppww = QgsGui::processingGuiRegistry()->createParameterWidgetWrapper( def, QgsProcessingGui::Standard );
mParametersLayout->addRow( ppww->createWrappedLabel(), ppww->createWrappedWidget( context ) ); mParametersLayout->addRow( ppww->createWrappedLabel(), ppww->createWrappedWidget( context ) );