@@ -52,6 +52,9 @@ class CORE_EXPORT QgsRendererCategory
52
52
*/
53
53
QgsRendererCategory ( const QVariant &value, QgsSymbol *symbol SIP_TRANSFER, const QString &label, bool render = true );
54
54
55
+ /* *
56
+ * Copy constructor.
57
+ */
55
58
QgsRendererCategory ( const QgsRendererCategory &cat );
56
59
QgsRendererCategory &operator =( QgsRendererCategory cat );
57
60
@@ -141,6 +144,14 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
141
144
{
142
145
public:
143
146
147
+ /* *
148
+ * Constructor for QgsCategorizedSymbolRenderer.
149
+ *
150
+ * The \a attrName argument specifies the layer's field name, or expression, which the categories will be matched against.
151
+ *
152
+ * A list of renderer \a categories can optionally be specified. If no categories are specified in the constructor, they
153
+ * can be added later by calling addCategory().
154
+ */
144
155
QgsCategorizedSymbolRenderer ( const QString &attrName = QString(), const QgsCategoryList &categories = QgsCategoryList() );
145
156
146
157
QgsSymbol *symbolForFeature ( const QgsFeature &feature, QgsRenderContext &context ) const override ;
@@ -164,38 +175,129 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
164
175
*/
165
176
void updateSymbols ( QgsSymbol *sym );
166
177
178
+ /* *
179
+ * Returns a list of all categories recognized by the renderer.
180
+ */
167
181
const QgsCategoryList &categories () const { return mCategories ; }
168
182
169
- // ! Returns index of category with specified value (-1 if not found)
183
+ /* *
184
+ * Returns the index for the category with the specified value (or -1 if not found).
185
+ */
170
186
int categoryIndexForValue ( const QVariant &val );
171
187
172
188
/* *
173
- * Returns index of category with specified label (-1 if not found or not unique)
189
+ * Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique).
174
190
* \since QGIS 2.5
175
191
*/
176
192
int categoryIndexForLabel ( const QString &val );
177
193
194
+ /* *
195
+ * Changes the value for the category with the specified index.
196
+ *
197
+ * \see updateCategorySymbol()
198
+ * \see updateCategoryLabel()
199
+ * \see updateCategoryRenderState()
200
+ */
178
201
bool updateCategoryValue ( int catIndex, const QVariant &value );
202
+
203
+ /* *
204
+ * Changes the \a symbol for the category with the specified index.
205
+ *
206
+ * Ownership of \a symbol is transferred to the renderer.
207
+ *
208
+ * \see updateCategoryValue()
209
+ * \see updateCategoryLabel()
210
+ * \see updateCategoryRenderState()
211
+ */
179
212
bool updateCategorySymbol ( int catIndex, QgsSymbol *symbol SIP_TRANSFER );
213
+
214
+ /* *
215
+ * Changes the \a label for the category with the specified index.
216
+ *
217
+ * A category's label is used to represent the category within
218
+ * legends and the layer tree.
219
+ *
220
+ * \see updateCategoryValue()
221
+ * \see updateCategoryLabel()
222
+ * \see updateCategoryRenderState()
223
+ */
180
224
bool updateCategoryLabel ( int catIndex, const QString &label );
181
225
182
- // ! \since QGIS 2.5
226
+ /* *
227
+ * Changes the render state for the category with the specified index.
228
+ *
229
+ * The render state indicates whether or not the category will be rendered,
230
+ * and is reflected in whether the category is checked with the project's layer tree.
231
+ *
232
+ * \see updateCategoryValue()
233
+ * \see updateCategorySymbol()
234
+ * \see updateCategoryLabel()
235
+ *
236
+ * \since QGIS 2.5
237
+ */
183
238
bool updateCategoryRenderState ( int catIndex, bool render );
184
239
240
+ /* *
241
+ * Adds a new \a category to the renderer.
242
+ *
243
+ * \see categories()
244
+ */
185
245
void addCategory ( const QgsRendererCategory &category );
246
+
247
+ /* *
248
+ * Deletes the category with the specified index from the renderer.
249
+ *
250
+ * \see deleteAllCategories()
251
+ */
186
252
bool deleteCategory ( int catIndex );
253
+
254
+ /* *
255
+ * Deletes all existing categories from the renderer.
256
+ *
257
+ * \see deleteCategory()
258
+ */
187
259
void deleteAllCategories ();
188
260
189
- // ! Moves the category at index position from to index position to.
261
+ /* *
262
+ * Moves an existing category at index position from to index position to.
263
+ */
190
264
void moveCategory ( int from, int to );
191
265
266
+ /* *
267
+ * Sorts the existing categories by their value.
268
+ *
269
+ * \see sortByLabel()
270
+ */
192
271
void sortByValue ( Qt::SortOrder order = Qt::AscendingOrder );
272
+
273
+ /* *
274
+ * Sorts the existing categories by their label.
275
+ *
276
+ * \see sortByValue()
277
+ */
193
278
void sortByLabel ( Qt::SortOrder order = Qt::AscendingOrder );
194
279
280
+ /* *
281
+ * Returns the class attribute for the renderer, which is the field name
282
+ * or expression string from the layer which will be matched against the
283
+ * renderer categories.
284
+ *
285
+ * \see setClassAttribute()
286
+ */
195
287
QString classAttribute () const { return mAttrName ; }
288
+
289
+ /* *
290
+ * Sets the class attribute for the renderer, which is the field name
291
+ * or expression string from the layer which will be matched against the
292
+ * renderer categories.
293
+ *
294
+ * \see classAttribute()
295
+ */
196
296
void setClassAttribute ( const QString &attr ) { mAttrName = attr; }
197
297
198
- // ! create renderer from XML element
298
+ /* *
299
+ * Creates a categorized renderer from an XML \a element.
300
+ */
199
301
static QgsFeatureRenderer *create ( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
200
302
201
303
QDomElement save ( QDomDocument &doc, const QgsReadWriteContext &context ) override ;
0 commit comments