22#include "moc_qgslayertreecustomnode.cpp"
27 , mName( nodeName.isEmpty() ?
nodeId : nodeName )
34 , mName( other.mName )
54 if ( element.tagName() != QLatin1String(
"layer-tree-custom-node" ) )
57 const QString
nodeId = element.attribute( QStringLiteral(
"id" ) );
58 const QString
name = element.attribute( QStringLiteral(
"name" ) );
69 QDomDocument doc = parentElement.ownerDocument();
70 QDomElement elem = doc.createElement( QStringLiteral(
"layer-tree-custom-node" ) );
71 elem.setAttribute( QStringLiteral(
"id" ), mId );
72 elem.setAttribute( QStringLiteral(
"name" ), mName );
73 elem.setAttribute( QStringLiteral(
"checked" ),
mChecked ? QStringLiteral(
"Qt::Checked" ) : QStringLiteral(
"Qt::Unchecked" ) );
77 parentElement.appendChild( elem );
82 return QStringLiteral(
"CUSTOM NODE: %1 checked=%2 id=%3\n" ).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.