@@ -28,104 +28,164 @@ class QgsMapLayerRegistry : QObject
28
28
//! Retrieve the mapLayers collection (mainly intended for use by projection)
29
29
QMap<QString, QgsMapLayer*> & mapLayers();
30
30
31
- /** Add a list of layers to the map of loaded layers
32
- @returns QList<QgsMapLayer *> - a list of the map layers that were added
33
- successfully. If a layer is invalid, or already exists in the registry,
34
- it will not be part of the returned QList.
35
- @note added in QGIS 1.8
36
-
37
- As a side-effect QgsProject is made dirty.
38
-
39
- If theEmitSignal is true (by default), a layersAdded( QList<QgsMapLayer *>)
40
- signal will be emitted indicating that a batch of layers were added.
41
- Not emitting signal is useful when you want to use registry for layers
42
- on a different canvas and don't want them added to the main canvas automatically.
43
- */
44
- QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers /Transfer/,
45
- bool theEmitSignal = true );
46
-
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 );
53
-
54
- /** Remove a set of layers from qgis
55
- @note As a side-effect QgsProject is made dirty.
56
- Any canvases using the affected layers will need to remove them
57
-
58
- If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
59
- signal will be emitted indicating to any listeners that the layers are being removed.
60
-
61
- The layer being removed is deleted as well as the registry
62
- table entry.
63
- */
64
- void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );
65
-
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
-
78
- /** Remove all registered layers
79
- @note raises removedAll()
80
- As a side-effect QgsProject is made dirty.
81
- @note The layers are deleted as the registry is cleared!
82
- */
31
+ /**
32
+ * @brief
33
+ * Add a list of layers to the map of loaded layers
34
+ *
35
+ * The layersAdded() and layersWasAdded() signals will be emitted in any case.
36
+ * The legendLayersAdded() signal only if addToLegend is true.
37
+ *
38
+ * @param theMapLayers A list of layer which should be added to the registry
39
+ * @param addToLegend If true (by default), the layers will be added to the
40
+ * legend and to the main canvas. If you have a private
41
+ * layer, you can set this parameter to false to hide it.
42
+ *
43
+ * @return QList<QgsMapLayer *> - a list of the map layers that were added
44
+ * successfully. If a layer is invalid, or already exists in the registry,
45
+ * it will not be part of the returned QList.
46
+ *
47
+ * @note As a side-effect QgsProject is made dirty.
48
+ * @note Added in QGIS 1.8
49
+ */
50
+ QList<QgsMapLayer *> addMapLayers(QList<QgsMapLayer *> theMapLayers,
51
+ bool addToLegend = true );
52
+
53
+ /**
54
+ * @brief
55
+ * Add a layer to the map of loaded layers
56
+ *
57
+ * The layersAdded() and layersWasAdded() signals will be emitted in any case.
58
+ * The legendLayersAdded() signal only if addToLegend is true.
59
+ * If you are adding multiple layers at once, you should use
60
+ * {@link addMapLayers()} instead.
61
+ *
62
+ * @param theMapLayer A layer to add to the registry
63
+ * @param addToLegend If true (by default), the layer will be added to the
64
+ * legend and to the main canvas. If you have a private
65
+ * you can set this parameter to false to hide it.
66
+ *
67
+ * @return NULL if unable to add layer, otherwise pointer to newly added layer
68
+ *
69
+ * @see addMapLayers
70
+ *
71
+ * @note As a side-effect QgsProject is made dirty.
72
+ * @note Use addMapLayers if adding more than one layer at a time
73
+ */
74
+ QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer, bool addToLegend = true );
75
+
76
+ /**
77
+ * @brief
78
+ * Remove a set of layers from the registry
79
+ *
80
+ * Any canvases using the affected layers will need to remove them
81
+ *
82
+ * The layers being removed are deleted as well as the registry
83
+ * table entries.
84
+ *
85
+ * @param theLayerIds The ids of the layers to remove
86
+ *
87
+ * @note As a side-effect QgsProject is made dirty.
88
+ */
89
+ void removeMapLayers(QStringList theLayerIds );
90
+
91
+ /**
92
+ * @brief
93
+ * Remove a layer from qgis
94
+ *
95
+ * Any canvases using the affected layers will need to remove them
96
+ *
97
+ * The layer being removed is deleted as well as the registry
98
+ * table entry.
99
+ *
100
+ * @param theLayerId The id of the layer to remove
101
+ *
102
+ * @note As a side-effect QgsProject is made dirty.
103
+ */
104
+ void removeMapLayer( const QString& theLayerId );
105
+
106
+ /**
107
+ * Remove all registered layers
108
+ *
109
+ * @note As a side-effect QgsProject is made dirty.
110
+ * @note The layers are deleted as the registry is cleared!
111
+ */
83
112
void removeAllMapLayers();
84
113
85
- /* Clears all layer caches, resetting them to zero and
114
+ /**
115
+ * Clears all layer caches, resetting them to zero and
86
116
* freeing up any memory they may have been using. Layer
87
117
* caches are used to speed up rendering in certain situations
88
118
* see ticket #1974 for more details.
89
- * @note this method was added in QGIS 1.4
119
+ *
120
+ * @note Added in QGIS 1.4
90
121
*/
91
122
void clearAllLayerCaches();
92
123
93
- /**Reload all provider data caches (currently used for WFS and WMS providers)
94
- @note: this method was added in QGIS 1.6*/
124
+ /**
125
+ * Reload all provider data caches (currently used for WFS and WMS providers)
126
+ *
127
+ * @note Added in QGIS 1.6
128
+ */
95
129
void reloadAllLayers();
96
130
97
131
signals:
98
- /** Emitted when one or more layers are removed from the registry
99
- @note intended to replace layerWillBeRemoved in QGIS 1.8
100
- */
132
+ /**
133
+ * Emitted when one or more layers are removed from the registry
134
+ *
135
+ * @param theLayerIds A list of ids of the layers which are removed.
136
+ */
101
137
void layersWillBeRemoved( QStringList theLayerIds );
102
138
103
- /** emitted when a layer is removed from the registry
104
- connected to main map canvas and overview map canvas remove()
105
- @note we should deprecate this at some stage
106
- */
139
+ /**
140
+ * Emitted when a layer is removed from the registry
141
+ *
142
+ * @param theLayerId The id of the layer being removed
143
+ *
144
+ * @note Consider using {@link layersWillBeRemoved()} instead
145
+ */
107
146
void layerWillBeRemoved( QString theLayerId );
108
147
109
- /** Emitted when one or more layers are added to the registry
110
- @note intended to replace layerWasAdded in QGIS 1.8
111
- */
148
+ /**
149
+ * Emitted, when all layers are removed, before {@link layersWillBeRemoved()} and
150
+ * {@link layerWillBeRemoved()} signals are emitted. You will still get these signals
151
+ * in any case.
152
+ * You can use this signal to do easy (and fast) cleanup.
153
+ *
154
+ * @note Added in 2.0
155
+ */
156
+ void removeAll();
157
+
158
+ /**
159
+ * Emitted when one or more layers are added to the registry.
160
+ * This signal is also emitted for layers added to the registry,
161
+ * but not to the legend and canvas.
162
+ *
163
+ * @param theMapLayers The layers which have been added
164
+ *
165
+ * @see legendLayersAdded()
166
+ */
112
167
void layersAdded( QList<QgsMapLayer *> theMapLayers );
113
168
114
- /** emitted when a layer is added to the registry
115
- connected to main map canvas and overview map canvas addLayer()
116
- @note we should deprecate this at some stage
117
- */
118
- void layerWasAdded( QgsMapLayer * theMapLayer );
119
-
120
- /** emitted when ALL layers are removed at once
121
- This could have been implemented by iteratively signalling
122
- layerWillBeRemoved() for each layer as it is removed. However, this
123
- generally causes a cascade of effects that are unnecessary if we're
124
- ultimately removing all layers. E.g., removing the legend item
125
- corresponding to the layer. Why bother doing that when you're just going
126
- to clear everything anyway?
169
+ /**
170
+ * Emitted when a layer is added to the registry.
171
+ *
172
+ * @param theMapLayer The id of the layer which has been added
173
+ *
174
+ * @note Consider using {@link layersAdded()} instead
175
+ */
176
+ void layerWasAdded( QgsMapLayer* theMapLayer );
177
+
178
+ /**
179
+ * Emitted, when a layer is added to the registry and the legend.
180
+ * Plugins are allowed to have private layers, which are signalled by
181
+ * {@link layersAdded()} and {@link layerWasAdded()} but will not be
182
+ * advertised by this signal.
183
+ *
184
+ * @param theMapLayers The {@link QgsMapLayer}s which are added to the legend.
185
+ *
186
+ * @note Added in 2.0
127
187
*/
128
- void removedAll( );
188
+ void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );
129
189
130
190
protected:
131
191
//! protected constructor
0 commit comments