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 const QString name = parameterAsString( parameters, QStringLiteral(
"FIELD_NAME" ), context );
95 const int type = parameterAsInt( parameters, QStringLiteral(
"FIELD_TYPE" ), context );
96 const int length = parameterAsInt( parameters, QStringLiteral(
"FIELD_LENGTH" ), context );
97 const 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
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
Base class for all map layer types.
Contains information about the context in which a processing algorithm is executed.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Base class for providing feedback from a processing algorithm.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
A numeric parameter for processing algorithms.
A string parameter for processing algorithms.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
QList< QgsFeature > QgsFeatureList