3
* \class QgsMapLayerRegistry
4
* \brief This class tracks map layers that are currently loaded an provides
5
* a means to fetch a pointer to a map layer and delete it
7
class QgsMapLayerRegistry : QObject
10
#include <qgsmaplayerregistry.h>
15
//! Returns the instance pointer, creating the object on the first call
16
static QgsMapLayerRegistry * instance();
18
//! Return the number of registered layers.
21
~QgsMapLayerRegistry();
23
//! Retrieve a pointer to a loaded plugin by id
24
QgsMapLayer * mapLayer(QString theLayerId);
26
//! Retrieve the mapLayers collection (mainly intended for use by projection)
27
QMap<QString,QgsMapLayer*> & mapLayers();
29
/** Add a layer to the map of loaded layers
30
@returns NULL if unable to add layer, otherwise pointer to newly added layer
33
As a side-effect QgsProject is made dirty.
35
Emits signal that layer has been added only if theEmitSignal is true (by default).
36
Not emitting signal is useful when you want to use registry also for layers
37
which won't be used in main map canvas but will be used in a special one
39
QgsMapLayer * addMapLayer(QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = TRUE);
41
/** Remove a layer from qgis
45
As a side-effect QgsProject is made dirty.
47
Any canvases using that layer will need to remove it
49
theEmitSignal - see addMapLayer()
51
void removeMapLayer(QString theLayerId, bool theEmitSignal = TRUE);
53
/** Remove all registered layers
55
@note raises removedAll()
57
As a side-effect QgsProject is made dirty.
60
void removeAllMapLayers();
62
/* Clears all layer caches, resetting them to zero and
63
* freeing up any memory they may have been using. Layer
64
* caches are used to speed up rendering in certain situations
65
* see ticket #1974 for more details.
66
* @note this method was added in QGIS 1.4
68
void clearAllLayerCaches();
72
/** emitted when a layer is removed from the registry
74
connected to main map canvas and overview map canvas remove()
76
void layerWillBeRemoved(QString theLayerId);
78
/** emitted when a layer is added to the registry
80
connected to main map canvas and overview map canvas addLayer()
82
void layerWasAdded(QgsMapLayer * theMapLayer);
84
/** emitted when ALL layers are removed at once
86
This could have been implemented by iteratively signalling
87
layerWillBeRemoved() for each layer as it is removed. However, this
88
generally causes a cascade of effects that are unnecessary if we're
89
ultimately removing all layers. E.g., removing the legend item
90
corresponding to the layer. Why bother doing that when you're just going
91
to clear everything anyway?
98
//! protected constructor
99
QgsMapLayerRegistry( QObject * parent = 0 );
102
}; // class QgsMapLayerRegistry