Skip to content

Commit aae400e

Browse files
committed
[API] restore QgsMapLayerRegistry::addMapLayer() but keep it deprecated
1 parent b74cb5f commit aae400e

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

python/core/qgsmaplayerregistry.sip

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class QgsMapLayerRegistry : QObject
4444
QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers /Transfer/,
4545
bool theEmitSignal = true );
4646

47+
/** Add a layer to the map of loaded layers
48+
@returns NULL if unable to add layer, otherwise pointer to newly added layer
49+
@see addMapLayers
50+
@note Use addMapLayers if adding more than one layer at a time
51+
*/
52+
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true ) /Deprecated/;
4753

4854
/** Remove a set of layers from qgis
4955
@note As a side-effect QgsProject is made dirty.
@@ -57,7 +63,6 @@ class QgsMapLayerRegistry : QObject
5763
*/
5864
void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );
5965

60-
6166
/** Remove all registered layers
6267
@note raises removedAll()
6368
As a side-effect QgsProject is made dirty.

src/core/qgsmaplayerregistry.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers(
104104
return myResultList;
105105
} // QgsMapLayerRegistry::addMapLayers
106106

107+
//this is just a thin wrapper for addMapLayers
108+
QgsMapLayer *
109+
QgsMapLayerRegistry::addMapLayer( QgsMapLayer * theMapLayer,
110+
bool theEmitSignal )
111+
{
112+
QList<QgsMapLayer *> myList, myList2;
113+
myList.append( theMapLayer );
114+
myList2 = addMapLayers( myList, theEmitSignal );
115+
return myList2.isEmpty() ? 0 : myList2[0];
116+
}
117+
118+
107119
//introduced in 1.8
108120
void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds,
109121
bool theEmitSignal )

src/core/qgsmaplayerregistry.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
6767
QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers,
6868
bool theEmitSignal = true );
6969

70+
/** Add a layer to the map of loaded layers
71+
@returns NULL if unable to add layer, otherwise pointer to newly added layer
72+
@see addMapLayers
73+
@note addMapLayers is prefered and must be used if adding more than one layer at a time
74+
*/
75+
Q_DECL_DEPRECATED QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );
7076

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

83-
8489
/** Remove all registered layers
8590
@note raises removedAll()
8691
As a side-effect QgsProject is made dirty.

0 commit comments

Comments
 (0)