42 return mMapLayers.
size();
47 return mMapLayers.
value( theLayerId );
55 if ( layer->
name() == layerName )
57 myResultList << layer;
71 if ( !myLayer || !myLayer->
isValid() )
79 mMapLayers[myLayer->
id()] = myLayer;
80 myResultList << mMapLayers[myLayer->
id()];
106 return addedLayers.
isEmpty() ? nullptr : addedLayers[0];
112 Q_FOREACH (
const QString &myId, theLayerIds )
114 layers << mMapLayers.
value( myId );
131 if ( layer && mMapLayers.
contains( layer->
id() ) )
133 layerIds << layer->
id();
149 mMapLayers.
remove( myId );
150 if ( lyr->
parent() == this )
188 void QgsMapLayerRegistry::onMapLayerDeleted(
QObject* obj )
190 QString id = mMapLayers.
key( static_cast<QgsMapLayer*>( obj ) );
Base class for all map layer types.
void layerWillBeRemoved(const QString &theLayerId)
Emitted when a layer is about to be removed from the registry.
void removeMapLayer(const QString &theLayerId)
Remove a layer from the registry by layer ID.
void layersRemoved(const QStringList &theLayerIds)
Emitted after one or more layers were removed from the registry.
bool contains(const Key &key) const
void legendLayersAdded(const QList< QgsMapLayer *> &theMapLayers)
Emitted, when a layer was added to the registry and the legend.
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
virtual void reload()
Synchronises with changes in the datasource.
QMap< QString, QgsMapLayer * > mapLayers() const
Returns a map of all registered layers by layer ID.
void removeMapLayers(const QStringList &theLayerIds)
Remove a set of layers from the registry by layer ID.
void removeAllMapLayers()
Removes all registered layers.
QVector< T > layers() const
Returns a list of registered map layers with a specified layer type.
QList< Key > keys() const
int count() const
Returns the number of registered layers.
void layerWasAdded(QgsMapLayer *theMapLayer)
Emitted when a layer was added to the registry.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
QList< QgsMapLayer * > addMapLayers(const QList< QgsMapLayer *> &theMapLayers, bool addToLegend=true, bool takeOwnership=true)
Add a list of layers to the map of loaded layers.
void layerRemoved(const QString &theLayerId)
Emitted after a layer was removed from the registry.
bool isValid()
Return the status of the layer.
This class tracks map layers that are currently loaded and provides various methods to retrieve match...
virtual void connectNotify(const char *signal)
void removeAll()
Emitted when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals ar...
void layersWillBeRemoved(const QStringList &theLayerIds)
Emitted when one or more layers are about to be removed from the registry.
void setParent(QObject *parent)
const Key key(const T &value) const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QString name
Read property of QString layerName.
void layersAdded(const QList< QgsMapLayer *> &theMapLayers)
Emitted when one or more layers were added to the registry.
QgsMapLayer * addMapLayer(QgsMapLayer *theMapLayer, bool addToLegend=true, bool takeOwnership=true)
Add a layer to the map of loaded layers.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void reloadAllLayers()
Reload all registered layer's provider data caches, synchronising the layer with any changes in the d...
bool isNull(const QVariant &v)
void destroyed(QObject *obj)
const T value(const Key &key) const
int remove(const Key &key)
QList< QgsMapLayer * > mapLayersByName(const QString &layerName) const
Retrieve a list of matching registered layers by layer name.