Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
QgsMapLayerRegistry Class Reference

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>

Inheritance diagram for QgsMapLayerRegistry:
Inheritance graph
[legend]
Collaboration diagram for QgsMapLayerRegistry:
Collaboration graph
[legend]

Signals

void layerWillBeRemoved (QString theLayerId)
 emitted when a layer is removed from the registry connected to main map canvas and overview map canvas remove() More...
 
void layerWasAdded (QgsMapLayer *theMapLayer)
 emitted when a layer is added to the registry connected to main map canvas and overview map canvas addLayer() More...
 
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. More...
 

Public Member Functions

int count ()
 
 ~QgsMapLayerRegistry ()
 
QgsMapLayermapLayer (QString theLayerId)
 Retrieve a pointer to a loaded plugin by id. More...
 
QMap< QString, QgsMapLayer * > & mapLayers ()
 Retrieve the mapLayers collection (mainly intended for use by projectio) More...
 
QgsMapLayeraddMapLayer (QgsMapLayer *theMapLayer, bool theEmitSignal=true)
 Add a layer to the map of loaded layers. More...
 
void removeMapLayer (QString theLayerId, bool theEmitSignal=true)
 Remove a layer from qgis. More...
 
void removeAllMapLayers ()
 Remove all registered layers. More...
 
void clearAllLayerCaches ()
 
void reloadAllLayers ()
 Reload all provider data caches (currently used for WFS and WMS providers) More...
 

Static Public Member Functions

static QgsMapLayerRegistryinstance ()
 Returns the instance pointer, creating the object on the first call. More...
 

Protected Member Functions

 QgsMapLayerRegistry (QObject *parent=0)
 protected constructor More...
 
void connectNotify (const char *signal)
 debugging member invoked when a connect() is made to this object More...
 

Private Attributes

QMap< QString, QgsMapLayer * > mMapLayers
 

Static Private Attributes

static QgsMapLayerRegistrymInstance = 0
 

Detailed Description

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 35 of file qgsmaplayerregistry.h.

Constructor & Destructor Documentation

QgsMapLayerRegistry::~QgsMapLayerRegistry ( )

Definition at line 47 of file qgsmaplayerregistry.cpp.

References removeAllMapLayers().

QgsMapLayerRegistry::QgsMapLayerRegistry ( QObject *  parent = 0)
protected

protected constructor

Definition at line 42 of file qgsmaplayerregistry.cpp.

Referenced by instance().

Member Function Documentation

QgsMapLayer * QgsMapLayerRegistry::addMapLayer ( QgsMapLayer theMapLayer,
bool  theEmitSignal = true 
)

Add a layer to the map of loaded layers.

Returns
NULL if unable to add layer, otherwise pointer to newly added layer
Note

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 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::id(), QgsMapLayer::isValid(), layerWasAdded(), mMapLayers, and QgsDebugMsg.

Referenced by QgsProject::_getMapLayers(), and QgsProject::read().

void QgsMapLayerRegistry::clearAllLayerCaches ( )

Definition at line 121 of file qgsmaplayerregistry.cpp.

References mMapLayers.

Referenced by QgsMapRenderer::render().

void QgsMapLayerRegistry::connectNotify ( const char *  signal)
protected

debugging member invoked when a connect() is made to this object

Definition at line 151 of file qgsmaplayerregistry.cpp.

int QgsMapLayerRegistry::count ( )

Return the number of registered layers.

Definition at line 53 of file qgsmaplayerregistry.cpp.

References mMapLayers.

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(), QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), QgsVectorLayer::addJoinedFeatureAttributes(), QgsGeometry::avoidIntersections(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsComposerMap::connectUpdateSlot(), QgsComposerMap::containsWMSLayer(), QgsComposerLegend::drawLayerItem(), QgsApplication::exitQgis(), QgsApplication::initQgis(), QgsVectorLayerJoinBuffer::joinForFieldIndex(), QgsMapCanvas::layer(), QgsMapCanvas::layers(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsQuickPrint::printMap(), QgsComposerAttributeTable::QgsComposerAttributeTable(), QgsLegendModel::QgsLegendModel(), QgsVectorLayer::QgsVectorLayer(), QgsProject::read(), QgsFormAnnotationItem::readXML(), QgsComposerAttributeTable::readXML(), QgsComposerSymbolItem::readXML(), QgsVectorLayerJoinBuffer::removeJoin(), QgsPluginLayerRegistry::removePluginLayerType(), 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(), QgsLegendModel::updateLayer(), and QgsProject::write().

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::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().

QgsMapLayer * QgsMapLayerRegistry::mapLayer ( QString  theLayerId)
QMap< QString, QgsMapLayer * > & QgsMapLayerRegistry::mapLayers ( )
void QgsMapLayerRegistry::reloadAllLayers ( )

Reload all provider data caches (currently used for WFS and WMS providers)

Note
: this method was added in QGIS 1.6

Definition at line 131 of file qgsmaplayerregistry.cpp.

References mMapLayers, and QgsMapLayer::reload().

void QgsMapLayerRegistry::removeAllMapLayers ( )

Remove all registered layers.

Note
raises removedAll() As a side-effect QgsProject is made dirty.
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::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.

Note
As a side-effect QgsProject is made dirty. Any canvases using that layer will need to remove it theEmitSignal - see addMapLayer() The layer being removed is deleted as well as the registry table entry.

Definition at line 94 of file qgsmaplayerregistry.cpp.

References layerWillBeRemoved(), and mMapLayers.

Referenced by QgsPluginLayerRegistry::removePluginLayerType().

Member Data Documentation

QgsMapLayerRegistry * QgsMapLayerRegistry::mInstance = 0
staticprivate

Definition at line 131 of file qgsmaplayerregistry.h.

Referenced by instance().

QMap<QString, QgsMapLayer*> QgsMapLayerRegistry::mMapLayers
private

The documentation for this class was generated from the following files: