24QString QgsSetLayerEncodingAlgorithm::name()
const
26 return QStringLiteral(
"setlayerencoding" );
29QString QgsSetLayerEncodingAlgorithm::displayName()
const
31 return QObject::tr(
"Set layer encoding" );
34QStringList QgsSetLayerEncodingAlgorithm::tags()
const
36 return QObject::tr(
"change,alter,attribute,codepage" ).split(
',' );
39QString QgsSetLayerEncodingAlgorithm::group()
const
41 return QObject::tr(
"Vector general" );
44QString QgsSetLayerEncodingAlgorithm::groupId()
const
46 return QStringLiteral(
"vectorgeneral" );
49QString QgsSetLayerEncodingAlgorithm::shortHelpString()
const
51 return QObject::tr(
"This algorithm sets the encoding used for reading a layer's attributes. No permanent changes "
52 "are made to the layer, rather it affects only how the layer is read during the current session.\n\n"
53 "Changing the encoding is only supported for some vector layer data sources." );
56QString QgsSetLayerEncodingAlgorithm::shortDescription()
const
58 return QObject::tr(
"Sets the encoding used for reading a layer's attributes" );
61QgsSetLayerEncodingAlgorithm *QgsSetLayerEncodingAlgorithm::createInstance()
const
63 return new QgsSetLayerEncodingAlgorithm();
66void QgsSetLayerEncodingAlgorithm::initAlgorithm(
const QVariantMap & )
76 QgsVectorLayer *layer = parameterAsVectorLayer( parameters, QStringLiteral(
"INPUT" ), context );
79 throw QgsProcessingException( QObject::tr(
"Could not load source layer for %1." ).arg( QLatin1String(
"INPUT" ) ) );
81 const QString encoding = parameterAsString( parameters, QStringLiteral(
"ENCODING" ), context );
83 mOutputId = layer->
id();
92 feedback->
pushInfo( QObject::tr(
"Layer's data provider does not support changing the attribute encoding" ) );
102 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.
This is the 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 data sets.
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.