QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Static Public Member Functions | List of all members
QgsMapLayerLegendUtils Class Reference

Miscellaneous utility functions for handling of map layer legend. More...

#include <qgsmaplayerlegend.h>

Static Public Member Functions

static void applyLayerNodeProperties (QgsLayerTreeLayer *nodeLayer, QList< QgsLayerTreeModelLegendNode * > &nodes)
 update according to layer node's custom properties (order of items, user labels for items) More...
 
static bool hasLegendNodeOrder (QgsLayerTreeLayer *nodeLayer)
 
static bool hasLegendNodeUserLabel (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 
static QgsColorRampLegendNodeSettingslegendNodeColorRampSettings (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 Returns the custom legend color ramp settings for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static bool legendNodeColumnBreak (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 Returns whether a forced column break should occur before the node. More...
 
static QgsSymbollegendNodeCustomSymbol (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 Returns the custom legend symbol for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static QList< int > legendNodeOrder (QgsLayerTreeLayer *nodeLayer)
 
static QgsLegendPatchShape legendNodePatchShape (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 Returns the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static QSizeF legendNodeSymbolSize (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 Returns the legend node symbol size for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static QString legendNodeUserLabel (QgsLayerTreeLayer *nodeLayer, int originalIndex)
 
static void setLegendNodeColorRampSettings (QgsLayerTreeLayer *nodeLayer, int originalIndex, const QgsColorRampLegendNodeSettings *settings)
 Sets a custom legend color ramp settings for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static void setLegendNodeColumnBreak (QgsLayerTreeLayer *nodeLayer, int originalIndex, bool columnBreakBeforeNode)
 Sets whether a forced column break should occur before the node. More...
 
static void setLegendNodeCustomSymbol (QgsLayerTreeLayer *nodeLayer, int originalIndex, const QgsSymbol *symbol)
 Sets a custom legend symbol for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static void setLegendNodeOrder (QgsLayerTreeLayer *nodeLayer, const QList< int > &order)
 
static void setLegendNodePatchShape (QgsLayerTreeLayer *nodeLayer, int originalIndex, const QgsLegendPatchShape &shape)
 Sets the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static void setLegendNodeSymbolSize (QgsLayerTreeLayer *nodeLayer, int originalIndex, QSizeF size)
 Sets the legend symbol size for the legend node belonging to nodeLayer at the specified originalIndex. More...
 
static void setLegendNodeUserLabel (QgsLayerTreeLayer *nodeLayer, int originalIndex, const QString &newLabel)
 

Detailed Description

Miscellaneous utility functions for handling of map layer legend.

Since
QGIS 2.6

Definition at line 104 of file qgsmaplayerlegend.h.

Member Function Documentation

◆ applyLayerNodeProperties()

void QgsMapLayerLegendUtils::applyLayerNodeProperties ( QgsLayerTreeLayer nodeLayer,
QList< QgsLayerTreeModelLegendNode * > &  nodes 
)
static

update according to layer node's custom properties (order of items, user labels for items)

Definition at line 278 of file qgsmaplayerlegend.cpp.

◆ hasLegendNodeOrder()

bool QgsMapLayerLegendUtils::hasLegendNodeOrder ( QgsLayerTreeLayer nodeLayer)
static

Definition at line 141 of file qgsmaplayerlegend.cpp.

◆ hasLegendNodeUserLabel()

bool QgsMapLayerLegendUtils::hasLegendNodeUserLabel ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Definition at line 156 of file qgsmaplayerlegend.cpp.

◆ legendNodeColorRampSettings()

QgsColorRampLegendNodeSettings * QgsMapLayerLegendUtils::legendNodeColorRampSettings ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Returns the custom legend color ramp settings for the legend node belonging to nodeLayer at the specified originalIndex.

If the corresponding legend node is not a QgsColorRampLegendNode then calling this method will return nullptr.

If the returned value is non-nullptr, they will be used in place of the default settings when rendering the legend node.

Caller takes ownership of the returned settings.

See also
setLegendNodeColorRampSettings()
Since
QGIS 3.18

Definition at line 247 of file qgsmaplayerlegend.cpp.

◆ legendNodeColumnBreak()

bool QgsMapLayerLegendUtils::legendNodeColumnBreak ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Returns whether a forced column break should occur before the node.

See also
setLegendNodeColumnBreak()
Since
QGIS 3.14

Definition at line 273 of file qgsmaplayerlegend.cpp.

◆ legendNodeCustomSymbol()

QgsSymbol * QgsMapLayerLegendUtils::legendNodeCustomSymbol ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Returns the custom legend symbol for the legend node belonging to nodeLayer at the specified originalIndex.

If the symbol is non-nullptr, it will be used in place of the default symbol when rendering the legend node.

Caller takes ownership of the returned symbol.

See also
setLegendNodeCustomSymbol()
Since
QGIS 3.14

Definition at line 215 of file qgsmaplayerlegend.cpp.

◆ legendNodeOrder()

QList< int > QgsMapLayerLegendUtils::legendNodeOrder ( QgsLayerTreeLayer nodeLayer)
static

Definition at line 114 of file qgsmaplayerlegend.cpp.

◆ legendNodePatchShape()

QgsLegendPatchShape QgsMapLayerLegendUtils::legendNodePatchShape ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Returns the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex.

See also
setLegendNodePatchShape()
Since
QGIS 3.14

Definition at line 170 of file qgsmaplayerlegend.cpp.

◆ legendNodeSymbolSize()

QSizeF QgsMapLayerLegendUtils::legendNodeSymbolSize ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Returns the legend node symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

If either the width or height are non-zero, they will be used when rendering the legend node instead of the default symbol width or height from QgsLegendSettings.

See also
setLegendNodeSymbolSize()
Since
QGIS 3.14

Definition at line 191 of file qgsmaplayerlegend.cpp.

◆ legendNodeUserLabel()

QString QgsMapLayerLegendUtils::legendNodeUserLabel ( QgsLayerTreeLayer nodeLayer,
int  originalIndex 
)
static

Definition at line 151 of file qgsmaplayerlegend.cpp.

◆ setLegendNodeColorRampSettings()

void QgsMapLayerLegendUtils::setLegendNodeColorRampSettings ( QgsLayerTreeLayer nodeLayer,
int  originalIndex,
const QgsColorRampLegendNodeSettings settings 
)
static

Sets a custom legend color ramp settings for the legend node belonging to nodeLayer at the specified originalIndex.

If the corresponding legend node is not a QgsColorRampLegendNode then calling this method will have no effect.

If settings is non-nullptr, they will be used in place of the default settigns when rendering the legend node.

See also
legendNodeColorRampSettings()
Since
QGIS 3.18

Definition at line 231 of file qgsmaplayerlegend.cpp.

◆ setLegendNodeColumnBreak()

void QgsMapLayerLegendUtils::setLegendNodeColumnBreak ( QgsLayerTreeLayer nodeLayer,
int  originalIndex,
bool  columnBreakBeforeNode 
)
static

Sets whether a forced column break should occur before the node.

See also
legendNodeColumnBreak()
Since
QGIS 3.14

Definition at line 265 of file qgsmaplayerlegend.cpp.

◆ setLegendNodeCustomSymbol()

void QgsMapLayerLegendUtils::setLegendNodeCustomSymbol ( QgsLayerTreeLayer nodeLayer,
int  originalIndex,
const QgsSymbol symbol 
)
static

Sets a custom legend symbol for the legend node belonging to nodeLayer at the specified originalIndex.

If symbol is non-nullptr, it will be used in place of the default symbol when rendering the legend node.

See also
legendNodeCustomSymbol()
Since
QGIS 3.14

Definition at line 200 of file qgsmaplayerlegend.cpp.

◆ setLegendNodeOrder()

void QgsMapLayerLegendUtils::setLegendNodeOrder ( QgsLayerTreeLayer nodeLayer,
const QList< int > &  order 
)
static

Definition at line 77 of file qgsmaplayerlegend.cpp.

◆ setLegendNodePatchShape()

void QgsMapLayerLegendUtils::setLegendNodePatchShape ( QgsLayerTreeLayer nodeLayer,
int  originalIndex,
const QgsLegendPatchShape shape 
)
static

Sets the legend patch shape for the legend node belonging to nodeLayer at the specified originalIndex.

See also
legendNodePatchShape()
Since
QGIS 3.14

Definition at line 161 of file qgsmaplayerlegend.cpp.

◆ setLegendNodeSymbolSize()

void QgsMapLayerLegendUtils::setLegendNodeSymbolSize ( QgsLayerTreeLayer nodeLayer,
int  originalIndex,
QSizeF  size 
)
static

Sets the legend symbol size for the legend node belonging to nodeLayer at the specified originalIndex.

If either the width or height are non-zero, they will be used when rendering the legend node instead of the default symbol width or height from QgsLegendSettings.

See also
legendNodeSymbolSize()
Since
QGIS 3.14

Definition at line 183 of file qgsmaplayerlegend.cpp.

◆ setLegendNodeUserLabel()

void QgsMapLayerLegendUtils::setLegendNodeUserLabel ( QgsLayerTreeLayer nodeLayer,
int  originalIndex,
const QString &  newLabel 
)
static

Definition at line 146 of file qgsmaplayerlegend.cpp.


The documentation for this class was generated from the following files: