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

Layer tree node points to a map layer. More...

#include <qgslayertreelayer.h>

Inheritance diagram for QgsLayerTreeLayer:
Inheritance graph
[legend]

Signals

void layerLoaded ()
 emitted when a previously unavailable layer got loaded
void layerWillBeUnloaded ()
 emitted when a previously available layer got unloaded (from layer registry)
- 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.

Public Member Functions

 QgsLayerTreeLayer (QgsMapLayer *layer)
 QgsLayerTreeLayer (const QgsLayerTreeLayer &other)
 QgsLayerTreeLayer (QString layerId, QString name=QString())
virtual QgsLayerTreeNodeclone () const override
 Create a copy of the node. Returns new instance.
virtual QString dump () const override
 Return string with layer tree structure. For debug purposes only.
Qt::CheckState isVisible () const
QgsMapLayerlayer () const
QString layerId () const
QString layerName () const
void setLayerName (const QString &n)
void setVisible (Qt::CheckState visible)
virtual void writeXML (QDomElement &parentElement) override
 Write layer tree to XML.
- 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 QgsLayerTreeLayerreadXML (QDomElement &element)
 Read layer tree from XML. Returns new instance.

Protected Slots

void registryLayersAdded (QList< QgsMapLayer * > layers)
void registryLayersWillBeRemoved (const QStringList &layerIds)

Protected Member Functions

void attachToLayer ()
- 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

QgsMapLayermLayer
QString mLayerId
QString mLayerName
Qt::CheckState mVisible
- 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...

Detailed Description

Layer tree node points to a map layer.

When using with existing QgsMapLayer instance, it is expected that the layer has been registered in QgsMapLayerRegistry earlier.

The node can exist also without a valid instance of a layer (just ID). That means the referenced layer does not need to be loaded in order to use it in layer tree. In such case, the node will start listening to map layer registry updates in expectation that the layer (identified by its ID) will be loaded later.

A map layer is supposed to be present in one layer tree just once. It is however possible that temporarily a layer exists in one tree more than just once, e.g. while reordering items with drag and drop.

Note
added in 2.4

Definition at line 41 of file qgslayertreelayer.h.

Constructor & Destructor Documentation

QgsLayerTreeLayer::QgsLayerTreeLayer ( QgsMapLayer layer)
explicit

Definition at line 23 of file qgslayertreelayer.cpp.

QgsLayerTreeLayer::QgsLayerTreeLayer ( const QgsLayerTreeLayer other)

Definition at line 43 of file qgslayertreelayer.cpp.

QgsLayerTreeLayer::QgsLayerTreeLayer ( QString  layerId,
QString  name = QString() 
)
explicit

Definition at line 33 of file qgslayertreelayer.cpp.

Member Function Documentation

void QgsLayerTreeLayer::attachToLayer ( )
protected

Definition at line 53 of file qgslayertreelayer.cpp.

QgsLayerTreeNode * QgsLayerTreeLayer::clone ( ) const
overridevirtual

Create a copy of the node. Returns new instance.

Implements QgsLayerTreeNode.

Definition at line 141 of file qgslayertreelayer.cpp.

QString QgsLayerTreeLayer::dump ( ) const
overridevirtual

Return string with layer tree structure. For debug purposes only.

Implements QgsLayerTreeNode.

Definition at line 136 of file qgslayertreelayer.cpp.

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

Definition at line 57 of file qgslayertreelayer.h.

QgsMapLayer* QgsLayerTreeLayer::layer ( ) const
inline

Definition at line 52 of file qgslayertreelayer.h.

QString QgsLayerTreeLayer::layerId ( ) const
inline

Definition at line 50 of file qgslayertreelayer.h.

void QgsLayerTreeLayer::layerLoaded ( )
signal

emitted when a previously unavailable layer got loaded

QString QgsLayerTreeLayer::layerName ( ) const

Definition at line 74 of file qgslayertreelayer.cpp.

void QgsLayerTreeLayer::layerWillBeUnloaded ( )
signal

emitted when a previously available layer got unloaded (from layer registry)

Note
added in 2.6
QgsLayerTreeLayer * QgsLayerTreeLayer::readXML ( QDomElement &  element)
static

Read layer tree from XML. Returns new instance.

Reimplemented from QgsLayerTreeNode.

Definition at line 96 of file qgslayertreelayer.cpp.

void QgsLayerTreeLayer::registryLayersAdded ( QList< QgsMapLayer * >  layers)
protectedslot

Definition at line 146 of file qgslayertreelayer.cpp.

void QgsLayerTreeLayer::registryLayersWillBeRemoved ( const QStringList &  layerIds)
protectedslot

Definition at line 160 of file qgslayertreelayer.cpp.

void QgsLayerTreeLayer::setLayerName ( const QString &  n)

Definition at line 79 of file qgslayertreelayer.cpp.

void QgsLayerTreeLayer::setVisible ( Qt::CheckState  visible)

Definition at line 87 of file qgslayertreelayer.cpp.

void QgsLayerTreeLayer::writeXML ( QDomElement &  parentElement)
overridevirtual

Write layer tree to XML.

Implements QgsLayerTreeNode.

Definition at line 122 of file qgslayertreelayer.cpp.

Member Data Documentation

QgsMapLayer* QgsLayerTreeLayer::mLayer
protected

Definition at line 83 of file qgslayertreelayer.h.

QString QgsLayerTreeLayer::mLayerId
protected

Definition at line 81 of file qgslayertreelayer.h.

QString QgsLayerTreeLayer::mLayerName
protected

Definition at line 82 of file qgslayertreelayer.h.

Qt::CheckState QgsLayerTreeLayer::mVisible
protected

Definition at line 84 of file qgslayertreelayer.h.


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