QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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
QgsStyleEntityVisitorInterface::Node::description
QString description
A string describing the node.
Definition: qgsstyleentityvisitor.h:141
QgsStyleEntityInterface
Definition: qgsstyle.h:1086
QgsStyleEntityVisitorInterface
Definition: qgsstyleentityvisitor.h:33
QgsStyleEntityVisitorInterface::visitExit
virtual bool visitExit(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor stops visiting a node.
Definition: qgsstyleentityvisitor.h:183
QgsStyleEntityVisitorInterface::StyleLeaf
Contains information relating to the style entity currently being visited.
Definition: qgsstyleentityvisitor.h:60
QgsStyleEntityVisitorInterface::Node::Node
Node(QgsStyleEntityVisitorInterface::NodeType type, const QString &identifier, const QString &description)
Constructor for Node, visiting the node with the specified identifier and description.
Definition: qgsstyleentityvisitor.h:116
QgsStyleEntityVisitorInterface::StyleLeaf::StyleLeaf
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...
Definition: qgsstyleentityvisitor.h:68
QgsStyleEntityVisitorInterface::StyleLeaf::description
QString description
A string describing the style entity.
Definition: qgsstyleentityvisitor.h:98
QgsStyleEntityVisitorInterface::Node
Contains information relating to a node (i.e.
Definition: qgsstyleentityvisitor.h:110
qgsstyle.h
QgsStyleEntityVisitorInterface::visitEnter
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
Definition: qgsstyleentityvisitor.h:169
QgsStyleEntityVisitorInterface::StyleLeaf::identifier
QString identifier
A string identifying the style entity.
Definition: qgsstyleentityvisitor.h:85
QgsStyleEntityVisitorInterface::visit
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
Definition: qgsstyleentityvisitor.h:153
QgsStyleEntityVisitorInterface::NodeType
NodeType
Describes the types of nodes which may be visited by the visitor.
Definition: qgsstyleentityvisitor.h:41
QgsStyleEntityVisitorInterface::Node::identifier
QString identifier
A string identifying the node.
Definition: qgsstyleentityvisitor.h:133
QgsStyleEntityVisitorInterface::NodeType::Project
@ Project
QGIS Project node.