24#include "moc_qgslayertreecustomnode.cpp"
26using namespace Qt::StringLiterals;
31 , mName( nodeName.isEmpty() ?
nodeId : nodeName )
38 , mName( other.mName )
58 if ( element.tagName() !=
"layer-tree-custom-node"_L1 )
61 const QString
nodeId = element.attribute( u
"id"_s );
62 const QString
name = element.attribute( u
"name"_s );
73 QDomDocument doc = parentElement.ownerDocument();
74 QDomElement elem = doc.createElement( u
"layer-tree-custom-node"_s );
75 elem.setAttribute( u
"id"_s, mId );
76 elem.setAttribute( u
"name"_s, mName );
77 elem.setAttribute( u
"checked"_s,
mChecked ? u
"Qt::Checked"_s : u
"Qt::Unchecked"_s );
81 parentElement.appendChild( elem );
86 return u
"CUSTOM NODE: %1 checked=%2 id=%3\n"_s.arg( mName ).arg(
mChecked ).arg( mId );
QString name() const override
Returns the node's name.
QString dump() const override
Returns string with layer tree structure. For debug purposes only.
QgsLayerTreeCustomNode * clone() const override
Create a copy of the node. Returns new instance.
void resolveReferences(const QgsProject *project, bool looseMatching=false) override
Turn textual references to layers into map layer object from project.
QString nodeId() const
Returns the node's unique identifier.
void setName(const QString &name) override
Sets the node's name.
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.
void writeXml(QDomElement &parentElement, const QgsReadWriteContext &context) override
Write custom node as XML element <layer-tree-custom-node> and add it to the given parent element.
static QgsLayerTreeCustomNode * readXml(const QDomElement &element, const QgsReadWriteContext &context)
Read custom node from XML element <layer-tree-custom-node> and return the newly created node (or null...
@ NodeCustom
Leaf node pointing to a custom object.
void nameChanged(QgsLayerTreeNode *node, QString name)
Emitted when the name of the node is changed.
QgsLayerTreeNode(NodeType t, bool checked=true)
Constructor.
void writeCommonXml(QDomElement &element)
Write common XML elements.
void readCommonXml(const QDomElement &element)
Read common XML elements.
static Qt::CheckState checkStateFromXml(const QString &txt)
Convert QString to Qt::CheckState.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A container for the context for various read/write operations on objects.