Skip to content

Commit 224df0a

Browse files
committed
Add missing documentation for QgsCategorizedRenderer
1 parent d32714c commit 224df0a

File tree

2 files changed

+153
-9
lines changed

2 files changed

+153
-9
lines changed

python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
135135
public:
136136

137137
QgsCategorizedSymbolRenderer( const QString &attrName = QString(), const QgsCategoryList &categories = QgsCategoryList() );
138+
%Docstring
139+
Constructor for QgsCategorizedSymbolRenderer.
140+
141+
The ``attrName`` argument specifies the layer's field name, or expression, which the categories will be matched against.
142+
143+
A list of renderer ``categories`` can optionally be specified. If no categories are specified in the constructor, they
144+
can be added later by calling addCategory().
145+
%End
138146

139147
virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const;
140148

@@ -171,15 +179,18 @@ symbol for the renderer.
171179
%End
172180

173181
const QgsCategoryList &categories() const;
182+
%Docstring
183+
Returns a list of all categories recognized by the renderer.
184+
%End
174185

175186
int categoryIndexForValue( const QVariant &val );
176187
%Docstring
177-
Returns index of category with specified value (-1 if not found)
188+
Returns the index for the category with the specified value (or -1 if not found).
178189
%End
179190

180191
int categoryIndexForLabel( const QString &val );
181192
%Docstring
182-
Returns index of category with specified label (-1 if not found or not unique)
193+
Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique).
183194

184195
.. versionadded:: 2.5
185196
%End
@@ -193,6 +204,8 @@ If ``value`` is a list, then the category will match any of the values from this
193204
.. seealso:: :py:func:`updateCategorySymbol`
194205

195206
.. seealso:: :py:func:`updateCategoryLabel`
207+
208+
.. seealso:: :py:func:`updateCategoryRenderState`
196209
%End
197210

198211
bool updateCategorySymbol( int catIndex, QgsSymbol *symbol /Transfer/ );
@@ -204,6 +217,8 @@ Ownership of ``symbol`` is transferred to the renderer.
204217
.. seealso:: :py:func:`updateCategoryValue`
205218

206219
.. seealso:: :py:func:`updateCategoryLabel`
220+
221+
.. seealso:: :py:func:`updateCategoryRenderState`
207222
%End
208223

209224
bool updateCategoryLabel( int catIndex, const QString &label );
@@ -216,32 +231,87 @@ legends and the layer tree.
216231
.. seealso:: :py:func:`updateCategoryValue`
217232

218233
.. seealso:: :py:func:`updateCategoryLabel`
234+
235+
.. seealso:: :py:func:`updateCategoryRenderState`
219236
%End
220237

221238
bool updateCategoryRenderState( int catIndex, bool render );
222239
%Docstring
240+
Changes the render state for the category with the specified index.
241+
242+
The render state indicates whether or not the category will be rendered,
243+
and is reflected in whether the category is checked with the project's layer tree.
244+
245+
.. seealso:: :py:func:`updateCategoryValue`
246+
247+
.. seealso:: :py:func:`updateCategorySymbol`
248+
249+
.. seealso:: :py:func:`updateCategoryLabel`
223250

224251
.. versionadded:: 2.5
225252
%End
226253

227254
void addCategory( const QgsRendererCategory &category );
255+
%Docstring
256+
Adds a new ``category`` to the renderer.
257+
258+
.. seealso:: :py:func:`categories`
259+
%End
260+
228261
bool deleteCategory( int catIndex );
262+
%Docstring
263+
Deletes the category with the specified index from the renderer.
264+
265+
.. seealso:: :py:func:`deleteAllCategories`
266+
%End
267+
229268
void deleteAllCategories();
269+
%Docstring
270+
Deletes all existing categories from the renderer.
271+
272+
.. seealso:: :py:func:`deleteCategory`
273+
%End
230274

231275
void moveCategory( int from, int to );
232276
%Docstring
233-
Moves the category at index position from to index position to.
277+
Moves an existing category at index position from to index position to.
234278
%End
235279

236280
void sortByValue( Qt::SortOrder order = Qt::AscendingOrder );
281+
%Docstring
282+
Sorts the existing categories by their value.
283+
284+
.. seealso:: :py:func:`sortByLabel`
285+
%End
286+
237287
void sortByLabel( Qt::SortOrder order = Qt::AscendingOrder );
288+
%Docstring
289+
Sorts the existing categories by their label.
290+
291+
.. seealso:: :py:func:`sortByValue`
292+
%End
238293

239294
QString classAttribute() const;
295+
%Docstring
296+
Returns the class attribute for the renderer, which is the field name
297+
or expression string from the layer which will be matched against the
298+
renderer categories.
299+
300+
.. seealso:: :py:func:`setClassAttribute`
301+
%End
302+
240303
void setClassAttribute( const QString &attr );
304+
%Docstring
305+
Sets the class attribute for the renderer, which is the field name
306+
or expression string from the layer which will be matched against the
307+
renderer categories.
308+
309+
.. seealso:: :py:func:`classAttribute`
310+
%End
241311

