From aae400ecf1b52ee042103cf8676a99a73c93a947 Mon Sep 17 00:00:00 2001 From: Etienne Tourigny Date: Fri, 1 Feb 2013 15:22:37 -0200 Subject: [PATCH] [API] restore QgsMapLayerRegistry::addMapLayer() but keep it deprecated --- python/core/qgsmaplayerregistry.sip | 7 ++++++- src/core/qgsmaplayerregistry.cpp | 12 ++++++++++++ src/core/qgsmaplayerregistry.h | 7 ++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/python/core/qgsmaplayerregistry.sip b/python/core/qgsmaplayerregistry.sip index fda642ce226..ca62c1efcd5 100644 --- a/python/core/qgsmaplayerregistry.sip +++ b/python/core/qgsmaplayerregistry.sip @@ -44,6 +44,12 @@ class QgsMapLayerRegistry : QObject QList addMapLayers( QList theMapLayers /Transfer/, bool theEmitSignal = true ); + /** 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 Use addMapLayers if adding more than one layer at a time + */ + QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true ) /Deprecated/; /** Remove a set of layers from qgis @note As a side-effect QgsProject is made dirty. @@ -57,7 +63,6 @@ class QgsMapLayerRegistry : QObject */ void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true ); - /** Remove all registered layers @note raises removedAll() As a side-effect QgsProject is made dirty. diff --git a/src/core/qgsmaplayerregistry.cpp b/src/core/qgsmaplayerregistry.cpp index d0da9b49b80..c37f06fa9b2 100644 --- a/src/core/qgsmaplayerregistry.cpp +++ b/src/core/qgsmaplayerregistry.cpp @@ -104,6 +104,18 @@ QList QgsMapLayerRegistry::addMapLayers( return myResultList; } // QgsMapLayerRegistry::addMapLayers +//this is just a thin wrapper for addMapLayers +QgsMapLayer * +QgsMapLayerRegistry::addMapLayer( QgsMapLayer * theMapLayer, + bool theEmitSignal ) +{ + QList myList, myList2; + myList.append( theMapLayer ); + myList2 = addMapLayers( myList, theEmitSignal ); + return myList2.isEmpty() ? 0 : myList2[0]; +} + + //introduced in 1.8 void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds, bool theEmitSignal ) diff --git a/src/core/qgsmaplayerregistry.h b/src/core/qgsmaplayerregistry.h index 0e9dba4ed56..77c89ff6638 100644 --- a/src/core/qgsmaplayerregistry.h +++ b/src/core/qgsmaplayerregistry.h @@ -67,6 +67,12 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject QList addMapLayers( QList theMapLayers, bool theEmitSignal = true ); + /** 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 + */ + Q_DECL_DEPRECATED QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true ); /** Remove a set of layers from qgis @note As a side-effect QgsProject is made dirty. @@ -80,7 +86,6 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject */ void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true ); - /** Remove all registered layers @note raises removedAll() As a side-effect QgsProject is made dirty.