QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
47 QgsSaveToStyleVisitor( QgsStyle *style, const QList<QgsStyle::StyleEntity> &objects = QList<QgsStyle::StyleEntity>() );
48
49 bool visit( const QgsStyleEntityVisitorInterface::StyleLeaf &entity ) override;
50 bool visitEnter( const QgsStyleEntityVisitorInterface::Node &node ) override;
51 bool visitExit( const QgsStyleEntityVisitorInterface::Node &node ) override;
52
53 private:
54 QgsStyle *mStyle = nullptr;
55 QList<QgsStyle::StyleEntity> mObjects;
56 QStringList mParentNames;
57};
58
62class QgsStyleFromProjectAlgorithm : public QgsProcessingAlgorithm
63{
64 public:
65 QgsStyleFromProjectAlgorithm();
66 ~QgsStyleFromProjectAlgorithm() override;
67 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
68 QString name() const override;
69 QString displayName() const override;
70 QStringList tags() const override;
71 QString group() const override;
72 QString groupId() const override;
73 QString shortHelpString() const override;
74 QString shortDescription() const override;
75 QgsStyleFromProjectAlgorithm *createInstance() const override SIP_FACTORY;
76
77 protected:
78 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
79 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
80
81 private:
82 QString mProjectPath;
83 QList<QgsStyle::StyleEntity> mObjects;
84 std::unique_ptr<QgsStyle> mStyle;
85};
86
88
89#endif // QGSPROJECTSTYLESALGORITHMS_H
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.