Skip to content

Commit

Permalink
Map layer registry: un-deprecated addMapLayer(), added removeMapLayer…
Browse files Browse the repository at this point in the history
…() for convenience
  • Loading branch information
wonder-sk committed Mar 5, 2013
1 parent 958f5e6 commit ed48ffb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
14 changes: 13 additions & 1 deletion python/core/qgsmaplayerregistry.sip
Expand Up @@ -49,7 +49,7 @@ class QgsMapLayerRegistry : QObject
@see addMapLayers
@note Use addMapLayers if adding more than one layer at a time
*/
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true ) /Deprecated/;
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true );

/** Remove a set of layers from qgis
@note As a side-effect QgsProject is made dirty.
Expand All @@ -63,6 +63,18 @@ class QgsMapLayerRegistry : QObject
*/
void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );

/** Remove a layer from qgis
@note As a side-effect QgsProject is made dirty.
Any canvases using the affected layers will need to remove them

If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
signal will be emitted indicating to any listeners that the layers are being removed.

The layer being removed is deleted as well as the registry
table entry.
*/
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );

/** Remove all registered layers
@note raises removedAll()
As a side-effect QgsProject is made dirty.
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsmaplayerregistry.cpp
Expand Up @@ -133,6 +133,12 @@ void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds,
emit layersWillBeRemoved( theLayerIds );
}

void QgsMapLayerRegistry::removeMapLayer( const QString& theLayerId, bool theEmitSignal )
{
removeMapLayers( QStringList( theLayerId ), theEmitSignal );
}


void QgsMapLayerRegistry::removeAllMapLayers()
{
// moved before physically removing the layers
Expand Down
16 changes: 14 additions & 2 deletions src/core/qgsmaplayerregistry.h
Expand Up @@ -70,9 +70,9 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
/** Add a layer to the map of loaded layers
@returns NULL if unable to add layer, otherwise pointer to newly added layer
@see addMapLayers
@note addMapLayers is prefered and must be used if adding more than one layer at a time
@note Use addMapLayers if adding more than one layer at a time
*/
Q_DECL_DEPRECATED QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );

/** Remove a set of layers from qgis
@note As a side-effect QgsProject is made dirty.
Expand All @@ -86,6 +86,18 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
*/
void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );

/** Remove a layer from qgis
@note As a side-effect QgsProject is made dirty.
Any canvases using the affected layers will need to remove them
If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
signal will be emitted indicating to any listeners that the layers are being removed.
The layer being removed is deleted as well as the registry
table entry.
*/
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );

/** Remove all registered layers
@note raises removedAll()
As a side-effect QgsProject is made dirty.
Expand Down

0 comments on commit ed48ffb

Please sign in to comment.