25using namespace Qt::StringLiterals;
29QString QgsSetLayerEncodingAlgorithm::name()
const
31 return u
"setlayerencoding"_s;
34QString QgsSetLayerEncodingAlgorithm::displayName()
const
36 return QObject::tr(
"Set layer encoding" );
39QStringList QgsSetLayerEncodingAlgorithm::tags()
const
41 return QObject::tr(
"change,alter,attribute,codepage" ).split(
',' );
44QString QgsSetLayerEncodingAlgorithm::group()
const
46 return QObject::tr(
"Vector general" );
49QString QgsSetLayerEncodingAlgorithm::groupId()
const
51 return u
"vectorgeneral"_s;
54QString QgsSetLayerEncodingAlgorithm::shortHelpString()
const
56 return QObject::tr(
"This algorithm sets the encoding used for reading a layer's attributes. No permanent changes "
57 "are made to the layer, rather it affects only how the layer is read during the current session.\n\n"
58 "Changing the encoding is only supported for some vector layer data sources." );
61QString QgsSetLayerEncodingAlgorithm::shortDescription()
const
63 return QObject::tr(
"Sets the encoding used for reading a layer's attributes." );
66QgsSetLayerEncodingAlgorithm *QgsSetLayerEncodingAlgorithm::createInstance()
const
68 return new QgsSetLayerEncodingAlgorithm();
71void QgsSetLayerEncodingAlgorithm::initAlgorithm(
const QVariantMap & )
81 QgsVectorLayer *layer = parameterAsVectorLayer( parameters, u
"INPUT"_s, context );
86 const QString encoding = parameterAsString( parameters, u
"ENCODING"_s, context );
88 mOutputId = layer->
id();
97 feedback->
pushInfo( QObject::tr(
"Layer's data provider does not support changing the attribute encoding" ) );
107 outputs.insert( u
"OUTPUT"_s, 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.