#include <qgsmaplayerregistry.h>
Signals | |
void | layerWillBeRemoved (QString theLayerId) |
emitted when a layer is removed from the registry connected to main map canvas and overview map canvas remove() | |
void | layerWasAdded (QgsMapLayer *theMapLayer) |
emitted when a layer is added to the registry connected to main map canvas and overview map canvas addLayer() | |
void | removedAll () |
emitted when ALL layers are removed at once This could have been implemented by iteratively signalling layerWillBeRemoved() for each layer as it is removed. | |
Public Member Functions | |
int | count () |
~QgsMapLayerRegistry () | |
QgsMapLayer * | mapLayer (QString theLayerId) |
Retrieve a pointer to a loaded plugin by id. | |
QMap< QString, QgsMapLayer * > & | mapLayers () |
Retrieve the mapLayers collection (mainly intended for use by projectio). | |
QgsMapLayer * | addMapLayer (QgsMapLayer *theMapLayer, bool theEmitSignal=true) |
Add a layer to the map of loaded layers. | |
void | removeMapLayer (QString theLayerId, bool theEmitSignal=true) |
Remove a layer from qgis. | |
void | removeAllMapLayers () |
Remove all registered layers. | |
void | clearAllLayerCaches () |
void | reloadAllLayers () |
Reload all provider data caches (currently used for WFS and WMS providers). | |
Static Public Member Functions | |
static QgsMapLayerRegistry * | instance () |
Returns the instance pointer, creating the object on the first call. | |
Protected Member Functions | |
QgsMapLayerRegistry (QObject *parent=0) | |
protected constructor | |
Private Member Functions | |
void | connectNotify (const char *signal) |
debugging member invoked when a connect() is made to this object | |
Private Attributes | |
QMap< QString, QgsMapLayer * > | mMapLayers |
Static Private Attributes | |
static QgsMapLayerRegistry * | mInstance = 0 |
Definition at line 35 of file qgsmaplayerregistry.h.
QgsMapLayerRegistry::~QgsMapLayerRegistry | ( | ) |
QgsMapLayerRegistry::QgsMapLayerRegistry | ( | QObject * | parent = 0 |
) | [protected] |
protected constructor
Definition at line 42 of file qgsmaplayerregistry.cpp.
Referenced by instance().
QgsMapLayerRegistry * QgsMapLayerRegistry::instance | ( | ) | [static] |
Returns the instance pointer, creating the object on the first call.
Definition at line 29 of file qgsmaplayerregistry.cpp.
References mInstance, and QgsMapLayerRegistry().
Referenced by QgsProject::_getMapLayers(), QgsGeometry::avoidIntersections(), QgsComposerMap::connectUpdateSlot(), QgsComposerMap::containsWMSLayer(), QgsComposerLegend::drawLayerItem(), QgsApplication::exitQgis(), QgsApplication::initQgis(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsQuickPrint::printMap(), QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsLegendModel::QgsLegendModel(), QgsProject::read(), QgsRasterLayer::readFile(), QgsFormAnnotationItem::readXML(), QgsComposerRasterSymbolItem::readXML(), QgsComposerSymbolItem::readXML(), QgsComposerAttributeTable::readXML(), QgsPluginLayerRegistry::removePluginLayerType(), QgsMapRenderer::render(), QgsQuickPrint::scalePointSymbols(), QgsQuickPrint::scaleTextLabels(), QgsVectorLayer::setDataProvider(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsMapRenderer::updateFullExtent(), QgsLegendModel::updateLayer(), and QgsProject::write().
int QgsMapLayerRegistry::count | ( | ) |
Return the number of registered layers.
Definition at line 53 of file qgsmaplayerregistry.cpp.
References mMapLayers.
QgsMapLayer * QgsMapLayerRegistry::mapLayer | ( | QString | theLayerId | ) |
Retrieve a pointer to a loaded plugin by id.
Definition at line 58 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsGeometry::avoidIntersections(), QgsComposerMap::containsWMSLayer(), QgsComposerLegend::drawLayerItem(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsQuickPrint::printMap(), QgsFormAnnotationItem::readXML(), QgsComposerRasterSymbolItem::readXML(), QgsComposerSymbolItem::readXML(), QgsComposerAttributeTable::readXML(), QgsMapRenderer::render(), QgsQuickPrint::scalePointSymbols(), QgsQuickPrint::scaleTextLabels(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsMapRenderer::updateFullExtent(), and QgsLegendModel::updateLayer().
QMap< QString, QgsMapLayer * > & QgsMapLayerRegistry::mapLayers | ( | ) |
Retrieve the mapLayers collection (mainly intended for use by projectio).
Definition at line 143 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsPluginLayerRegistry::removePluginLayerType(), QgsVectorLayer::setDataProvider(), and QgsProject::write().
QgsMapLayer * QgsMapLayerRegistry::addMapLayer | ( | QgsMapLayer * | theMapLayer, | |
bool | theEmitSignal = true | |||
) |
Add a layer to the map of loaded layers.
Emits signal that layer has been added only if theEmitSignal is true (by default). Not emitting signal is useful when you want to use registry also for layers which won't be used in main map canvas but will be used in a special one
Definition at line 66 of file qgsmaplayerregistry.cpp.
References QgsMapLayer::getLayerID(), QgsMapLayer::isValid(), layerWasAdded(), mMapLayers, and QgsDebugMsg.
Referenced by QgsProject::_getMapLayers(), and QgsProject::read().
void QgsMapLayerRegistry::removeMapLayer | ( | QString | theLayerId, | |
bool | theEmitSignal = true | |||
) |
Remove a layer from qgis.
Definition at line 94 of file qgsmaplayerregistry.cpp.
References layerWillBeRemoved(), and mMapLayers.
Referenced by QgsPluginLayerRegistry::removePluginLayerType().
void QgsMapLayerRegistry::removeAllMapLayers | ( | ) |
Remove all registered layers.
The layers are deleted as the registry is cleared!
Definition at line 102 of file qgsmaplayerregistry.cpp.
References layerWillBeRemoved(), mMapLayers, and removedAll().
Referenced by ~QgsMapLayerRegistry().
void QgsMapLayerRegistry::clearAllLayerCaches | ( | ) |
Definition at line 120 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsMapRenderer::render().
void QgsMapLayerRegistry::reloadAllLayers | ( | ) |
Reload all provider data caches (currently used for WFS and WMS providers).
Definition at line 130 of file qgsmaplayerregistry.cpp.
References mMapLayers, and QgsMapLayer::reload().
void QgsMapLayerRegistry::layerWillBeRemoved | ( | QString | theLayerId | ) | [signal] |
emitted when a layer is removed from the registry connected to main map canvas and overview map canvas remove()
Referenced by removeAllMapLayers(), and removeMapLayer().
void QgsMapLayerRegistry::layerWasAdded | ( | QgsMapLayer * | theMapLayer | ) | [signal] |
emitted when a layer is added to the registry connected to main map canvas and overview map canvas addLayer()
Referenced by addMapLayer().
void QgsMapLayerRegistry::removedAll | ( | ) | [signal] |
emitted when ALL layers are removed at once This could have been implemented by iteratively signalling layerWillBeRemoved() for each layer as it is removed.
However, this generally causes a cascade of effects that are unnecessary if we're ultimately removing all layers. E.g., removing the legend item corresponding to the layer. Why bother doing that when you're just going to clear everything anyway?
Referenced by removeAllMapLayers().
void QgsMapLayerRegistry::connectNotify | ( | const char * | signal | ) | [private] |
debugging member invoked when a connect() is made to this object
Definition at line 150 of file qgsmaplayerregistry.cpp.
QgsMapLayerRegistry * QgsMapLayerRegistry::mInstance = 0 [static, private] |
QMap<QString, QgsMapLayer*> QgsMapLayerRegistry::mMapLayers [private] |
Definition at line 128 of file qgsmaplayerregistry.h.
Referenced by addMapLayer(), clearAllLayerCaches(), count(), mapLayer(), mapLayers(), reloadAllLayers(), removeAllMapLayers(), and removeMapLayer().