35 QgsMapLayerRegistry::QgsMapLayerRegistry(
QObject *parent ) :
QObject( parent )
48 return mMapLayers.
size();
53 return mMapLayers.
value( theLayerId );
61 if ( layer->
name() == layerName )
63 myResultList << layer;
76 for (
int i = 0; i < theMapLayers.
size(); ++i )
79 if ( !myLayer || !myLayer->
isValid() )
87 mMapLayers[myLayer->
id()] = myLayer;
88 myResultList << mMapLayers[myLayer->
id()];
90 mOwnedLayers << myLayer;
94 if ( myResultList.
count() > 0 )
112 return addedLayers.
isEmpty() ? 0 : addedLayers[0];
121 foreach (
const QString &myId, theLayerIds )
128 mOwnedLayers.
remove( lyr );
130 mMapLayers.
remove( myId );
157 for ( it = mMapLayers.
begin(); it != mMapLayers.
end() ; ++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.
bool contains(const Key &key) const
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.
const T & at(int i) const
virtual void reload()
Synchronises with changes in the datasource.
void removeAllMapLayers()
Remove all registered layers.
void layersRemoved(QStringList theLayerIds)
Emitted after one or more layers were removed from the registry.
QList< Key > keys() const
const QString & name() const
Get the display name of the layer.
int count(const T &value) const
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.
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
virtual void connectNotify(const char *signal)
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.
bool contains(const T &value) const
int count()
Return the number of registered layers.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
bool remove(const T &value)
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)
const T value(const Key &key) const
void layerWillBeRemoved(QString theLayerId)
Emitted when a layer is removed from the registry.
int remove(const Key &key)