QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsobjectvisitor.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsobjectvisitor.h
3 ---------------
4 begin : October 2025
5 copyright : (C) 2025 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
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 QGSOBJECTVISITOR_H
19#define QGSOBJECTVISITOR_H
20
21#include "qgis.h"
22#include "qgis_core.h"
23
30class CORE_EXPORT QgsEmbeddedScriptEntity
31{
32 public:
33
38 : mType( type )
39 , mName( name )
40 , mScript( script )
41 {}
42
46 Qgis::EmbeddedScriptType type() const { return mType; }
47
51 QString name() const { return mName; }
52
56 QString script() const { return mScript; }
57
58 private:
59
61 QString mName;
62 QString mScript;
63
64};
65
66
75class CORE_EXPORT QgsObjectVisitorContext
76{
77 public:
78
80};
81
82
92{
93
94 public:
95
97
104 virtual bool visitEmbeddedScript( const QgsEmbeddedScriptEntity &entity, const QgsObjectVisitorContext &context )
105 {
106 Q_UNUSED( entity )
107 Q_UNUSED( context )
108 return true;
109 }
110
111};
112
113
121{
122 public:
123
125 {
126 mEmbeddedScripts << entity;
127 return true;
128 }
129
131 const QList<QgsEmbeddedScriptEntity> &embeddedScripts() const { return mEmbeddedScripts; }
132
133 private:
134 QList<QgsEmbeddedScriptEntity> mEmbeddedScripts;
135};
136
137#endif // QGSOBJECTVISITOR_H
EmbeddedScriptType
Type of Python Embedded in projects.
Definition qgis.h:439
A embedded script entity for QgsObjectEntityVisitorInterface.
QgsEmbeddedScriptEntity(Qgis::EmbeddedScriptType type, const QString &name, const QString &script)
Constructor for QgsEmbeddedScriptEntity.
QString script() const
Returns the entity's script.
Qgis::EmbeddedScriptType type() const
Returns the entity's embedded script type.
QString name() const
Returns the entity's name.
An object entity visitor to collect embedded scripts wthin a project and its layers.
bool visitEmbeddedScript(const QgsEmbeddedScriptEntity &entity, const QgsObjectVisitorContext &) override
Called when the visitor will visit an embedded script entity.
const QList< QgsEmbeddedScriptEntity > & embeddedScripts() const
Returns the collected embedded scripts.
An interface for classes which can visit various object entity (e.g.
virtual bool visitEmbeddedScript(const QgsEmbeddedScriptEntity &entity, const QgsObjectVisitorContext &context)
Called when the visitor will visit an embedded script entity.
virtual ~QgsObjectEntityVisitorInterface()=default
A QgsObjectEntityVisitorInterface context object.
QgsObjectVisitorContext()=default