QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
QgsLayerTreeGroup Class Reference

Layer tree group node serves as a container for layers and further groups. More...

#include <qgslayertreegroup.h>

Inheritance diagram for QgsLayerTreeGroup:
Inheritance graph
[legend]

Public Member Functions

 QgsLayerTreeGroup (const QString &name=QString(), Qt::CheckState checked=Qt::Checked)
 QgsLayerTreeGroup (const QgsLayerTreeGroup &other)
void addChildNode (QgsLayerTreeNode *node)
 Append an existing node. The node must not have a parent yet. The node will be owned by this group.
QgsLayerTreeGroupaddGroup (const QString &name)
 Append a new group node with given name. Newly created node is owned by this group.
QgsLayerTreeLayeraddLayer (QgsMapLayer *layer)
 Append a new layer node for given map layer. Newly created node is owned by this group.
virtual QgsLayerTreeNodeclone () const override
 Return a clone of the group. The children are cloned too.
virtual QString dump () const override
 Return text representation of the tree. For debugging purposes only.
QgsLayerTreeGroupfindGroup (const QString &name)
 Find group node with specified name. Searches recursively the whole sub-tree.
QgsLayerTreeLayerfindLayer (const QString &layerId) const
 Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
QStringList findLayerIds () const
 Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
QList< QgsLayerTreeLayer * > findLayers () const
 Find all layer nodes. Searches recursively the whole sub-tree.
void insertChildNode (int index, QgsLayerTreeNode *node)
 Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
void insertChildNodes (int index, QList< QgsLayerTreeNode * > nodes)
 Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
QgsLayerTreeGroupinsertGroup (int index, const QString &name)
 Insert a new group node with given name at specified position. Newly created node is owned by this group.
QgsLayerTreeLayerinsertLayer (int index, QgsMapLayer *layer)
 Insert a new layer node for given map layer at specified position. Newly created node is owned by this group.
Qt::CheckState isVisible () const
 Return the check state of the group node.
QString name () const
 Get group's name.
void readChildrenFromXML (QDomElement &element)
 Read children from XML and append them to the group.
void removeAllChildren ()
 Remove all child nodes. The nodes will be deleted.
void removeChildNode (QgsLayerTreeNode *node)
 Remove a child node from this group. The node will be deleted.
void removeChildren (int from, int count)
 Remove child nodes from index "from". The nodes will be deleted.
void removeChildrenGroupWithoutLayers ()
 Remove all child group nodes without layers. The groupnodes will be deleted.
void removeLayer (QgsMapLayer *layer)
 Remove map layer's node from this group. The node will be deleted.
void setName (const QString &n)
 Set group's name.
void setVisible (Qt::CheckState state)
 Set check state of the group node - will also update children.
virtual void writeXML (QDomElement &parentElement) override
 Write group (tree) as XML element <layer-tree-group> and add it to the given parent element.
- Public Member Functions inherited from QgsLayerTreeNode
 ~QgsLayerTreeNode ()
QList< QgsLayerTreeNode * > children ()
 Get list of children of the node. Children are owned by the parent.
QStringList customProperties () const
 Return list of keys stored in custom properties.
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from layer.
bool isExpanded () const
 Return whether the node should be shown as expanded or collapsed in GUI.
NodeType nodeType ()
 Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree namespace for that.
QgsLayerTreeNodeparent ()
 Get pointer to the parent. If parent is a null pointer, the node is a root node.
void removeCustomProperty (const QString &key)
 Remove a custom property from layer.
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the node.
void setExpanded (bool expanded)
 Set whether the node should be shown as expanded or collapsed in GUI.
bool takeChild (QgsLayerTreeNode *node)
 Remove a child from a node.

Static Public Member Functions

static QgsLayerTreeGroupreadXML (QDomElement &element)
 Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error)

Protected Slots

void layerDestroyed ()
void nodeVisibilityChanged (QgsLayerTreeNode *node)

Protected Member Functions

void updateVisibilityFromChildren ()
- Protected Member Functions inherited from QgsLayerTreeNode
 QgsLayerTreeNode (NodeType t)
 QgsLayerTreeNode (const QgsLayerTreeNode &other)
