QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "qgslayertreenode.h"
20 
21 class QgsMapLayer;
22 
41 class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode
42 {
43  Q_OBJECT
44  public:
45  explicit QgsLayerTreeLayer( QgsMapLayer* layer );
46  QgsLayerTreeLayer( const QgsLayerTreeLayer& other );
47 
48  explicit QgsLayerTreeLayer( QString layerId, QString name = QString() );
49 
50  QString layerId() const { return mLayerId; }
51 
52  QgsMapLayer* layer() const { return mLayer; }
53 
54  QString layerName() const;
55  void setLayerName( const QString& n );
56 
57  Qt::CheckState isVisible() const { return mVisible; }
58  void setVisible( Qt::CheckState visible );
59 
60  static QgsLayerTreeLayer* readXML( QDomElement& element );
61  virtual void writeXML( QDomElement& parentElement );
62 
63  virtual QString dump() const;
64 
65  virtual QgsLayerTreeNode* clone() const;
66 
67  protected slots:
68  void registryLayersAdded( QList<QgsMapLayer*> layers );
69  void registryLayersWillBeRemoved( const QStringList& layerIds );
70 
71  signals:
73  void layerLoaded();
76  void layerWillBeUnloaded();
77 
78  protected:
79  void attachToLayer();
80 
81  QString mLayerId;
82  QString mLayerName; // only used if layer does not exist
83  QgsMapLayer* mLayer; // not owned! may be null
84  Qt::CheckState mVisible;
85 };
86 
87 
88 
89 #endif // QGSLAYERTREELAYER_H