Skip to content

Commit ed48ffb

Browse files
committedMar 5, 2013
Map layer registry: un-deprecated addMapLayer(), added removeMapLayer() for convenience
1 parent 958f5e6 commit ed48ffb

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed
 

‎python/core/qgsmaplayerregistry.sip

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class QgsMapLayerRegistry : QObject
4949
@see addMapLayers
5050
@note Use addMapLayers if adding more than one layer at a time
5151
*/
52-
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true ) /Deprecated/;
52+
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true );
5353

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

66+
/** Remove a layer from qgis
67+
@note As a side-effect QgsProject is made dirty.
68+
Any canvases using the affected layers will need to remove them
69+
70+
If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
71+
signal will be emitted indicating to any listeners that the layers are being removed.
72+
73+
The layer being removed is deleted as well as the registry
74+
table entry.
75+
*/
76+
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );
77+
6678
/** Remove all registered layers
6779
@note raises removedAll()
6880
As a side-effect QgsProject is made dirty.

‎src/core/qgsmaplayerregistry.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds,
133133
emit layersWillBeRemoved( theLayerIds );
134134
}
135135

136+
void QgsMapLayerRegistry::removeMapLayer( const QString& theLayerId, bool theEmitSignal )
137+
{
138+
removeMapLayers( QStringList( theLayerId ), theEmitSignal );
139+
}
140+
141+
136142
void QgsMapLayerRegistry::removeAllMapLayers()
137143
{
138144
// moved before physically removing the layers

‎src/core/qgsmaplayerregistry.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
7070
/** Add a layer to the map of loaded layers
7171
@returns NULL if unable to add layer, otherwise pointer to newly added layer
7272
@see addMapLayers
73-
@note addMapLayers is prefered and must be used if adding more than one layer at a time
73+
@note Use addMapLayers if adding more than one layer at a time
7474
*/
75-
Q_DECL_DEPRECATED QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );
75+
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );
7676

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

89+
/** Remove a layer from qgis
90+
@note As a side-effect QgsProject is made dirty.
91+
Any canvases using the affected layers will need to remove them
92+
93+
If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
94+
signal will be emitted indicating to any listeners that the layers are being removed.
95+
96+
The layer being removed is deleted as well as the registry
97+
table entry.
98+
*/
99+
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );
100+
89101
/** Remove all registered layers
90102
@note raises removedAll()
91103
As a side-effect QgsProject is made dirty.

0 commit comments

Comments
 (0)
Please sign in to comment.