void insertChildrenPrivate (int index, QList< QgsLayerTreeNode * > nodes)
 Low-level insertion of children to the node. The children must not have any parent yet!
void readCommonXML (QDomElement &element)
void removeChildrenPrivate (int from, int count, bool destroy=true)
 Low-level removal of children from the node.
void writeCommonXML (QDomElement &element)

Protected Attributes

bool mChangingChildVisibility
Qt::CheckState mChecked
QString mName
- Protected Attributes inherited from QgsLayerTreeNode
QList< QgsLayerTreeNode * > mChildren
 list of children - node is responsible for their deletion
bool mExpanded
 whether the node should be shown in GUI as expanded
NodeType mNodeType
 type of the node - determines which subclass is used
QgsLayerTreeNodemParent
 pointer to the parent node - null in case of root node
QgsObjectCustomProperties mProperties
 custom properties attached to the node

Additional Inherited Members

- Public Types inherited from QgsLayerTreeNode
enum  NodeType { NodeGroup, NodeLayer }
 Enumeration of possible tree node types. More...
- Signals inherited from QgsLayerTreeNode
void addedChildren (QgsLayerTreeNode *node, int indexFrom, int indexTo)
 Emitted when one or more nodes have been added to a node within the tree.
void customPropertyChanged (QgsLayerTreeNode *node, QString key)
 Emitted when a custom property of a node within the tree has been changed or removed.
void expandedChanged (QgsLayerTreeNode *node, bool expanded)
 Emitted when the collapsed/expanded state of a node within the tree has been changed.
void removedChildren (QgsLayerTreeNode *node, int indexFrom, int indexTo)
 Emitted when one or more nodes has been removed from a node within the tree.
void visibilityChanged (QgsLayerTreeNode *node, Qt::CheckState state)
 Emitted when check state of a node within the tree has been changed.
void willAddChildren (QgsLayerTreeNode *node, int indexFrom, int indexTo)
 Emitted when one or more nodes will be added to a node within the tree.
void willRemoveChildren (QgsLayerTreeNode *node, int indexFrom, int indexTo)
 Emitted when one or more nodes will be removed from a node within the tree.

Detailed Description

Layer tree group node serves as a container for layers and further groups.

Group names do not need to be unique within one tree nor within one parent.

Note
added in 2.4

Definition at line 31 of file qgslayertreegroup.h.

Constructor & Destructor Documentation

QgsLayerTreeGroup::QgsLayerTreeGroup ( const QString &  name = QString(),
Qt::CheckState  checked = Qt::Checked 
)

Definition at line 27 of file qgslayertreegroup.cpp.

QgsLayerTreeGroup::QgsLayerTreeGroup ( const QgsLayerTreeGroup other)

Definition at line 36 of file qgslayertreegroup.cpp.

Member Function Documentation

void QgsLayerTreeGroup::addChildNode ( QgsLayerTreeNode node)

Append an existing node. The node must not have a parent yet. The node will be owned by this group.

Definition at line 95 of file qgslayertreegroup.cpp.

QgsLayerTreeGroup * QgsLayerTreeGroup::addGroup ( const QString &  name)

Append a new group node with given name. Newly created node is owned by this group.

Definition at line 53 of file qgslayertreegroup.cpp.

QgsLayerTreeLayer * QgsLayerTreeGroup::addLayer ( QgsMapLayer layer)

Append a new layer node for given map layer. Newly created node is owned by this group.

Definition at line 70 of file qgslayertreegroup.cpp.

QgsLayerTreeNode * QgsLayerTreeGroup::clone ( ) const
overridevirtual

Return a clone of the group. The children are cloned too.

Implements QgsLayerTreeNode.

Definition at line 266 of file qgslayertreegroup.cpp.

QString QgsLayerTreeGroup::dump ( ) const
overridevirtual

Return text representation of the tree. For debugging purposes only.

Implements QgsLayerTreeNode.

Definition at line 255 of file qgslayertreegroup.cpp.

QgsLayerTreeGroup * QgsLayerTreeGroup::findGroup ( const QString &  name)

