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 class QString;
27 class QgsMapLayer;
28 
33 class CORE_EXPORT QgsMapLayerRegistry : public QObject
34 {
35  Q_OBJECT
36 
37  public:
39  static QgsMapLayerRegistry * instance();
40 
42  int count();
43 
45 
47  QgsMapLayer *mapLayer( QString theLayerId );
48 
50  QList<QgsMapLayer *> mapLayersByName( QString layerName );
51 
53  const QMap<QString, QgsMapLayer*> & mapLayers();
54 
77  QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
78  bool addToLegend = true,
79  bool takeOwnership = true );
80 
106  QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true, bool takeOwnership = true );
107 
121  void removeMapLayers( QStringList theLayerIds );
122 
136  void removeMapLayer( const QString& theLayerId );
137 
144  void removeAllMapLayers();
145 
152  Q_DECL_DEPRECATED void clearAllLayerCaches();
154 
158  void reloadAllLayers();
159 
160  signals:
166  void layersWillBeRemoved( QStringList theLayerIds );
167 
175  void layerWillBeRemoved( QString theLayerId );
176 
182  void layersRemoved( QStringList theLayerIds );
183 
191  void layerRemoved( QString theLayerId );
192 
193 
200  void removeAll();
201 
211  void layersAdded( QList<QgsMapLayer *> theMapLayers );
212 
220  void layerWasAdded( QgsMapLayer* theMapLayer );
221 
230  void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
231 
232  protected:
236  void connectNotify( const char * signal );
237 
238  private:
240  QgsMapLayerRegistry( QObject * parent = 0 );
241 
242  static QgsMapLayerRegistry *mInstance;
243  QMap<QString, QgsMapLayer*> mMapLayers;
244  QSet<QgsMapLayer*> mOwnedLayers;
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...