QGIS API Documentation  2.99.0-Master (7fe5405)
qgslayertreelayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayertreelayer.h
3  --------------------------------------
4  Date : May 2014
5  Copyright : (C) 2014 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSLAYERTREELAYER_H
17 #define QGSLAYERTREELAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgslayertreenode.h"
21 
22 class QgsMapLayer;
23 
42 class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode
43 {
44  Q_OBJECT
45  public:
46  explicit QgsLayerTreeLayer( QgsMapLayer* layer );
47  QgsLayerTreeLayer( const QgsLayerTreeLayer& other );
48 
49  explicit QgsLayerTreeLayer( const QString& layerId, const QString& name = QString() );
50 
51  QString layerId() const { return mLayerId; }
52 
53  QgsMapLayer* layer() const { return mLayer; }
54 
57  QString name() const override;
60  void setName( const QString& n ) override;
61 
62  static QgsLayerTreeLayer* readXml( QDomElement& element );
63  virtual void writeXml( QDomElement& parentElement ) override;
64 
65  virtual QString dump() const override;
66 
67  virtual QgsLayerTreeLayer* clone() const override;
68 
69  protected slots:
70  void registryLayersAdded( const QList<QgsMapLayer*>& layers );
71  void registryLayersWillBeRemoved( const QStringList& layerIds );
74  void layerNameChanged();
75 
76  signals:
78  void layerLoaded();
81  void layerWillBeUnloaded();
82 
83  protected:
84  void attachToLayer();
85 
86  QString mLayerId;
87  QString mLayerName; // only used if layer does not exist
88  QgsMapLayer* mLayer; // not owned! may be null
89 };
90 
91 
92 
93 #endif // QGSLAYERTREELAYER_H
Base class for all map layer types.
Definition: qgsmaplayer.h:50
virtual QString name() const =0
Return name of the node.
virtual void setName(const QString &name)=0
Set name of the node.
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
virtual QString dump() const =0
Return string with layer tree structure. For debug purposes only.
QString layerId() const
QgsMapLayer * mLayer
virtual void writeXml(QDomElement &parentElement)=0
Write layer tree to XML.
static QgsLayerTreeNode * readXml(QDomElement &element)
Read layer tree from XML. Returns new instance.
This class is a base class for nodes in a layer tree.
QgsMapLayer * layer() const
Layer tree node points to a map layer.