20
20
#define QGSMAPLAYERREGISTRY_H
21
21
22
22
#include < QMap>
23
+ #include < QSet>
23
24
#include < QObject>
24
25
#include < QStringList>
25
26
class QString ;
@@ -58,10 +59,13 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
58
59
* The layersAdded() and layersWasAdded() signals will be emitted in any case.
59
60
* The legendLayersAdded() signal only if addToLegend is true.
60
61
*
61
- * @param theMapLayers A list of layer which should be added to the registry
62
- * @param addToLegend If true (by default), the layers will be added to the
63
- * legend and to the main canvas. If you have a private
64
- * layer, you can set this parameter to false to hide it.
62
+ * @param theMapLayers A list of layer which should be added to the registry
63
+ * @param addToLegend If true (by default), the layers will be added to the
64
+ * legend and to the main canvas. If you have a private
65
+ * layer, you can set this parameter to false to hide it.
66
+ * @param takeOwnership Ownership will be transferred to the layer registry.
67
+ * If you specify false here, you have take care of deleting
68
+ * the layers yourself. Not available in python.
65
69
*
66
70
* @return QList<QgsMapLayer *> - a list of the map layers that were added
67
71
* successfully. If a layer is invalid, or already exists in the registry,
@@ -71,7 +75,8 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
71
75
* @note Added in QGIS 1.8
72
76
*/
73
77
QList<QgsMapLayer *> addMapLayers ( QList<QgsMapLayer *> theMapLayers,
74
- bool addToLegend = true );
78
+ bool addToLegend = true ,
79
+ bool takeOwnership = true );
75
80
76
81
/* *
77
82
* @brief
@@ -86,6 +91,9 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
86
91
* @param addToLegend If true (by default), the layer will be added to the
87
92
* legend and to the main canvas. If you have a private
88
93
* you can set this parameter to false to hide it.
94
+ * @param takeOwnership Ownership will be transferred to the layer registry.
95
+ * If you specify false here, you have take care of deleting
96
+ * the layer yourself. Not available in python.
89
97
*
90
98
* @return NULL if unable to add layer, otherwise pointer to newly added layer
91
99
*
@@ -94,17 +102,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
94
102
* @note As a side-effect QgsProject is made dirty.
95
103
* @note Use addMapLayers if adding more than one layer at a time
96
104
*/
97
- QgsMapLayer* addMapLayer ( QgsMapLayer * theMapLayer, bool addToLegend = true );
98
-
99
- /* *
100
- * @brief
101
- * Clears the map layer registry silently. No signals are emitted,
102
- * no layer is deleted. Whatever this is suitable for... The WMS
103
- * server makes use of this.
104
- *
105
- * Not available in python
106
- */
107
- void clearMapLayers ();
105
+ QgsMapLayer* addMapLayer ( QgsMapLayer * theMapLayer, bool addToLegend = true , bool takeOwnership = true );
108
106
109
107
/* *
110
108
* @brief
@@ -230,6 +228,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
230
228
static QgsMapLayerRegistry* mInstance ;
231
229
232
230
QMap<QString, QgsMapLayer*> mMapLayers ;
231
+ QSet<QgsMapLayer*> mOwnedLayers ;
233
232
234
233
/* * debugging member
235
234
invoked when a connect() is made to this object
0 commit comments