QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsstyleentityvisitor.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsstyleentityvisitor.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 QGSSTYLEENTITYVISITOR_H
19 #define QGSSTYLEENTITYVISITOR_H
20 
21 #include "qgis_core.h"
22 #include "qgsstyle.h"
23 
34 {
35 
36  public:
37 
41  enum class NodeType : int
42  {
43  Project,
44  Layer,
45  SymbolRule,
46  Layouts,
47  PrintLayout,
48  LayoutItem,
49  Report,
50  ReportHeader,
51  ReportFooter,
52  ReportSection,
53  Annotations,
54  Annotation,
55  };
56 
60  struct StyleLeaf
61  {
62 
68  StyleLeaf( const QgsStyleEntityInterface *entity, const QString &identifier = QString(), const QString &description = QString() )
69  : identifier( identifier )
70  , description( description )
71  , entity( entity )
72  {}
73 
85  QString identifier;
86 
98  QString description;
99 
103  const QgsStyleEntityInterface *entity = nullptr;
104  };
105 
110  struct Node
111  {
112 
116  Node( QgsStyleEntityVisitorInterface::NodeType type, const QString &identifier, const QString &description )
117  : type( type )
118  , identifier( identifier )
119  , description( description )
120  {}
121 
126 
133  QString identifier;
134 
141  QString description;
142 
143  };
144 
145  virtual ~QgsStyleEntityVisitorInterface() = default;
146 
153  virtual bool visit( const QgsStyleEntityVisitorInterface::StyleLeaf &entity )
154  {
155  Q_UNUSED( entity )
156  return true;
157  }
158 
170  {
171  Q_UNUSED( node )
172  return true;
173  }
174 
184  {
185  Q_UNUSED( node )
186  return true;
187  }
188 
189 };
190 
191 #endif // QGSSTYLEENTITYVISITOR_H
An interface for entities which can be placed in a QgsStyle database.
Definition: qgsstyle.h:1171
An interface for classes which can visit style entity (e.g.
NodeType
Describes the types of nodes which may be visited by the visitor.
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.
virtual ~QgsStyleEntityVisitorInterface()=default
Contains information relating to a node (i.e.
Node(QgsStyleEntityVisitorInterface::NodeType type, const QString &identifier, const QString &description)
Constructor for Node, visiting the node with the specified identifier and description.
QString identifier
A string identifying the node.
QString description
A string describing the node.
Contains information relating to the style entity currently being visited.
QString description
A string describing the style entity.
QString identifier
A string identifying the style entity.
StyleLeaf(const QgsStyleEntityInterface *entity, const QString &identifier=QString(), const QString &description=QString())
Constructor for StyleLeaf, visiting the given style entity with the specified identifier and descript...