QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
16 #ifndef QGSLAYERTREENODE_H
17 #define QGSLAYERTREENODE_H
19 #include "qgis_core.h"
80 if ( sipCpp->inherits(
"QgsLayerTreeNode" ) )
82 sipType = sipType_QgsLayerTreeNode;
85 sipType = sipType_QgsLayerTreeLayer;
86 else if ( qobject_cast<QgsLayerTree *>( sipCpp ) )
87 sipType = sipType_QgsLayerTree;
89 sipType = sipType_QgsLayerTreeGroup;
112 QList<QgsLayerTreeNode *>
children() {
return mChildren; }
120 virtual QString
name()
const = 0;
126 virtual void setName(
const QString &name ) = 0;
145 virtual QString
dump()
const = 0;
165 bool isVisible()
const;
180 void setItemVisibilityChecked(
bool checked );
186 virtual void setItemVisibilityCheckedRecursive(
bool checked );
192 void setItemVisibilityCheckedParentRecursive(
bool checked );
198 bool isItemVisibilityCheckedRecursive()
const;
204 bool isItemVisibilityUncheckedRecursive()
const;
211 QList< QgsMapLayer * > checkedLayers()
const;
220 bool isExpanded()
const;
222 void setExpanded(
bool expanded );
225 void setCustomProperty(
const QString &key,
const QVariant &value );
227 QVariant customProperty(
const QString &key,
const QVariant &defaultValue = QVariant() )
const;
229 void removeCustomProperty(
const QString &key );
231 QStringList customProperties()
const;
267 void readCommonXml( QDomElement &element );
269 void writeCommonXml( QDomElement &element );
272 void insertChildrenPrivate(
int index, QList<QgsLayerTreeNode *> nodes );
274 void removeChildrenPrivate(
int from,
int count,
bool destroy =
true );
296 #endif // QGSLAYERTREENODE_H
@ NodeGroup
Container of other groups and layers.
This class is a base class for nodes in a layer tree.
void removedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes has been removed from a node within the tree.
The class is used as a container of context for various read/write operations on other objects.
virtual void resolveReferences(const QgsProject *project, bool looseMatching=false)=0
Turn textual references to layers into map layer object from project.
void expandedChanged(QgsLayerTreeNode *node, bool expanded)
Emitted when the collapsed/expanded state of a node within the tree has been changed.
QList< QgsLayerTreeNode * > mChildren
list of children - node is responsible for their deletion
void customPropertyChanged(QgsLayerTreeNode *node, const QString &key)
Emitted when a custom property of a node within the tree has been changed or removed.
void nameChanged(QgsLayerTreeNode *node, QString name)
Emitted when the name of the node is changed.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
NodeType nodeType() const
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
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.
QgsObjectCustomProperties mProperties
custom properties attached to the node
NodeType
Enumeration of possible tree node types.
void willAddChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be added to a node within the tree.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
virtual void setName(const QString &name)=0
Set name of the node.
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
bool itemVisibilityChecked() const
Returns whether a node is checked (independently of its ancestors or children)
NodeType mNodeType
type of the node - determines which subclass is used
Base class for all map layer types.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
virtual QString name() const =0
Returns name of the node.
bool mExpanded
whether the node should be shown in GUI as expanded
void addedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes have been added to a node within the tree.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
void willRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be removed from a node within the tree.
static bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
QList< QgsLayerTreeNode * > children() const
Gets list of children of the node. Children are owned by the parent.
void visibilityChanged(QgsLayerTreeNode *node)
Emitted when check state of a node within the tree has been changed.