22 QString QgsAddTableFieldAlgorithm::name()
const
24 return QStringLiteral(
"addfieldtoattributestable" );
27 QString QgsAddTableFieldAlgorithm::displayName()
const
29 return QObject::tr(
"Add field to attributes table" );
32 QString QgsAddTableFieldAlgorithm::shortHelpString()
const
34 return QObject::tr(
"This algorithm adds a new attribute to a vector layer.\n\n"
35 "The name and characteristics of the attribute are defined as parameters. The new attribute "
36 "is not added to the input layer but a new layer is generated instead.\n\n" );
39 QStringList QgsAddTableFieldAlgorithm::tags()
const
41 return QObject::tr(
"add,create,new,attribute,fields" ).split(
',' );
44 QString QgsAddTableFieldAlgorithm::group()
const
46 return QObject::tr(
"Vector table" );
49 QString QgsAddTableFieldAlgorithm::groupId()
const
51 return QStringLiteral(
"vectortable" );
54 QString QgsAddTableFieldAlgorithm::outputName()
const
56 return QObject::tr(
"Added" );
59 QList<int> QgsAddTableFieldAlgorithm::inputLayerTypes()
const
69 QgsAddTableFieldAlgorithm *QgsAddTableFieldAlgorithm::createInstance()
const
71 return new QgsAddTableFieldAlgorithm();
74 void QgsAddTableFieldAlgorithm::initParameters(
const QVariantMap & )
78 QStringList() << QObject::tr(
"Integer" ) << QObject::tr(
"Float" ) << QObject::tr(
"String" ),
false, 0 ) );
85 QgsFields QgsAddTableFieldAlgorithm::outputFields(
const QgsFields &inputFields )
const
94 QString name = parameterAsString( parameters, QStringLiteral(
"FIELD_NAME" ), context );
95 int type = parameterAsInt( parameters, QStringLiteral(
"FIELD_TYPE" ), context );
96 int length = parameterAsInt( parameters, QStringLiteral(
"FIELD_LENGTH" ), context );
97 int precision = parameterAsInt( parameters, QStringLiteral(
"FIELD_PRECISION" ), context );
99 mField.setName( name );
100 mField.setLength( length );
106 mField.setType( QVariant::Int );
109 mField.setType( QVariant::Double );
112 mField.setType( QVariant::String );
123 attributes.append( QVariant() );
128 bool QgsAddTableFieldAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const