Class: QgsStyleEntityVisitorInterface

An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern).

Added in version 3.10.

class qgis.core.QgsStyleEntityVisitorInterface[source]

Bases: object

class Node

Bases: object

Contains information relating to a node (i.e. a group of symbols or other nodes) being visited.

description: str
identifier: str
type: NodeType
class NodeType(*values)

Bases: IntEnum

Describes the types of nodes which may be visited by the visitor.

  • Project: QGIS Project node

  • Layer: Map layer

  • SymbolRule: Rule based symbology or label child rule

  • Layouts: Layout collection

  • PrintLayout: An individual print layout

  • LayoutItem: Individual item in a print layout

  • Report: A QGIS print report

  • ReportHeader: Report header section

  • ReportFooter: Report footer section

  • ReportSection: Report sub section

  • Annotations: Annotations collection

  • Annotation: An individual annotation

Annotation = 11
Annotations = 10
Layer = 1
LayoutItem = 5
Layouts = 3
PrintLayout = 4
Project = 0
Report = 6
ReportFooter = 8
ReportHeader = 7
ReportSection = 9
SymbolRule = 2
class StyleLeaf

Bases: object

Contains information relating to the style entity currently being visited.

description: str
entity: QgsStyleEntityInterface
identifier: str
virtual visit(self, entity: QgsStyleEntityVisitorInterface.StyleLeaf) bool[source]

Called when the visitor will visit a style entity.

Subclasses should return False to abort further visitations, or True to continue visiting after processing this entity.

Parameters:

entity (QgsStyleEntityVisitorInterface.StyleLeaf)

Return type:

bool

virtual visitEnter(self, node: QgsStyleEntityVisitorInterface.Node) bool[source]

Called when the visitor starts visiting a node.

Subclasses should return False if they do NOT want to visit this particular node - e.g. if the node type is QgsStyleEntityVisitorInterface.NodeType.Layouts and they do not wish to visit layout objects. In this case the visitor will not process the node, and will move to the next available node instead. Return True to proceed with visiting the node.

The default implementation returns True.

Parameters:

node (QgsStyleEntityVisitorInterface.Node)

Return type:

bool

virtual visitExit(self, node: QgsStyleEntityVisitorInterface.Node) bool[source]

Called when the visitor stops visiting a node.

Subclasses should return False to abort further visitations, or True to continue visiting other nodes.

The default implementation returns True.

Parameters:

node (QgsStyleEntityVisitorInterface.Node)

Return type:

bool