QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsmaplayerregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayerregistry.h
3  Singleton class for keeping track of loaded layers
4  -------------------
5  begin : Sun June 04 2004
6  copyright : (C) 2004 by Tim Sutton
7  email : tim@linfiniti.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSMAPLAYERREGISTRY_H
20 #define QGSMAPLAYERREGISTRY_H
21 
22 #include <QMap>
23 #include <QSet>
24 #include <QObject>
25 #include <QStringList>
26 
27 #include "qgssingleton.h"
28 class QString;
29 class QgsMapLayer;
30 
35 class CORE_EXPORT QgsMapLayerRegistry : public QObject, public QgsSingleton<QgsMapLayerRegistry>
36 {
37  Q_OBJECT
38 
39  public:
41  int count();
42 
44 
46  QgsMapLayer *mapLayer( QString theLayerId );
47 
49  QList<QgsMapLayer *> mapLayersByName( QString layerName );
50 
52  const QMap<QString, QgsMapLayer*> & mapLayers();
53 
76  QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
77  bool addToLegend = true,
78  bool takeOwnership = true );
79 
105  QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true, bool takeOwnership = true );
106 
120  void removeMapLayers( QStringList theLayerIds );
121 
135  void removeMapLayer( const QString& theLayerId );
136 
143  void removeAllMapLayers();
144 
151  Q_DECL_DEPRECATED void clearAllLayerCaches();
153 
157  void reloadAllLayers();
158 
159  signals:
165  void layersWillBeRemoved( QStringList theLayerIds );
166 
174  void layerWillBeRemoved( QString theLayerId );
175 
181  void layersRemoved( QStringList theLayerIds );
182 
190  void layerRemoved( QString theLayerId );
191 
192 
199  void removeAll();
200 
210  void layersAdded( QList<QgsMapLayer *> theMapLayers );
211 
219  void layerWasAdded( QgsMapLayer* theMapLayer );
220 
229  void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
230 
231  protected:
235  void connectNotify( const char * signal );
236 
237  private:
239  QgsMapLayerRegistry( QObject * parent = 0 );
240 
241  QMap<QString, QgsMapLayer*> mMapLayers;
242  QSet<QgsMapLayer*> mOwnedLayers;
243 
244  friend class QgsSingleton<QgsMapLayerRegistry>; // Let QgsSingleton access private constructor
245 }; // class QgsMapLayerRegistry
246 
247 #endif //QgsMapLayerRegistry_H
248 
Base class for all map layer types.
Definition: qgsmaplayer.h:48
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...