QgsMapLayerRegistry Class Reference
[Core]

#include <qgsmaplayerregistry.h>

Collaboration diagram for QgsMapLayerRegistry:

Collaboration graph
[legend]
List of all members.

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.

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 ()
QgsMapLayermapLayer (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).
QgsMapLayeraddMapLayer (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.

Static Public Member Functions

static QgsMapLayerRegistryinstance ()
 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 QgsMapLayerRegistrymInstance


Constructor & Destructor Documentation

QgsMapLayerRegistry::~QgsMapLayerRegistry (  ) 

Definition at line 48 of file qgsmaplayerregistry.cpp.

References removeAllMapLayers().

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

protected constructor

Definition at line 43 of file qgsmaplayerregistry.cpp.

Referenced by instance().


Member Function Documentation

QgsMapLayerRegistry * QgsMapLayerRegistry::instance (  )  [static]

Returns the instance pointer, creating the object on the first call.

Definition at line 30 of file qgsmaplayerregistry.cpp.

References mInstance, and QgsMapLayerRegistry().

Referenced by _getMapLayers(), QgsComposerMap::connectUpdateSlot(), QgsComposerMap::containsWMSLayer(), QgsApplication::exitQgis(), QgsApplication::initQgis(), QgsMapCanvas::layer(), QgsComposerLegend::layerIdList(), QgsQuickPrint::printMap(), QgsLegendModel::QgsLegendModel(), QgsProject::read(), QgsRasterLayer::readFile(), QgsLegendModel::readXML(), QgsMapRenderer::render(), QgsQuickPrint::scalePointSymbols(), QgsQuickPrint::scaleTextLabels(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsMapRenderer::updateFullExtent(), QgsLegendModel::updateLayer(), QgsLegendModel::updateRasterClassificationItem(), QgsLegendModel::updateVectorClassificationItem(), and QgsProject::write().

int QgsMapLayerRegistry::count (  ) 

Return the number of registered layers.

Definition at line 54 of file qgsmaplayerregistry.cpp.

References mMapLayers.

QgsMapLayer * QgsMapLayerRegistry::mapLayer ( QString  theLayerId  ) 

Retrieve a pointer to a loaded plugin by id.

Definition at line 59 of file qgsmaplayerregistry.cpp.

References mMapLayers.

Referenced by QgsComposerMap::containsWMSLayer(), QgsMapCanvas::layer(), QgsQuickPrint::printMap(), QgsLegendModel::readXML(), QgsMapRenderer::render(), QgsQuickPrint::scalePointSymbols(), QgsQuickPrint::scaleTextLabels(), QgsLegendModel::setLayerSet(), QgsMapCanvasSnapper::snapToBackgroundLayers(), QgsMapRenderer::updateFullExtent(), QgsLegendModel::updateLayer(), QgsLegendModel::updateRasterClassificationItem(), and QgsLegendModel::updateVectorClassificationItem().

QMap< QString, QgsMapLayer * > & QgsMapLayerRegistry::mapLayers (  ) 

Retrieve the mapLayers collection (mainly intended for use by projectio).

Definition at line 122 of file qgsmaplayerregistry.cpp.

References mMapLayers.

Referenced by QgsComposerLegend::layerIdList(), and QgsProject::write().

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 67 of file qgsmaplayerregistry.cpp.

References QgsMapLayer::getLayerID(), QgsMapLayer::isValid(), layerWasAdded(), mMapLayers, and QgsDebugMsg.

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

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 95 of file qgsmaplayerregistry.cpp.

References layerWillBeRemoved(), and mMapLayers.

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 103 of file qgsmaplayerregistry.cpp.

References layerWillBeRemoved(), mMapLayers, and removedAll().

Referenced by ~QgsMapLayerRegistry().

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 129 of file qgsmaplayerregistry.cpp.


Member Data Documentation

QgsMapLayerRegistry * QgsMapLayerRegistry::mInstance [static, private]

Definition at line 114 of file qgsmaplayerregistry.h.

Referenced by instance().

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

Definition at line 116 of file qgsmaplayerregistry.h.

Referenced by addMapLayer(), count(), mapLayer(), mapLayers(), removeAllMapLayers(), and removeMapLayer().


The documentation for this class was generated from the following files:
Generated on Tue Jan 6 16:51:21 2009 for Quantum GIS API Documentation by  doxygen 1.5.1