22using namespace Qt::StringLiterals;
26QString QgsApplyLayerStyleAlgorithm::name()
const
28 return u
"setlayerstyle"_s;
31QString QgsApplyLayerStyleAlgorithm::displayName()
const
33 return QObject::tr(
"Set layer style" );
36QStringList QgsApplyLayerStyleAlgorithm::tags()
const
38 return QObject::tr(
"change,layer,style,qml" ).split(
',' );
41QString QgsApplyLayerStyleAlgorithm::group()
const
43 return QObject::tr(
"Cartography" );
46QString QgsApplyLayerStyleAlgorithm::groupId()
const
48 return u
"cartography"_s;
51QString QgsApplyLayerStyleAlgorithm::shortHelpString()
const
53 return QObject::tr(
"This algorithm applies the style to a layer. The style must be defined as QML file." );
56QString QgsApplyLayerStyleAlgorithm::shortDescription()
const
58 return QObject::tr(
"Applies the style from a QML file to a layer." );
61QgsApplyLayerStyleAlgorithm *QgsApplyLayerStyleAlgorithm::createInstance()
const
63 return new QgsApplyLayerStyleAlgorithm();
66void QgsApplyLayerStyleAlgorithm::initAlgorithm(
const QVariantMap & )
75 QGS_MARK_ALGORITHM_SOURCE
77 QgsMapLayer *layer = parameterAsLayer( parameters, u
"INPUT"_s, context );
78 const QString style = parameterAsFile( parameters, u
"STYLE"_s, context );
83 mLayerId = layer->id();
86 const QString msg = layer->loadNamedStyle( style, ok );
91 layer->triggerRepaint();
98 Q_UNUSED( parameters );
102 results.insert( u
"OUTPUT"_s, mLayerId );
@ File
Parameter is a single file.
Base class for all map layer types.
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.
A map layer output for processing algorithms, where layers may be either vector or raster.
An input file or folder parameter for processing algorithms.
A map layer parameter for processing algorithms.