Quantum GIS API Documentation
1.8
|
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a map layer and delete it. More...
#include <qgsmaplayerregistry.h>
Signals | |
void | layersWillBeRemoved (QStringList theLayerIds) |
Emitted when one or more layers are removed from the registry. | |
void | layerWillBeRemoved (QString theLayerId) |
emitted when a layer is removed from the registry connected to main map canvas and overview map canvas remove() | |
void | layersAdded (QList< QgsMapLayer * > theMapLayers) |
Emitted when one or more layers are added to the registry. | |
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 layer by id. | |
QMap< QString, QgsMapLayer * > & | mapLayers () |
Retrieve the mapLayers collection (mainly intended for use by projectio) | |
Q_DECL_DEPRECATED QgsMapLayer * | addMapLayer (QgsMapLayer *theMapLayer, bool theEmitSignal=true) |
Add a layer to the map of loaded layers. | |
QList< QgsMapLayer * > | addMapLayers (QList< QgsMapLayer * > theMapLayers, bool theEmitSignal=true) |
Add a list of layers to the map of loaded layers. | |
Q_DECL_DEPRECATED void | removeMapLayer (QString theLayerId, bool theEmitSignal=true) |
Remove a layer from qgis. | |
void | removeMapLayers (QStringList theLayerIds, bool theEmitSignal=true) |
Remove a set of layers 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 |
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a map layer and delete it.
Definition at line 32 of file qgsmaplayerregistry.h.
Definition at line 44 of file qgsmaplayerregistry.cpp.
References removeAllMapLayers().
QgsMapLayerRegistry::QgsMapLayerRegistry | ( | QObject * | parent = 0 | ) | [protected] |
protected constructor
Definition at line 39 of file qgsmaplayerregistry.cpp.
Referenced by instance().
QgsMapLayer * QgsMapLayerRegistry::addMapLayer | ( | QgsMapLayer * | theMapLayer, |
bool | theEmitSignal = true |
||
) |
Add a layer to the map of loaded layers.
As a side-effect QgsProject is made dirty.
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 for layers on a different canvas and don't want them added to the main canvas automatically.
Definition at line 96 of file qgsmaplayerregistry.cpp.
References addMapLayers().
QList< QgsMapLayer * > QgsMapLayerRegistry::addMapLayers | ( | QList< QgsMapLayer * > | theMapLayers, |
bool | theEmitSignal = true |
||
) |
Add a list of layers to the map of loaded layers.
As a side-effect QgsProject is made dirty.
If theEmitSignal is true (by default), a layersAdded( QList<QgsMapLayer *>) signal will be emitted indicating that a batch of layers were added. Not emitting signal is useful when you want to use registry for layers on a different canvas and don't want them added to the main canvas automatically.
Definition at line 61 of file qgsmaplayerregistry.cpp.
References QgsMapLayer::id(), QgsMapLayer::isValid(), layersAdded(), layerWasAdded(), mMapLayers, and QgsDebugMsg.
Referenced by addMapLayer().
Definition at line 150 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsMapRenderer::render().
void QgsMapLayerRegistry::connectNotify | ( | const char * | signal | ) | [private] |
debugging member invoked when a connect() is made to this object
Definition at line 180 of file qgsmaplayerregistry.cpp.
int QgsMapLayerRegistry::count | ( | ) |
Return the number of registered layers.
Definition at line 50 of file qgsmaplayerregistry.cpp.
References mMapLayers.
QgsMapLayerRegistry * QgsMapLayerRegistry::instance | ( | ) | [static] |
Returns the instance pointer, creating the object on the first call.
Definition at line 26 of file qgsmaplayerregistry.cpp.
References mInstance, and QgsMapLayerRegistry().
Referenced by QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), QgsVectorLayer::addJoinedFeatureAttributes(), QgsGeometry::avoidIntersections(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsComposerMap::connectUpdateSlot(), QgsComposerMap::containsWMSLayer(), QgsAttributeEditor::createAttributeEditor(), QgsComposerLegend::drawLayerItem(), QgsApplication::exitQgis(), QgsApplication::initQgis(), QgsVectorLayerJoinBuffer::joinForFieldIndex(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsQuickPrint::printMap(), QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsLegendModel::QgsLegendModel(), QgsVectorLayer::QgsVectorLayer(), QgsFormAnnotationItem::readXML(), QgsComposerAttributeTable::readXML(), QgsComposerSymbolItem::readXML(), QgsVectorLayer::readXml(), QgsVectorLayerJoinBuffer::removeJoin(), QgsMapRenderer::render(), QgsQuickPrint::scalePointSymbols(), QgsQuickPrint::scaleTextLabels(), QgsVectorLayerJoinBuffer::select(), QgsLegendModel::setAutoUpdate(), QgsVectorLayer::setDataProvider(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsComposerMap::syncLayerSet(), QgsVectorLayer::uniqueValues(), QgsVectorLayerJoinBuffer::updateFeatureAttributes(), QgsVectorLayerJoinBuffer::updateFieldMap(), QgsMapRenderer::updateFullExtent(), and QgsLegendModel::updateLayer().
void QgsMapLayerRegistry::layersAdded | ( | QList< QgsMapLayer * > | theMapLayers | ) | [signal] |
Emitted when one or more layers are added to the registry.
Referenced by addMapLayers().
void QgsMapLayerRegistry::layersWillBeRemoved | ( | QStringList | theLayerIds | ) | [signal] |
Emitted when one or more layers are removed from the registry.
Referenced by removeMapLayers().
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 addMapLayers().
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 removeMapLayers().
QgsMapLayer * QgsMapLayerRegistry::mapLayer | ( | QString | theLayerId | ) |
Retrieve a pointer to a loaded layer by id.
Definition at line 55 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), QgsVectorLayer::addJoinedFeatureAttributes(), QgsGeometry::avoidIntersections(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsComposerMap::containsWMSLayer(), QgsAttributeEditor::createAttributeEditor(), QgsComposerLegend::drawLayerItem(), QgsVectorLayerJoinBuffer::joinForFieldIndex(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsQuickPrint::printMap(), QgsFormAnnotationItem::readXML(), QgsComposerAttributeTable::readXML(), QgsComposerSymbolItem::readXML(), QgsVectorLayerJoinBuffer::removeJoin(), QgsMapRenderer::render(), QgsQuickPrint::scalePointSymbols(), QgsQuickPrint::scaleTextLabels(), QgsVectorLayerJoinBuffer::select(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsVectorLayer::uniqueValues(), QgsVectorLayerJoinBuffer::updateFeatureAttributes(), QgsVectorLayerJoinBuffer::updateFieldMap(), QgsMapRenderer::updateFullExtent(), and QgsLegendModel::updateLayer().
QMap< QString, QgsMapLayer * > & QgsMapLayerRegistry::mapLayers | ( | ) |
Retrieve the mapLayers collection (mainly intended for use by projectio)
Definition at line 173 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsVectorLayer::setDataProvider(), and QgsComposerMap::syncLayerSet().
void QgsMapLayerRegistry::reloadAllLayers | ( | ) |
Reload all provider data caches (currently used for WFS and WMS providers)
Definition at line 160 of file qgsmaplayerregistry.cpp.
References mMapLayers, and QgsMapLayer::reload().
Remove all registered layers.
Definition at line 131 of file qgsmaplayerregistry.cpp.
References mMapLayers, removedAll(), and removeMapLayers().
Referenced by ~QgsMapLayerRegistry().
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::removeMapLayer | ( | QString | theLayerId, |
bool | theEmitSignal = true |
||
) |
Remove a layer from qgis.
If theEmitSignal is true (by default), a layerWillBeRemoved( QString theId ) signal will be emitted indicating to any listeners that the layer is being removed.
The layer being removed is deleted as well as the registry table entry.
Definition at line 123 of file qgsmaplayerregistry.cpp.
References removeMapLayers().
void QgsMapLayerRegistry::removeMapLayers | ( | QStringList | theLayerIds, |
bool | theEmitSignal = true |
||
) |
Remove a set of layers from qgis.
If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds ) signal will be emitted indicating to any listeners that the layers are being removed.
The layer being removed is deleted as well as the registry table entry.
Definition at line 106 of file qgsmaplayerregistry.cpp.
References layersWillBeRemoved(), layerWillBeRemoved(), and mMapLayers.
Referenced by removeAllMapLayers(), and removeMapLayer().
QgsMapLayerRegistry * QgsMapLayerRegistry::mInstance = 0 [static, private] |
Definition at line 169 of file qgsmaplayerregistry.h.
Referenced by instance().
QMap<QString, QgsMapLayer*> QgsMapLayerRegistry::mMapLayers [private] |
Definition at line 171 of file qgsmaplayerregistry.h.
Referenced by addMapLayers(), clearAllLayerCaches(), count(), mapLayer(), mapLayers(), reloadAllLayers(), removeAllMapLayers(), and removeMapLayers().