242312
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
243313
%Docstring
244-
create renderer from XML element
314+
Creates a categorized renderer from an XML ``element``.
245315
%End
246316

247317
virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context );

src/core/symbology/qgscategorizedsymbolrenderer.h

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
149149
{
150150
public:
151151

152+
/**
153+
* Constructor for QgsCategorizedSymbolRenderer.
154+
*
155+
* The \a attrName argument specifies the layer's field name, or expression, which the categories will be matched against.
156+
*
157+
* A list of renderer \a categories can optionally be specified. If no categories are specified in the constructor, they
158+
* can be added later by calling addCategory().
159+
*/
152160
QgsCategorizedSymbolRenderer( const QString &attrName = QString(), const QgsCategoryList &categories = QgsCategoryList() );
153161

154162
QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override;
@@ -172,13 +180,18 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
172180
*/
173181
void updateSymbols( QgsSymbol *sym );
174182

183+
/**
184+
* Returns a list of all categories recognized by the renderer.
185+
*/
175186
const QgsCategoryList &categories() const { return mCategories; }
176187

177-
//! Returns index of category with specified value (-1 if not found)
188+
/**
189+
* Returns the index for the category with the specified value (or -1 if not found).
190+
*/
178191
int categoryIndexForValue( const QVariant &val );
179192

180193
/**
181-
* Returns index of category with specified label (-1 if not found or not unique)
194+
* Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique).
182195
* \since QGIS 2.5
183196
*/
184197
int categoryIndexForLabel( const QString &val );
@@ -190,6 +203,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
190203
*
191204
* \see updateCategorySymbol()
192205
* \see updateCategoryLabel()
206+
* \see updateCategoryRenderState()
193207
*/
194208
bool updateCategoryValue( int catIndex, const QVariant &value );
195209

@@ -200,6 +214,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
200214
*
201215
* \see updateCategoryValue()
202216
* \see updateCategoryLabel()
217+
* \see updateCategoryRenderState()
203218
*/
204219
bool updateCategorySymbol( int catIndex, QgsSymbol *symbol SIP_TRANSFER );
205220

@@ -211,26 +226,85 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
211226
*
212227
* \see updateCategoryValue()
213228
* \see updateCategoryLabel()
229+
* \see updateCategoryRenderState()
214230
*/
215231
bool updateCategoryLabel( int catIndex, const QString &label );
216232

217-
//! \since QGIS 2.5
233+
/**
234+
* Changes the render state for the category with the specified index.
235+
*
236+
* The render state indicates whether or not the category will be rendered,
237+
* and is reflected in whether the category is checked with the project's layer tree.
238+
*
239+
* \see updateCategoryValue()
240+
* \see updateCategorySymbol()
241+
* \see updateCategoryLabel()
242+
*
243+
* \since QGIS 2.5
244+
*/
218245
bool updateCategoryRenderState( int catIndex, bool render );
219246

247+
/**
248+
* Adds a new \a category to the renderer.
249+
*
250+
* \see categories()
251+
*/
220252
void addCategory( const QgsRendererCategory &category );
253+
254+
/**
255+
* Deletes the category with the specified index from the renderer.
256+
*
257+
* \see deleteAllCategories()
258+
*/
221259
bool deleteCategory( int catIndex );
260+
261+
/**
262+
* Deletes all existing categories from the renderer.
263+
*
264+
* \see deleteCategory()
265+
*/
222266
void deleteAllCategories();
223267

224-
//! Moves the category at index position from to index position to.
268+
/**
269+
* Moves an existing category at index position from to index position to.
270+
*/
225271
void moveCategory( int from, int to );
226272

273+
/**
274+
* Sorts the existing categories by their value.
275+
*
276+
* \see sortByLabel()
277+
*/
227278
void sortByValue( Qt::SortOrder order = Qt::AscendingOrder );
279+
280+
/**
281+
* Sorts the existing categories by their label.
282+
*
283+
* \see sortByValue()
284+
*/
228285
void sortByLabel( Qt::SortOrder order = Qt::AscendingOrder );
229286

287+
/**
288+
* Returns the class attribute for the renderer, which is the field name
289+
* or expression string from the layer which will be matched against the
290+
* renderer categories.
291+
*
292+
* \see setClassAttribute()
293+
*/
230294
QString classAttribute() const { return mAttrName; }
295+
296+
/**
297+
* Sets the class attribute for the renderer, which is the field name
298+
* or expression string from the layer which will be matched against the
299+
* renderer categories.
300+
*
301+
* \see classAttribute()
302+
*/
231303
void setClassAttribute( const QString &attr ) { mAttrName = attr; }
232304

233-
//! create renderer from XML element
305+
/**
306+
* Creates a categorized renderer from an XML \a element.
307+
*/
234308
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
235309

236310
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;

0 commit comments

Comments
 (0)