21 #include <QDomElement>
22 #include <QStringList>
34 , mNodeType( other.mNodeType )
36 , mExpanded( other.mExpanded )
37 , mProperties( other.mProperties )
41 clonedChildren << child->
clone();
53 if ( element.
tagName() ==
"layer-tree-group" )
55 else if ( element.
tagName() ==
"layer-tree-layer" )
113 if ( nodes.
count() == 0 )
118 Q_ASSERT( node->
mParent == 0 );
125 int indexTo = index + nodes.
count() - 1;
127 for (
int i = 0; i < nodes.
count(); ++i )
145 if ( from < 0 || count <= 0 )
148 int to = from + count - 1;
152 while ( --count >= 0 )
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
void readXml(const QDomNode &parentNode, const QString &keyStartsWith=QString())
Read store contents from XML.
bool takeChild(QgsLayerTreeNode *node)
Remove a child from a node.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
static QgsLayerTreeGroup * readXML(QDomElement &element)
Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on ...
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
QStringList customProperties() const
Return list of keys stored in custom properties.
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)
void customPropertyChanged(QgsLayerTreeNode *node, QString key)
Emitted when a custom property of a node within the tree has been changed or removed.
NodeType
Enumeration of possible tree node types.
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)
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 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 insertChildrenPrivate(int index, QList< QgsLayerTreeNode * > nodes)
Low-level insertion of children to the node. The children must not have any parent yet! ...
void addedChildren(QgsLayerTreeNode *node, int indexFrom, int indexTo)
Emitted when one or more nodes have been added to a node within the tree.
QStringList keys() const
Return list of stored keys.
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.
static QgsLayerTreeNode * readXML(QDomElement &element)
Read layer tree from XML. Returns new instance.
bool isExpanded() const
Return whether the node should be shown as expanded or collapsed in GUI.
QList< QgsLayerTreeNode * > mChildren
list of children - node is responsible for their deletion
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
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)
void writeXml(QDomNode &parentNode, QDomDocument &doc) const
Write store contents to XML.
void insert(int i, const T &value)
static QgsLayerTreeLayer * readXML(QDomElement &element)
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