QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 : [email protected]
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 
78  QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
79  bool addToLegend = true,
80  bool takeOwnership = true );
81 
107  QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true, bool takeOwnership = true );
108 
122  void removeMapLayers( QStringList theLayerIds );
123 
137  void removeMapLayer( const QString& theLayerId );
138 
145  void removeAllMapLayers();
146 
155  Q_DECL_DEPRECATED void clearAllLayerCaches();
157 
163  void reloadAllLayers();
164 
165  signals:
171  void layersWillBeRemoved( QStringList theLayerIds );
172 
180  void layerWillBeRemoved( QString theLayerId );
181 
187  void layersRemoved( QStringList theLayerIds );
188 
196  void layerRemoved( QString theLayerId );
197 
198 
207  void removeAll();
208 
218  void layersAdded( QList<QgsMapLayer *> theMapLayers );
219 
227  void layerWasAdded( QgsMapLayer* theMapLayer );
228 
239  void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
240 
241  protected:
243  QgsMapLayerRegistry( QObject * parent = 0 );
244 
248  void connectNotify( const char * signal );
249 
250  private:
252  QMap<QString, QgsMapLayer*> mMapLayers;
253  QSet<QgsMapLayer*> mOwnedLayers;
254 }; // class QgsMapLayerRegistry
255 
256 #endif //QgsMapLayerRegistry_H
257 
Base class for all map layer types.
Definition: qgsmaplayer.h:47
static QgsMapLayerRegistry * mInstance
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
QMap< QString, QgsMapLayer * > mMapLayers
QSet< QgsMapLayer * > mOwnedLayers