QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgslayertreecustomnode.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayertreecustomnode.h
3 ------------------------
4 begin : July 2025
5 copyright : (C) 2025 by Germán Carrillo
6 email : german 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 QGSLAYERTREECUSTOMNODE_H
19#define QGSLAYERTREECUSTOMNODE_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgslayertreenode.h"
24
25#include <QObject>
26
36class CORE_EXPORT QgsLayerTreeCustomNode : public QgsLayerTreeNode
37{
38 Q_OBJECT
39 public:
40
48 explicit QgsLayerTreeCustomNode( const QString &nodeId, const QString &nodeName = QString(), bool checked = true );
49
50#ifndef SIP_RUN
52#endif
53
54#ifdef SIP_RUN
55 SIP_PYOBJECT __repr__();
56 % MethodCode
57 QString str = QStringLiteral( "<QgsLayerTreeCustomNode: %1>" ).arg( sipCpp->name() );
58 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
59 % End
60#endif
61
65 QString nodeId() const { return mId; };
66
70 QString name() const override;
71
75 void setName( const QString &name ) override;
76
80 static QgsLayerTreeCustomNode *readXml( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
81
85 void writeXml( QDomElement &parentElement, const QgsReadWriteContext &context ) override;
86
87 QString dump() const override;
88
90
91 void resolveReferences( const QgsProject *project, bool looseMatching = false ) override;
92
93 private:
94#ifdef SIP_RUN
95
100#endif
101
102 QgsLayerTreeCustomNode &operator= ( const QgsLayerTreeCustomNode & ) = delete;
103
104 QString mId;
105 QString mName;
106};
107
108#endif // QGSLAYERTREECUSTOMNODE_H
Layer tree custom node serves as a node for objects that are not layers nor groups.
QString nodeId() const
Returns the node's unique identifier.
QgsLayerTreeCustomNode(const QString &nodeId, const QString &nodeName=QString(), bool checked=true)
Constructor to create custom nodes that represent application objects other than layers and groups.
virtual void setName(const QString &name)=0
Set name of the node.
virtual QString dump() const =0
Returns string with layer tree structure. For debug purposes only.
virtual void writeXml(QDomElement &parentElement, const QgsReadWriteContext &context)=0
Write layer tree to XML.
static QgsLayerTreeNode * readXml(QDomElement &element, const QgsReadWriteContext &context)
Read layer tree from XML.
virtual QString name() const =0
Returns name of the node.
QgsLayerTreeNode(NodeType t, bool checked=true)
Constructor.
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
A container for the context for various read/write operations on objects.
#define SIP_FACTORY
Definition qgis_sip.h:84