Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Add support for setting alias and comment in
"Add field to attributes table" algorithm
  • Loading branch information
nyalldawson committed Apr 21, 2023
1 parent 807ff7b commit f98b9b3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/analysis/processing/qgsalgorithmaddtablefield.cpp
Expand Up @@ -118,6 +118,9 @@ void QgsAddTableFieldAlgorithm::initParameters( const QVariantMap & )
QgsProcessingParameterNumber::Integer, 10, false, 1, 255 ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "FIELD_PRECISION" ), QObject::tr( "Field precision" ),
QgsProcessingParameterNumber::Integer, 0, false, 0, 10 ) );

addParameter( new QgsProcessingParameterString( QStringLiteral( "FIELD_ALIAS" ), QObject::tr( "Field alias" ) ) );
addParameter( new QgsProcessingParameterString( QStringLiteral( "FIELD_COMMENT" ), QObject::tr( "Field comment" ) ) );
}

QgsFields QgsAddTableFieldAlgorithm::outputFields( const QgsFields &inputFields ) const
Expand All @@ -133,10 +136,14 @@ bool QgsAddTableFieldAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
const int type = parameterAsInt( parameters, QStringLiteral( "FIELD_TYPE" ), context );
const int length = parameterAsInt( parameters, QStringLiteral( "FIELD_LENGTH" ), context );
const int precision = parameterAsInt( parameters, QStringLiteral( "FIELD_PRECISION" ), context );
const QString alias = parameterAsString( parameters, QStringLiteral( "FIELD_ALIAS" ), context );
const QString comment = parameterAsString( parameters, QStringLiteral( "FIELD_COMMENT" ), context );

mField.setName( name );
mField.setLength( length );
mField.setPrecision( precision );
mField.setAlias( alias );
mField.setComment( comment );

switch ( type )
{
Expand Down

0 comments on commit f98b9b3

Please sign in to comment.