QGIS API Documentation  2.2.0-Valmiera
 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  void clearAllLayerCaches();
156 
162  void reloadAllLayers();
163 
164  signals:
170  void layersWillBeRemoved( QStringList theLayerIds );
171 
179  void layerWillBeRemoved( QString theLayerId );
180 
186  void layersRemoved( QStringList theLayerIds );
187 
195  void layerRemoved( QString theLayerId );
196 
197 
206  void removeAll();
207 
217  void layersAdded( QList<QgsMapLayer *> theMapLayers );
218 
226  void layerWasAdded( QgsMapLayer* theMapLayer );
227 
238  void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
239 
240  protected:
242  QgsMapLayerRegistry( QObject * parent = 0 );
243 
247  void connectNotify( const char * signal );
248 
249  private:
251  QMap<QString, QgsMapLayer*> mMapLayers;
252  QSet<QgsMapLayer*> mOwnedLayers;
253 }; // class QgsMapLayerRegistry
254 
255 #endif //QgsMapLayerRegistry_H
256