Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 : 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 /* $Id$ */
19 
20 #ifndef QGSMAPLAYERREGISTRY_H
21 #define QGSMAPLAYERREGISTRY_H
22 
23 #include <QMap>
24 #include <QObject>
25 
26 class QString;
27 class QStringList;
28 
29 class QgsMapLayer;
30 
35 class CORE_EXPORT QgsMapLayerRegistry : public QObject
36 {
37  Q_OBJECT
38 
39  public:
40 
42  static QgsMapLayerRegistry * instance();
46  int count();
47 
49 
51  QgsMapLayer * mapLayer( QString theLayerId );
52 
54  QMap<QString, QgsMapLayer*> & mapLayers();
55 
66  QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );
67 
76  void removeMapLayer( QString theLayerId, bool theEmitSignal = true );
77 
83  void removeAllMapLayers();
84 
85  /* Clears all layer caches, resetting them to zero and
86  * freeing up any memory they may have been using. Layer
87  * caches are used to speed up rendering in certain situations
88  * see ticket #1974 for more details.
89  * @note this method was added in QGIS 1.4
90  */
91  void clearAllLayerCaches();
92 
95  void reloadAllLayers();
96 
97  signals:
98 
102  void layerWillBeRemoved( QString theLayerId );
103 
107  void layerWasAdded( QgsMapLayer * theMapLayer );
108 
117  void removedAll();
118 
119  protected:
120 
122  QgsMapLayerRegistry( QObject * parent = 0 );
123 
124  private:
125 
127 
128  QMap<QString, QgsMapLayer*> mMapLayers;
129 
133  void connectNotify( const char * signal );
134 
135 
136 }; // class QgsMapLayerRegistry
137 
138 #endif //QgsMapLayerRegistry_H
139