QGIS API Documentation  2.0.1-Dufour
 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 
77  QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
78  bool addToLegend = true,
79  bool takeOwnership = true );
80 
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 
153  void clearAllLayerCaches();
154 
160  void reloadAllLayers();
161 
162  signals:
168  void layersWillBeRemoved( QStringList theLayerIds );
169 
177  void layerWillBeRemoved( QString theLayerId );
178 
184  void layersRemoved( QStringList theLayerIds );
185 
193  void layerRemoved( QString theLayerId );
194 
195 
204  void removeAll();
205 
215  void layersAdded( QList<QgsMapLayer *> theMapLayers );
216 
224  void layerWasAdded( QgsMapLayer* theMapLayer );
225 
236  void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
237 
238  protected:
240  QgsMapLayerRegistry( QObject * parent = 0 );
241 
245  void connectNotify( const char * signal );
246 
247  private:
248 
250 
251  QMap<QString, QgsMapLayer*> mMapLayers;
252  QSet<QgsMapLayer*> mOwnedLayers;
253 
254 
255 
256 }; // class QgsMapLayerRegistry
257 
258 #endif //QgsMapLayerRegistry_H
259