mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -05:00
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6415 c8812cc2-4d05-0410-92ff-de0c093fc19c
98 lines
2.6 KiB
Plaintext
98 lines
2.6 KiB
Plaintext
|
|
/**
|
|
* \class QgsMapLayerRegistry
|
|
* \brief This class tracks map layers that are currently loaded an provides
|
|
* a means to fetch a pointer to a map layer and delete it
|
|
*/
|
|
class QgsMapLayerRegistry : QObject
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsmaplayerregistry.h>
|
|
%End
|
|
|
|
public:
|
|
|
|
//! Returns the instance pointer, creating the object on the first call
|
|
static QgsMapLayerRegistry * instance();
|
|
/*! Return the number of registered layers.
|
|
*
|
|
* */
|
|
const int count();
|
|
|
|
~QgsMapLayerRegistry();
|
|
|
|
//! Retrieve a pointer to a loaded plugin by id
|
|
QgsMapLayer * mapLayer(QString theLayerId);
|
|
|
|
//! Retrieve the mapLayers collection (mainly intended for use by projectio)
|
|
// TODO: wrap
|
|
//std::map<QString,QgsMapLayer*> & mapLayers();
|
|
|
|
/** 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
|
|
*/
|
|
QgsMapLayer * addMapLayer(QgsMapLayer * theMapLayer /Transfer/, 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()
|
|
*/
|
|
void removeMapLayer(QString theLayerId, bool theEmitSignal = TRUE);
|
|
|
|
/** Remove all registered layers
|
|
|
|
@note raises removedAll()
|
|
|
|
As a side-effect QgsProject is made dirty.
|
|
|
|
*/
|
|
void removeAllMapLayers();
|
|
|
|
signals:
|
|
|
|
/** emitted when a layer is removed from the registry
|
|
|
|
connected to main map canvas and overview map canvas remove()
|
|
*/
|
|
void layerWillBeRemoved(QString theLayerId);
|
|
|
|
/** emitted when a layer is added to the registry
|
|
|
|
connected to main map canvas and overview map canvas addLayer()
|
|
*/
|
|
void layerWasAdded(QgsMapLayer * theMapLayer);
|
|
|
|
/** 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?
|
|
|
|
*/
|
|
void removedAll();
|
|
|
|
protected:
|
|
|
|
//! protected constructor
|
|
QgsMapLayerRegistry( QObject * parent = 0, const char * name = 0 );
|
|
|
|
|
|
}; // class QgsMapLayerRegistry
|
|
|