QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsprojectstylealgorithms.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectstylealgorithms.h
3 ---------------------
4 begin : July 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPROJECTSTYLESALGORITHMS_H
19#define QGSPROJECTSTYLESALGORITHMS_H
20
21#define SIP_NO_FILE
22
23#include "qgis_sip.h"
24#include "qgis_analysis.h"
26#include "qgsstyle.h"
28
30
37class ANALYSIS_EXPORT QgsSaveToStyleVisitor : public QgsStyleEntityVisitorInterface
38{
39 public:
40
48 QgsSaveToStyleVisitor( QgsStyle *style, const QList< QgsStyle::StyleEntity > &objects = QList< QgsStyle::StyleEntity >() );
49
50 bool visit( const QgsStyleEntityVisitorInterface::StyleLeaf &entity ) override;
51 bool visitEnter( const QgsStyleEntityVisitorInterface::Node &node ) override;
52 bool visitExit( const QgsStyleEntityVisitorInterface::Node &node ) override;
53
54 private:
55
56 QgsStyle *mStyle = nullptr;
57 QList< QgsStyle::StyleEntity > mObjects;
58 QStringList mParentNames;
59
60};
61
65class QgsStyleFromProjectAlgorithm : public QgsProcessingAlgorithm
66{
67
68 public:
69
70 QgsStyleFromProjectAlgorithm();
71 ~QgsStyleFromProjectAlgorithm() override;
72 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
73 QString name() const override;
74 QString displayName() const override;
75 QStringList tags() const override;
76 QString group() const override;
77 QString groupId() const override;
78 QString shortHelpString() const override;
79 QString shortDescription() const override;
80 QgsStyleFromProjectAlgorithm *createInstance() const override SIP_FACTORY;
81
82 protected:
83
84 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
85 QVariantMap processAlgorithm( const QVariantMap &parameters,
86 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
87
88 private:
89
90 QString mProjectPath;
91 QList< QgsStyle::StyleEntity > mObjects;
92 std::unique_ptr< QgsStyle > mStyle;
93};
94
96
97#endif // QGSPROJECTSTYLESALGORITHMS_H
98
99
Abstract base class for processing algorithms.
virtual QgsProcessingAlgorithm * createInstance() const =0
Creates a new instance of the algorithm class.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.
virtual QString shortDescription() const
Returns an optional translated short description of the algorithm.
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
virtual QStringList tags() const
Returns a list of tags which relate to the algorithm, and are used to assist users in searching for s...
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
An interface for classes which can visit style entity (e.g.
virtual bool visitExit(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor stops visiting a node.
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
#define SIP_FACTORY
Definition qgis_sip.h:76
Contains information relating to a node (i.e.
Contains information relating to the style entity currently being visited.