Find group node with specified name. Searches recursively the whole sub-tree.

Definition at line 184 of file qgslayertreegroup.cpp.

QgsLayerTreeLayer * QgsLayerTreeGroup::findLayer ( const QString &  layerId) const

Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.

Definition at line 151 of file qgslayertreegroup.cpp.

QStringList QgsLayerTreeGroup::findLayerIds ( ) const

Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.

Definition at line 296 of file qgslayertreegroup.cpp.

QList< QgsLayerTreeLayer * > QgsLayerTreeGroup::findLayers ( ) const

Find all layer nodes. Searches recursively the whole sub-tree.

Definition at line 171 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::insertChildNode ( int  index,
QgsLayerTreeNode node 
)

Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.

Definition at line 80 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::insertChildNodes ( int  index,
QList< QgsLayerTreeNode * >  nodes 
)

Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.

Definition at line 87 of file qgslayertreegroup.cpp.

QgsLayerTreeGroup * QgsLayerTreeGroup::insertGroup ( int  index,
const QString &  name 
)

Insert a new group node with given name at specified position. Newly created node is owned by this group.

Definition at line 46 of file qgslayertreegroup.cpp.

QgsLayerTreeLayer * QgsLayerTreeGroup::insertLayer ( int  index,
QgsMapLayer layer 
)

Insert a new layer node for given map layer at specified position. Newly created node is owned by this group.

Definition at line 60 of file qgslayertreegroup.cpp.

Qt::CheckState QgsLayerTreeGroup::isVisible ( ) const
inline

Return the check state of the group node.

Definition at line 93 of file qgslayertreegroup.h.

void QgsLayerTreeGroup::layerDestroyed ( )
protectedslot

Definition at line 310 of file qgslayertreegroup.cpp.

QString QgsLayerTreeGroup::name ( ) const
inline

Get group's name.

Definition at line 39 of file qgslayertreegroup.h.

void QgsLayerTreeGroup::nodeVisibilityChanged ( QgsLayerTreeNode node)
protectedslot

Definition at line 316 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::readChildrenFromXML ( QDomElement &  element)

Read children from XML and append them to the group.

Definition at line 239 of file qgslayertreegroup.cpp.

QgsLayerTreeGroup * QgsLayerTreeGroup::readXML ( QDomElement &  element)
static

Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error)

Reimplemented from QgsLayerTreeNode.

Definition at line 204 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::removeAllChildren ( )

Remove all child nodes. The nodes will be deleted.

Definition at line 146 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::removeChildNode ( QgsLayerTreeNode node)

Remove a child node from this group. The node will be deleted.

Definition at line 100 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::removeChildren ( int  from,
int  count 
)

Remove child nodes from index "from". The nodes will be deleted.

Definition at line 123 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::removeChildrenGroupWithoutLayers ( )

Remove all child group nodes without layers. The groupnodes will be deleted.

Definition at line 130 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::removeLayer ( QgsMapLayer layer)

Remove map layer's node from this group. The node will be deleted.

Definition at line 107 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::setName ( const QString &  n)
inline

Set group's name.

Definition at line 41 of file qgslayertreegroup.h.

void QgsLayerTreeGroup::setVisible ( Qt::CheckState  state)

Set check state of the group node - will also update children.

Definition at line 271 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::updateVisibilityFromChildren ( )
protected

Definition at line 322 of file qgslayertreegroup.cpp.

void QgsLayerTreeGroup::writeXML ( QDomElement &  parentElement)
overridevirtual

Write group (tree) as XML element <layer-tree-group> and add it to the given parent element.

Implements QgsLayerTreeNode.

Definition at line 223 of file qgslayertreegroup.cpp.

Member Data Documentation

bool QgsLayerTreeGroup::mChangingChildVisibility
protected

Definition at line 108 of file qgslayertreegroup.h.

Qt::CheckState QgsLayerTreeGroup::mChecked
protected

Definition at line 106 of file qgslayertreegroup.h.

QString QgsLayerTreeGroup::mName
protected

Definition at line 105 of file qgslayertreegroup.h.


The documentation for this class was generated from the following files: