21 #include <QDomElement> 22 #include <QStringList> 41 clonedChildren << child->
clone();
53 if ( element.
tagName() ==
"layer-tree-group" )
55 else if ( element.
tagName() ==
"layer-tree-layer" )
125 int indexTo = index + nodes.
count() - 1;
127 for (
int i = 0; i < nodes.
count(); ++i )
146 if ( from < 0 || count <= 0 )
149 int to = from + count - 1;
153 while ( --count >= 0 )
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
static QgsLayerTreeGroup * readXML(QDomElement &element, bool looseMatch=false)
Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on ...
void readXml(const QDomNode &parentNode, const QString &keyStartsWith=QString())
Read store contents from XML.
void insertChildrenPrivate(int index, QList< QgsLayerTreeNode *> nodes)
Low-level insertion of children to the node. The children must not have any parent yet! ...
bool takeChild(QgsLayerTreeNode *node)
Remove a child from a node.
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
bool mExpanded
whether the node should be shown in GUI as expanded
void willRemoveChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be removed from a node within the tree.
void readCommonXML(QDomElement &element)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Return value for the given key. If the key is not stored, default value will be used.
void writeXml(QDomNode &parentNode, QDomDocument &doc) const
Write store contents to XML.
bool isExpanded() const
Return whether the node should be shown as expanded or collapsed in GUI.
NodeType
Enumeration of possible tree node types.
QStringList customProperties() const
Return list of keys stored in custom properties.
void remove(const QString &key)
Remove a key (entry) from the store.
void willAddChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes will be added to a node within the tree.
void removedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes has been removed from a node within the tree.
int indexOf(const T &value, int from) const
QgsLayerTreeNode(NodeType t)
NodeType mNodeType
type of the node - determines which subclass is used
void visibilityChanged(QgsLayerTreeNode *node, Qt::CheckState state)
Emitted when check state of a node within the tree has been changed.
int count(const T &value) const
void setValue(const QString &key, const QVariant &value)
Add an entry to the store. If the entry with the keys exists already, it will be overwritten.
QDomDocument ownerDocument() const
void expandedChanged(QgsLayerTreeNode *node, bool expanded)
Emitted when the collapsed/expanded state of a node within the tree has been changed.
void addedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes have been added to a node within the tree.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QgsLayerTreeNode * mParent
pointer to the parent node - null in case of root node
This class is a base class for nodes in a layer tree.
QList< QgsLayerTreeNode * > mChildren
list of children - node is responsible for their deletion
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
QStringList keys() const
Return list of stored keys.
void setExpanded(bool expanded)
Set whether the node should be shown as expanded or collapsed in GUI.
void removeChildrenPrivate(int from, int count, bool destroy=true)
Low-level removal of children from the node.
void writeCommonXML(QDomElement &element)
static QgsLayerTreeNode * readXML(QDomElement &element, bool looseMatch=false)
Read layer tree from XML.
void insert(int i, const T &value)
static QgsLayerTreeLayer * readXML(QDomElement &element, bool looseMatch=false)
Creates a new layer from an XML definition.
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.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the node.
QgsObjectCustomProperties mProperties
custom properties attached to the node