16 #ifndef QGSLAYERTREENODE_H
17 #define QGSLAYERTREENODE_H
19 #include "qgis_core.h"
81 if ( sipCpp->inherits(
"QgsLayerTreeNode" ) )
83 sipType = sipType_QgsLayerTreeNode;
86 sipType = sipType_QgsLayerTreeLayer;
87 else if ( qobject_cast<QgsLayerTree *>( sipCpp ) )
88 sipType = sipType_QgsLayerTree;
90 sipType = sipType_QgsLayerTreeGroup;
109 SIP_PYOBJECT __repr__();
111 QString
str = QStringLiteral(
"<QgsLayerTreeNode: %1>" ).arg( sipCpp->name() );
112 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
121 QList<QgsLayerTreeNode *>
children() {
return mChildren; }
130 QList<QgsLayerTreeNode *> abandonChildren()
SIP_SKIP;
136 virtual QString name() const = 0;
142 virtual
void setName( const QString &name ) = 0;
161 virtual QString dump() const = 0;
175 virtual
void resolveReferences( const
QgsProject *project,
bool looseMatching = false ) = 0;
181 bool isVisible() const;
187 bool itemVisibilityChecked()
const {
return mChecked; }
196 void setItemVisibilityChecked(
bool checked );
202 virtual void setItemVisibilityCheckedRecursive(
bool checked );
208 void setItemVisibilityCheckedParentRecursive(
bool checked );
214 bool isItemVisibilityCheckedRecursive()
const;
220 bool isItemVisibilityUncheckedRecursive()
const;
227 QList< QgsMapLayer * > checkedLayers()
const;
236 bool isExpanded()
const;
238 void setExpanded(
bool expanded );
241 void setCustomProperty(
const QString &key,
const QVariant &value );
243 QVariant customProperty(
const QString &key,
const QVariant &defaultValue = QVariant() )
const;
245 void removeCustomProperty(
const QString &key );
247 QStringList customProperties()
const;
283 void readCommonXml( QDomElement &element );
285 void writeCommonXml( QDomElement &element );
288 void insertChildrenPrivate(
int index, QList<QgsLayerTreeNode *> nodes );
290 void removeChildrenPrivate(
int from,
int count,
bool destroy =
true );
This class is a base class for nodes in a layer tree.
NodeType
Enumeration of possible tree node types.
@ NodeGroup
Container of other groups and layers.
void removedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes has been removed from a node within the tree.
void nameChanged(QgsLayerTreeNode *node, QString name)
Emitted when the name of the node is changed.
void willRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be removed from a node within the tree.
NodeType nodeType() const
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree...
QgsObjectCustomProperties mProperties
custom properties attached to the node
void customPropertyChanged(QgsLayerTreeNode *node, const QString &key)
Emitted when a custom property of a node within the tree has been changed or removed.
NodeType mNodeType
type of the node - determines which subclass is used
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
void addedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes have been added to a node within the tree.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
void willAddChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be added to a node within the tree.
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.
QList< QgsLayerTreeNode * > mChildren
list of children - node is responsible for their deletion
bool mExpanded
whether the node should be shown in GUI as expanded
void expandedChanged(QgsLayerTreeNode *node, bool expanded)
Emitted when the collapsed/expanded state of a node within the tree has been changed.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
static bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
Base class for all map layer types.
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
The class is used as a container of context for various read/write operations on other objects.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)