QGIS API Documentation
2.2.0-Valmiera
|
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. | |
void | layersRemoved (QStringList theLayerIds) |
Emitted after one or more layers were removed from the registry. | |
void | layerRemoved (QString theLayerId) |
Emitted after a layer was removed from the registry. | |
void | removeAll () |
Emitted, when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals are emitted. | |
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. | |
void | legendLayersAdded (QList< QgsMapLayer * > theMapLayers) |
Emitted, when a layer is added to the registry and the legend. |
Public Member Functions | |
int | count () |
Return the number of registered layers. | |
~QgsMapLayerRegistry () | |
QgsMapLayer * | mapLayer (QString theLayerId) |
Retrieve a pointer to a loaded layer by id. | |
QList< QgsMapLayer * > | mapLayersByName (QString layerName) |
Retrieve a pointer to a loaded layer by name. | |
const QMap< QString, QgsMapLayer * > & | mapLayers () |
Retrieve the mapLayers collection (mainly intended for use by projection) | |
QList< QgsMapLayer * > | addMapLayers (QList< QgsMapLayer * > theMapLayers, bool addToLegend=true, bool takeOwnership=true) |
Add a list of layers to the map of loaded layers. | |
QgsMapLayer * | addMapLayer (QgsMapLayer *theMapLayer, bool addToLegend=true, bool takeOwnership=true) |
Add a layer to the map of loaded layers. | |
void | removeMapLayers (QStringList theLayerIds) |
Remove a set of layers from the registry. | |
void | removeMapLayer (const QString &theLayerId) |
Remove a layer from qgis. | |
void | removeAllMapLayers () |
Remove all registered layers. | |
void | clearAllLayerCaches () |
Clears all layer caches, resetting them to zero and freeing up any memory they may have been using. | |
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 | |
void | connectNotify (const char *signal) |
debugging member invoked when a connect() is made to this object |
Private Attributes | |
QMap< QString, QgsMapLayer * > | mMapLayers |
QSet< QgsMapLayer * > | mOwnedLayers |
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 33 of file qgsmaplayerregistry.h.
QgsMapLayerRegistry::~QgsMapLayerRegistry | ( | ) |
Definition at line 44 of file qgsmaplayerregistry.cpp.
References removeAllMapLayers().
|
protected |
protected constructor
Definition at line 39 of file qgsmaplayerregistry.cpp.
Referenced by instance().
QgsMapLayer * QgsMapLayerRegistry::addMapLayer | ( | QgsMapLayer * | theMapLayer, |
bool | addToLegend = true , |
||
bool | takeOwnership = true |
||
) |
Add a layer to the map of loaded layers.
The layersAdded() and layersWasAdded() signals will be emitted in any case. The legendLayersAdded() signal only if addToLegend is true. If you are adding multiple layers at once, you should use addMapLayers() instead.
theMapLayer | A layer to add to the registry |
addToLegend | If true (by default), the layer will be added to the legend and to the main canvas. If you have a private you can set this parameter to false to hide it. |
takeOwnership | Ownership will be transferred to the layer registry. If you specify false here, you have take care of deleting the layer yourself. Not available in python. |
Definition at line 110 of file qgsmaplayerregistry.cpp.
References addMapLayers().
QList< QgsMapLayer * > QgsMapLayerRegistry::addMapLayers | ( | QList< QgsMapLayer * > | theMapLayers, |
bool | addToLegend = true , |
||
bool | takeOwnership = true |
||
) |
Add a list of layers to the map of loaded layers.
The layersAdded() and layersWasAdded() signals will be emitted in any case. The legendLayersAdded() signal only if addToLegend is true.
theMapLayers | A list of layer which should be added to the registry |
addToLegend | If true (by default), the layers will be added to the legend and to the main canvas. If you have a private layer, you can set this parameter to false to hide it. |
takeOwnership | Ownership will be transferred to the layer registry. If you specify false here, you have take care of deleting the layers yourself. Not available in python. |
Definition at line 74 of file qgsmaplayerregistry.cpp.
References QgsMapLayer::id(), QgsMapLayer::isValid(), layersAdded(), layerWasAdded(), legendLayersAdded(), mMapLayers, mOwnedLayers, and QgsDebugMsg.
Referenced by addMapLayer(), QgsOfflineEditing::copyVectorLayer(), and QgsOfflineEditing::synchronize().
void QgsMapLayerRegistry::clearAllLayerCaches | ( | ) |
Clears all layer caches, resetting them to zero and freeing up any memory they may have been using.
Layer caches are used to speed up rendering in certain situations see ticket #1974 for more details.
Definition at line 155 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsMapRenderer::render().
|
protected |
debugging member invoked when a connect() is made to this object
Definition at line 185 of file qgsmaplayerregistry.cpp.
int QgsMapLayerRegistry::count | ( | ) |
Return the number of registered layers.
Definition at line 50 of file qgsmaplayerregistry.cpp.
References mMapLayers.
|
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 QgsGeometry::avoidIntersections(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsOfflineEditing::committedFeaturesAdded(), QgsComposerMap::connectUpdateSlot(), QgsComposerMap::containsAdvancedEffects(), QgsComposerMap::containsWMSLayer(), QgsOfflineEditing::convertToOfflineProject(), QgsOfflineEditing::copyVectorLayer(), QgsAttributeEditor::createAttributeEditor(), QgsRelation::createFromXML(), QgsComposerLegend::drawSymbolItem(), QgsApplication::exitQgis(), QgsMapToolIdentify::handleMenuHover(), QgsMapToolIdentify::identify(), QgsApplication::initQgis(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsAttributeTableModel::loadAttributes(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsLegendModel::QgsLegendModel(), QgsOfflineEditing::QgsOfflineEditing(), QgsVectorLayer::QgsVectorLayer(), QgsHtmlAnnotationItem::readXML(), QgsFormAnnotationItem::readXML(), QgsComposerAttributeTable::readXML(), QgsAtlasComposition::readXML(), QgsVectorLayer::readXml(), QgsMapRenderer::render(), QgsLegendModel::setAutoUpdate(), QgsVectorLayer::setDataProvider(), QgsComposerLayerItem::setDefaultStyle(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsOfflineEditing::synchronize(), QgsComposerMap::syncLayerSet(), QgsVectorLayer::uniqueValues(), QgsVectorLayerJoinBuffer::updateFields(), QgsMapRenderer::updateFullExtent(), QgsLegendModel::updateLayer(), QgsLegendModel::updateLayerItemText(), QgsLegendModel::updateRasterSymbolItemText(), QgsRelation::updateRelationStatus(), and QgsLegendModel::updateSymbolV2ItemText().
|
signal |
Emitted after a layer was removed from the registry.
theLayerId | The id of the layer removed |
Referenced by removeMapLayers().
|
signal |
Emitted when one or more layers are added to the registry.
This signal is also emitted for layers added to the registry, but not to the legend and canvas.
theMapLayers | The layers which have been added |
Referenced by addMapLayers().
|
signal |
Emitted after one or more layers were removed from the registry.
theLayerIds | A list of ids of the layers which were removed. |
Referenced by removeMapLayers().
|
signal |
Emitted when one or more layers are removed from the registry.
theLayerIds | A list of ids of the layers which are removed. |
Referenced by removeMapLayers().
|
signal |
Emitted when a layer is added to the registry.
theMapLayer | The id of the layer which has been added |
Referenced by addMapLayers().
|
signal |
Emitted when a layer is removed from the registry.
theLayerId | The id of the layer being removed |
Referenced by removeMapLayers().
|
signal |
Emitted, when a layer is added to the registry and the legend.
Plugins are allowed to have private layers, which are signalled by layersAdded() and layerWasAdded() but will not be advertised by this signal.
theMapLayers | The QgsMapLayers which are added to the legend. |
Referenced by addMapLayers().
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 QgsGeometry::avoidIntersections(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsOfflineEditing::committedFeaturesAdded(), QgsComposerMap::containsAdvancedEffects(), QgsComposerMap::containsWMSLayer(), QgsOfflineEditing::convertToOfflineProject(), QgsAttributeEditor::createAttributeEditor(), QgsComposerLegend::drawSymbolItem(), QgsMapToolIdentify::handleMenuHover(), QgsMapToolIdentify::identify(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsAttributeTableModel::loadAttributes(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsFormAnnotationItem::readXML(), QgsHtmlAnnotationItem::readXML(), QgsComposerAttributeTable::readXML(), QgsMapRenderer::render(), QgsComposerLayerItem::setDefaultStyle(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsVectorLayer::uniqueValues(), QgsVectorLayerJoinBuffer::updateFields(), QgsMapRenderer::updateFullExtent(), QgsLegendModel::updateLayer(), QgsLegendModel::updateLayerItemText(), QgsLegendModel::updateRasterSymbolItemText(), and QgsLegendModel::updateSymbolV2ItemText().
const QMap< QString, QgsMapLayer * > & QgsMapLayerRegistry::mapLayers | ( | ) |
Retrieve the mapLayers collection (mainly intended for use by projection)
Definition at line 178 of file qgsmaplayerregistry.cpp.
References mMapLayers.
Referenced by QgsRelation::createFromXML(), QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsAtlasComposition::readXML(), QgsVectorLayer::setDataProvider(), QgsOfflineEditing::synchronize(), QgsComposerMap::syncLayerSet(), and QgsRelation::updateRelationStatus().
QList< QgsMapLayer * > QgsMapLayerRegistry::mapLayersByName | ( | QString | layerName | ) |
Retrieve a pointer to a loaded layer by name.
Definition at line 60 of file qgsmaplayerregistry.cpp.
References mMapLayers, and QgsMapLayer::name().
void QgsMapLayerRegistry::reloadAllLayers | ( | ) |
Reload all provider data caches (currently used for WFS and WMS providers)
Definition at line 165 of file qgsmaplayerregistry.cpp.
References mMapLayers, and QgsMapLayer::reload().
|
signal |
Emitted, when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals are emitted.
You will still get these signals in any case. You can use this signal to do easy (and fast) cleanup.
Referenced by removeAllMapLayers().
void QgsMapLayerRegistry::removeAllMapLayers | ( | ) |
Remove all registered layers.
Definition at line 145 of file qgsmaplayerregistry.cpp.
References mMapLayers, removeAll(), and removeMapLayers().
Referenced by ~QgsMapLayerRegistry().
void QgsMapLayerRegistry::removeMapLayer | ( | const QString & | theLayerId | ) |
Remove a layer from qgis.
Any canvases using the affected layers will need to remove them
The layer being removed is deleted as well as the registry table entry.
theLayerId | The id of the layer to remove |
Definition at line 140 of file qgsmaplayerregistry.cpp.
References removeMapLayers().
void QgsMapLayerRegistry::removeMapLayers | ( | QStringList | theLayerIds | ) |
Remove a set of layers from the registry.
Any canvases using the affected layers will need to remove them
The layers being removed are deleted as well as the registry table entries.
theLayerIds | The ids of the layers to remove |
Definition at line 121 of file qgsmaplayerregistry.cpp.
References layerRemoved(), layersRemoved(), layersWillBeRemoved(), layerWillBeRemoved(), mMapLayers, and mOwnedLayers.
Referenced by QgsOfflineEditing::copyVectorLayer(), removeAllMapLayers(), removeMapLayer(), and QgsOfflineEditing::synchronize().
|
staticprivate |
Definition at line 250 of file qgsmaplayerregistry.h.
Referenced by instance().
|
private |
Definition at line 251 of file qgsmaplayerregistry.h.
Referenced by addMapLayers(), clearAllLayerCaches(), count(), mapLayer(), mapLayers(), mapLayersByName(), reloadAllLayers(), removeAllMapLayers(), and removeMapLayers().
|
private |
Definition at line 252 of file qgsmaplayerregistry.h.
Referenced by addMapLayers(), and removeMapLayers().