QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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#include <QString>
27
28using namespace Qt::StringLiterals;
29
39class CORE_EXPORT QgsLayerTreeCustomNode : public QgsLayerTreeNode
40{
41 Q_OBJECT
42 public:
50 explicit QgsLayerTreeCustomNode( const QString &nodeId, const QString &nodeName = QString(), bool checked = true );
51
52#ifndef SIP_RUN
54#endif
55
56#ifdef SIP_RUN
57 // clang-format off
58 SIP_PYOBJECT __repr__();
59 % MethodCode
60 QString str = u"<QgsLayerTreeCustomNode: %1>"_s.arg( sipCpp->name() );
61 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
62 % End
63// clang-format on
64#endif
65
69 QString nodeId() const
70 {
71 return mId;
72 };
73
77 QString name() const override;
78
82 void setName( const QString &name ) override;
83
87 static QgsLayerTreeCustomNode *readXml( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
88
92 void writeXml( QDomElement &parentElement, const QgsReadWriteContext &context ) override;
93
94 QString dump() const override;
95
97
98 void resolveReferences( const QgsProject *project, bool looseMatching = false ) override;
99
100 private:
101#ifdef SIP_RUN
102
107#endif
108
109 QgsLayerTreeCustomNode &operator=( const QgsLayerTreeCustomNode & ) = delete;
110
111 QString mId;
112 QString mName;
113};
114
115#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:113
A container for the context for various read/write operations on objects.
#define SIP_FACTORY
Definition qgis_sip.h:83