A storage object for map layers, in which the layers are owned by the store and have their lifetime bound to the store.
More...
#include <qgsmaplayerstore.h>
A storage object for map layers, in which the layers are owned by the store and have their lifetime bound to the store.
- Since
- QGIS 3.0
Definition at line 35 of file qgsmaplayerstore.h.
◆ QgsMapLayerStore()
QgsMapLayerStore::QgsMapLayerStore |
( |
QObject * |
parent = nullptr | ) |
|
|
explicit |
◆ ~QgsMapLayerStore()
QgsMapLayerStore::~QgsMapLayerStore |
( |
| ) |
|
|
override |
◆ addMapLayer()
Add a layer to the store.
Ownership of the layer is transferred to the store.
The layersAdded() and layerWasAdded() signals will always be emitted. If you are adding multiple layers at once, you should use addMapLayers() instead.
- Parameters
-
layer | A layer to add to the store |
takeOwnership | Ownership will be transferred to the layer store. If you specify false here you have take care of deleting the layers yourself. Not available in Python. |
- Returns
nullptr
if unable to add layer, otherwise pointer to newly added layer
- See also
- addMapLayers
- Note
- Use addMapLayers() if adding more than one layer at a time.
- See also
- addMapLayers()
Definition at line 105 of file qgsmaplayerstore.cpp.
◆ addMapLayers()
QList< QgsMapLayer * > QgsMapLayerStore::addMapLayers |
( |
const QList< QgsMapLayer * > & |
layers, |
|
|
bool |
takeOwnership = true |
|
) |
| |
Add a list of layers to the store.
Ownership of the layers is transferred to the store.
The layersAdded() and layerWasAdded() signals will always be emitted.
- Parameters
-
layers | A list of layer which should be added to the store. |
takeOwnership | Ownership will be transferred to the layer store. If you specify false here you have take care of deleting the layers yourself. Not available in Python. |
- Note
- If a layer with the same id is already in the store it is not added again, but if the validity of the layer has changed from
false
to true
, the layer data source is updated to the new one.
- Returns
- a list of the map layers that were added successfully. If a layer already exists in the store, it will not be part of the returned list.
- See also
- addMapLayer()
Definition at line 68 of file qgsmaplayerstore.cpp.
◆ allLayersRemoved
void QgsMapLayerStore::allLayersRemoved |
( |
| ) |
|
|
signal |
◆ count()
int QgsMapLayerStore::count |
( |
| ) |
const |
◆ layerRemoved
void QgsMapLayerStore::layerRemoved |
( |
const QString & |
layerId | ) |
|
|
signal |
◆ layers()
template<typename T >
QVector< T > QgsMapLayerStore::layers |
( |
| ) |
const |
|
inline |
Returns a list of registered map layers with a specified layer type.
Example
QVector<QgsVectorLayer*> vectorLayers = store->layers<QgsVectorLayer*>();
- Note
- not available in Python bindings
- See also
- mapLayers()
Definition at line 124 of file qgsmaplayerstore.h.
◆ layersAdded
void QgsMapLayerStore::layersAdded |
( |
const QList< QgsMapLayer * > & |
layers | ) |
|
|
signal |
Emitted when one or more layers were added to the store.
- Parameters
-
layers | List of layers which have been added. |
- See also
- layerWasAdded()
◆ layersRemoved
void QgsMapLayerStore::layersRemoved |
( |
const QStringList & |
layerIds | ) |
|
|
signal |
Emitted after one or more layers were removed from the store.
- Parameters
-
layerIds | A list of IDs of the layers which were removed. |
- See also
- layersWillBeRemoved()
◆ layersWillBeRemoved [1/2]
void QgsMapLayerStore::layersWillBeRemoved |
( |
const QList< QgsMapLayer * > & |
layers | ) |
|
|
signal |
Emitted when one or more layers are about to be removed from the store.
- Parameters
-
layers | A list of layers which are to be removed. |
- See also
- layerWillBeRemoved()
-
layersRemoved()
◆ layersWillBeRemoved [2/2]
void QgsMapLayerStore::layersWillBeRemoved |
( |
const QStringList & |
layerIds | ) |
|
|
signal |
Emitted when one or more layers are about to be removed from the store.
- Parameters
-
layerIds | A list of IDs for the layers which are to be removed. |
- See also
- layerWillBeRemoved()
-
layersRemoved()
◆ layerWasAdded
void QgsMapLayerStore::layerWasAdded |
( |
QgsMapLayer * |
layer | ) |
|
|
signal |
◆ layerWillBeRemoved [1/2]
void QgsMapLayerStore::layerWillBeRemoved |
( |
const QString & |
layerId | ) |
|
|
signal |
◆ layerWillBeRemoved [2/2]
void QgsMapLayerStore::layerWillBeRemoved |
( |
QgsMapLayer * |
layer | ) |
|
|
signal |
◆ mapLayer()
QgsMapLayer * QgsMapLayerStore::mapLayer |
( |
const QString & |
id | ) |
const |
◆ mapLayers()
QMap< QString, QgsMapLayer * > QgsMapLayerStore::mapLayers |
( |
| ) |
const |
◆ mapLayersByName()
QList< QgsMapLayer * > QgsMapLayerStore::mapLayersByName |
( |
const QString & |
name | ) |
const |
◆ removeAllMapLayers()
void QgsMapLayerStore::removeAllMapLayers |
( |
| ) |
|
◆ removeMapLayer() [1/2]
void QgsMapLayerStore::removeMapLayer |
( |
const QString & |
id | ) |
|
◆ removeMapLayer() [2/2]
void QgsMapLayerStore::removeMapLayer |
( |
QgsMapLayer * |
layer | ) |
|
◆ removeMapLayers() [1/2]
void QgsMapLayerStore::removeMapLayers |
( |
const QList< QgsMapLayer * > & |
layers | ) |
|
◆ removeMapLayers() [2/2]
void QgsMapLayerStore::removeMapLayers |
( |
const QStringList & |
layerIds | ) |
|
◆ takeMapLayer()
Takes a layer from the store.
If the layer was owned by the store, the layer will be returned without deleting it. The caller takes ownership of the layer and is responsible for deleting it.
- See also
- removeMapLayer()
Definition at line 177 of file qgsmaplayerstore.cpp.
◆ transferLayersFromStore()
Transfers all the map layers contained within another map layer store and adds them to this store.
Note that other and this store must have the same thread affinity.
Definition at line 207 of file qgsmaplayerstore.cpp.
◆ validCount()
int QgsMapLayerStore::validCount |
( |
| ) |
const |
Returns the number of valid layers contained in the store.
- Since
- QGIS 3.6
Definition at line 37 of file qgsmaplayerstore.cpp.
◆ validMapLayers()
QMap< QString, QgsMapLayer * > QgsMapLayerStore::validMapLayers |
( |
| ) |
const |
The documentation for this class was generated from the following files: