QGIS API Documentation
2.14.0-Essen
|
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 | layerRemoved (const QString &theLayerId) |
Emitted after a layer was removed from the registry. More... | |
void | layersAdded (const QList< QgsMapLayer * > &theMapLayers) |
Emitted when one or more layers are added to the registry. More... | |
void | layersRemoved (const QStringList &theLayerIds) |
Emitted after one or more layers were removed from the registry. More... | |
void | layersWillBeRemoved (const QStringList &theLayerIds) |
Emitted when one or more layers are removed from the registry. More... | |
void | layersWillBeRemoved (const QList< QgsMapLayer * > &layers) |
Emitted when one or more layers are removed from the registry. More... | |
void | layerWasAdded (QgsMapLayer *theMapLayer) |
Emitted when a layer is added to the registry. More... | |
void | layerWillBeRemoved (const QString &theLayerId) |
Emitted when an owned layer is removed from the registry. More... | |
void | layerWillBeRemoved (QgsMapLayer *layer) |
Emitted when an owned layer is removed from the registry. More... | |
void | legendLayersAdded (const QList< QgsMapLayer * > &theMapLayers) |
Emitted, when a layer is added to the registry and the legend. More... | |
void | removeAll () |
Emitted, when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals are emitted. More... | |
Public Member Functions | |
~QgsMapLayerRegistry () | |
QgsMapLayer * | addMapLayer (QgsMapLayer *theMapLayer, bool addToLegend=true, bool takeOwnership=true) |
Add a layer to the map of loaded layers. More... | |
QList< QgsMapLayer * > | addMapLayers (const QList< QgsMapLayer * > &theMapLayers, bool addToLegend=true, bool takeOwnership=true) |
Add a list of layers to the map of loaded layers. More... | |
Q_DECL_DEPRECATED void | clearAllLayerCaches () |
Clears all layer caches, resetting them to zero and freeing up any memory they may have been using. More... | |
int | count () |
Return the number of registered layers. More... | |
QgsMapLayer * | mapLayer (const QString &theLayerId) |
Retrieve a pointer to a loaded layer by id. More... | |
const QMap< QString, QgsMapLayer * > & | mapLayers () |
Retrieve the mapLayers collection (mainly intended for use by projection) More... | |
QList< QgsMapLayer * > | mapLayersByName (const QString &layerName) |
Retrieve a pointer to a loaded layer by name. More... | |
void | reloadAllLayers () |
Reload all provider data caches (currently used for WFS and WMS providers) More... | |
void | removeAllMapLayers () |
Remove all registered layers. More... | |
void | removeMapLayer (const QString &theLayerId) |
Remove a layer from qgis. More... | |
void | removeMapLayer (QgsMapLayer *layer) |
Remove a layer from qgis. More... | |
void | removeMapLayers (const QStringList &theLayerIds) |
Remove a set of layers from the registry. More... | |
void | removeMapLayers (const QList< QgsMapLayer * > &layers) |
Remove a set of layers from the registry. More... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Static Public Member Functions | |
static QgsMapLayerRegistry * | instance () |
Returns the instance pointer, creating the object on the first call. More... | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Additional Inherited Members | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
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 40 of file qgsmaplayerregistry.cpp.
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 106 of file qgsmaplayerregistry.cpp.
QList< QgsMapLayer * > QgsMapLayerRegistry::addMapLayers | ( | const 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 70 of file qgsmaplayerregistry.cpp.
|
inline |
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 183 of file qgsmaplayerregistry.h.
int QgsMapLayerRegistry::count | ( | ) |
Return the number of registered layers.
Definition at line 46 of file qgsmaplayerregistry.cpp.
|
static |
Returns the instance pointer, creating the object on the first call.
Definition at line 25 of file qgsmaplayerregistry.cpp.
|
signal |
Emitted after a layer was removed from the registry.
theLayerId | The id of the layer removed |
|
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 |
|
signal |
Emitted after one or more layers were removed from the registry.
theLayerIds | A list of ids of the layers which were removed. |
|
signal |
Emitted when one or more layers are removed from the registry.
theLayerIds | A list of ids of the layers which are removed. |
|
signal |
Emitted when one or more layers are removed from the registry.
layers | A list of layers which are removed. |
|
signal |
Emitted when a layer is added to the registry.
theMapLayer | The id of the layer which has been added |
|
signal |
Emitted when an owned layer is removed from the registry.
theLayerId | The id of the layer being removed |
|
signal |
Emitted when an owned layer is removed from the registry.
layer | The layer being removed |
|
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. |
QgsMapLayer * QgsMapLayerRegistry::mapLayer | ( | const QString & | theLayerId | ) |
Retrieve a pointer to a loaded layer by id.
Definition at line 51 of file qgsmaplayerregistry.cpp.
const QMap< QString, QgsMapLayer * > & QgsMapLayerRegistry::mapLayers | ( | ) |
Retrieve the mapLayers collection (mainly intended for use by projection)
Definition at line 194 of file qgsmaplayerregistry.cpp.
QList< QgsMapLayer * > QgsMapLayerRegistry::mapLayersByName | ( | const QString & | layerName | ) |
Retrieve a pointer to a loaded layer by name.
Definition at line 56 of file qgsmaplayerregistry.cpp.
void QgsMapLayerRegistry::reloadAllLayers | ( | ) |
Reload all provider data caches (currently used for WFS and WMS providers)
Definition at line 181 of file qgsmaplayerregistry.cpp.
|
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.
void QgsMapLayerRegistry::removeAllMapLayers | ( | ) |
Remove all registered layers.
Definition at line 172 of file qgsmaplayerregistry.cpp.
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 161 of file qgsmaplayerregistry.cpp.
void QgsMapLayerRegistry::removeMapLayer | ( | QgsMapLayer * | layer | ) |
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.
layer | The layer to remove. Nothing happens if the pointer is null |
Definition at line 166 of file qgsmaplayerregistry.cpp.
void QgsMapLayerRegistry::removeMapLayers | ( | const 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 117 of file qgsmaplayerregistry.cpp.
void QgsMapLayerRegistry::removeMapLayers | ( | const QList< QgsMapLayer * > & | layers | ) |
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.
layers | The layers to remove. Null pointers are ignored |
Definition at line 128 of file qgsmaplayerregistry.cpp.