25QString QgsSetLayerEncodingAlgorithm::name()
const
27 return QStringLiteral(
"setlayerencoding" );
30QString QgsSetLayerEncodingAlgorithm::displayName()
const
32 return QObject::tr(
"Set layer encoding" );
35QStringList QgsSetLayerEncodingAlgorithm::tags()
const
37 return QObject::tr(
"change,alter,attribute,codepage" ).split(
',' );
40QString QgsSetLayerEncodingAlgorithm::group()
const
42 return QObject::tr(
"Vector general" );
45QString QgsSetLayerEncodingAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeneral" );
50QString QgsSetLayerEncodingAlgorithm::shortHelpString()
const
52 return QObject::tr(
"This algorithm sets the encoding used for reading a layer's attributes. No permanent changes "
53 "are made to the layer, rather it affects only how the layer is read during the current session.\n\n"
54 "Changing the encoding is only supported for some vector layer data sources." );
57QString QgsSetLayerEncodingAlgorithm::shortDescription()
const
59 return QObject::tr(
"Sets the encoding used for reading a layer's attributes." );
62QgsSetLayerEncodingAlgorithm *QgsSetLayerEncodingAlgorithm::createInstance()
const
64 return new QgsSetLayerEncodingAlgorithm();
67void QgsSetLayerEncodingAlgorithm::initAlgorithm(
const QVariantMap & )
77 QgsVectorLayer *layer = parameterAsVectorLayer( parameters, QStringLiteral(
"INPUT" ), context );
80 throw QgsProcessingException( QObject::tr(
"Could not load source layer for %1." ).arg( QLatin1String(
"INPUT" ) ) );
82 const QString encoding = parameterAsString( parameters, QStringLiteral(
"ENCODING" ), context );
84 mOutputId = layer->
id();
93 feedback->
pushInfo( QObject::tr(
"Layer's data provider does not support changing the attribute encoding" ) );
103 outputs.insert( QStringLiteral(
"OUTPUT" ), mOutputId );
@ SelectEncoding
Allows user to select encoding.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A vector layer output for processing algorithms.
A string parameter for processing algorithms.
A vector layer (with or without geometry) parameter for processing algorithms.
Base class for vector data providers.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
Represents a vector layer which manages a vector based dataset.
void setProviderEncoding(const QString &encoding)
Sets the text encoding of the data provider.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.