62 QList<QgsMapLayer *> myResultList;
65 if ( layer->
name() == layerName )
67 myResultList << layer;
75 QList<QgsMapLayer *> theMapLayers,
79 QList<QgsMapLayer *> myResultList;
80 for (
int i = 0; i < theMapLayers.size(); ++i )
83 if ( !myLayer || !myLayer->
isValid() )
98 if ( myResultList.count() > 0 )
114 QList<QgsMapLayer *> addedLayers;
115 addedLayers =
addMapLayers( QList<QgsMapLayer*>() << theMapLayer, addToLegend, takeOwnership );
116 return addedLayers.isEmpty() ? 0 : addedLayers[0];
125 foreach (
const QString &myId, theLayerIds )
160 QMap<QString, QgsMapLayer *>::iterator it;
void legendLayersAdded(QList< QgsMapLayer * > theMapLayers)
Emitted, when a layer is added to the registry and the legend.
Base class for all map layer types.
void removeMapLayer(const QString &theLayerId)
Remove a layer from qgis.
void layersAdded(QList< QgsMapLayer * > theMapLayers)
Emitted when one or more layers are added to the registry.
void layersWillBeRemoved(QStringList theLayerIds)
Emitted when one or more layers are removed from the registry.
virtual void reload()
Synchronises with changes in the datasource.
void connectNotify(const char *signal)
debugging member invoked when a connect() is made to this object
void removeAllMapLayers()
Remove all registered layers.
static QgsMapLayerRegistry * mInstance
void layersRemoved(QStringList theLayerIds)
Emitted after one or more layers were removed from the registry.
const QString & name() const
Get the display name of the layer.
void layerRemoved(QString theLayerId)
Emitted after a layer was removed from the registry.
void layerWasAdded(QgsMapLayer *theMapLayer)
Emitted when a layer is added to the registry.
QList< QgsMapLayer * > addMapLayers(QList< QgsMapLayer * > theMapLayers, bool addToLegend=true, bool takeOwnership=true)
Add a list of layers to the map of loaded layers.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
QgsMapLayerRegistry(QObject *parent=0)
protected constructor
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
QMap< QString, QgsMapLayer * > mMapLayers
void removeAll()
Emitted, when all layers are removed, before layersWillBeRemoved() and layerWillBeRemoved() signals a...
QList< QgsMapLayer * > mapLayersByName(QString layerName)
Retrieve a pointer to a loaded layer by name.
int count()
Return the number of registered layers.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QSet< QgsMapLayer * > mOwnedLayers
void removeMapLayers(QStringList theLayerIds)
Remove a set of layers from the registry.
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
Q_DECL_DEPRECATED void clearAllLayerCaches()
Clears all layer caches, resetting them to zero and freeing up any memory they may have been using...
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
QgsMapLayer * addMapLayer(QgsMapLayer *theMapLayer, bool addToLegend=true, bool takeOwnership=true)
Add a layer to the map of loaded layers.
void reloadAllLayers()
Reload all provider data caches (currently used for WFS and WMS providers)
void layerWillBeRemoved(QString theLayerId)
Emitted when a layer is removed from the registry.