QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsLegendSymbolItem Class Reference

The class stores information about one class/rule of a vector layer renderer in a unified way that can be used by legend model for rendering of legend. More...

#include <qgslegendsymbolitem.h>

Public Member Functions

 QgsLegendSymbolItem ()=default
 
 QgsLegendSymbolItem (const QgsLegendSymbolItem &other)
 
 QgsLegendSymbolItem (QgsSymbol *symbol, const QString &label, const QString &ruleKey, bool checkable=false, int scaleMinDenom=-1, int scaleMaxDenom=-1, int level=0, const QString &parentRuleKey=QString())
 Construct item.
 
 ~QgsLegendSymbolItem ()
 
QgsDataDefinedSizeLegenddataDefinedSizeLegendSettings () const
 Returns extra information for data-defined size legend rendering.
 
bool isCheckable () const
 Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.
 
bool isScaleOK (double scale) const
 Determine whether given scale is within the scale range. Returns true if scale or scale range is invalid (value <= 0)
 
QString label () const
 Returns text label.
 
QgsSymbollegacyRuleKey () const
 Used for older code that identifies legend entries from symbol pointer within renderer.
 
int level () const
 Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0.
 
QgsLegendSymbolItemoperator= (const QgsLegendSymbolItem &other)
 
QString parentRuleKey () const
 Key of the parent legend node.
 
QString ruleKey () const
 Returns unique identifier of the rule for identification of the item within renderer.
 
int scaleMaxDenom () const
 Max scale denominator of the scale range.
 
int scaleMinDenom () const
 Min scale denominator of the scale range.
 
void setDataDefinedSizeLegendSettings (QgsDataDefinedSizeLegend *settings)
 Sets extra information about data-defined size.
 
void setSymbol (QgsSymbol *s)
 Sets the symbol of the item.
 
void setUserData (int key, QVariant &value)
 Adds a key - value pair to the item's user data.
 
QgsSymbolsymbol () const
 Returns associated symbol. May be nullptr.
 
QVariant userData (int key) const
 Retrieves the item's user data with the specified key.
 

Detailed Description

The class stores information about one class/rule of a vector layer renderer in a unified way that can be used by legend model for rendering of legend.

See also
QgsSymbolLegendNode

Definition at line 35 of file qgslegendsymbolitem.h.

Constructor & Destructor Documentation

◆ QgsLegendSymbolItem() [1/3]

QgsLegendSymbolItem::QgsLegendSymbolItem ( )
default

◆ QgsLegendSymbolItem() [2/3]

QgsLegendSymbolItem::QgsLegendSymbolItem ( QgsSymbol symbol,
const QString &  label,
const QString &  ruleKey,
bool  checkable = false,
int  scaleMinDenom = -1,
int  scaleMaxDenom = -1,
int  level = 0,
const QString &  parentRuleKey = QString() 
)

Construct item.

Does not take ownership of symbol (makes internal clone)

Definition at line 21 of file qgslegendsymbolitem.cpp.

◆ ~QgsLegendSymbolItem()

QgsLegendSymbolItem::~QgsLegendSymbolItem ( )

Definition at line 39 of file qgslegendsymbolitem.cpp.

◆ QgsLegendSymbolItem() [3/3]

QgsLegendSymbolItem::QgsLegendSymbolItem ( const QgsLegendSymbolItem other)

Definition at line 34 of file qgslegendsymbolitem.cpp.

Member Function Documentation

◆ dataDefinedSizeLegendSettings()

QgsDataDefinedSizeLegend * QgsLegendSymbolItem::dataDefinedSizeLegendSettings ( ) const

Returns extra information for data-defined size legend rendering.

Normally it returns nullptr.

Definition at line 93 of file qgslegendsymbolitem.cpp.

◆ isCheckable()

bool QgsLegendSymbolItem::isCheckable ( ) const
inline

Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.

Definition at line 57 of file qgslegendsymbolitem.h.

◆ isScaleOK()

bool QgsLegendSymbolItem::isScaleOK ( double  scale) const

Determine whether given scale is within the scale range. Returns true if scale or scale range is invalid (value <= 0)

Definition at line 67 of file qgslegendsymbolitem.cpp.

◆ label()

QString QgsLegendSymbolItem::label ( ) const
inline

Returns text label.

Definition at line 53 of file qgslegendsymbolitem.h.

◆ legacyRuleKey()

QgsSymbol * QgsLegendSymbolItem::legacyRuleKey ( ) const
inline

Used for older code that identifies legend entries from symbol pointer within renderer.

Definition at line 60 of file qgslegendsymbolitem.h.

◆ level()

int QgsLegendSymbolItem::level ( ) const
inline

Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0.

Definition at line 78 of file qgslegendsymbolitem.h.

◆ operator=()

QgsLegendSymbolItem & QgsLegendSymbolItem::operator= ( const QgsLegendSymbolItem other)

Definition at line 45 of file qgslegendsymbolitem.cpp.

◆ parentRuleKey()

QString QgsLegendSymbolItem::parentRuleKey ( ) const
inline

Key of the parent legend node.

For legends with tree hierarchy

Note
Parameter parentRuleKey added in QGIS 2.8

Definition at line 84 of file qgslegendsymbolitem.h.

◆ ruleKey()

QString QgsLegendSymbolItem::ruleKey ( ) const
inline

Returns unique identifier of the rule for identification of the item within renderer.

Definition at line 55 of file qgslegendsymbolitem.h.

◆ scaleMaxDenom()

int QgsLegendSymbolItem::scaleMaxDenom ( ) const
inline

Max scale denominator of the scale range.

For range 1:1000 to 1:2000 this will return 2000. Value <= 0 means the range is unbounded on this side

Definition at line 75 of file qgslegendsymbolitem.h.

◆ scaleMinDenom()

int QgsLegendSymbolItem::scaleMinDenom ( ) const
inline

Min scale denominator of the scale range.

For range 1:1000 to 1:2000 this will return 1000. Value <= 0 means the range is unbounded on this side

Definition at line 69 of file qgslegendsymbolitem.h.

◆ setDataDefinedSizeLegendSettings()

void QgsLegendSymbolItem::setDataDefinedSizeLegendSettings ( QgsDataDefinedSizeLegend settings)

Sets extra information about data-defined size.

If set, this item should be converted to QgsDataDefinedSizeLegendNode rather than QgsSymbolLegendNode instance as usual. Passing nullptr removes any data-defined size legend settings.

Takes ownership of the settings object.

Definition at line 87 of file qgslegendsymbolitem.cpp.

◆ setSymbol()

void QgsLegendSymbolItem::setSymbol ( QgsSymbol s)

Sets the symbol of the item.

Does not take ownership of symbol – an internal clone is made of the symbol.

See also
symbol()

Definition at line 80 of file qgslegendsymbolitem.cpp.

◆ setUserData()

void QgsLegendSymbolItem::setUserData ( int  key,
QVariant &  value 
)

Adds a key - value pair to the item's user data.

See also
userData()
Since
QGIS 3.38

Definition at line 98 of file qgslegendsymbolitem.cpp.

◆ symbol()

QgsSymbol * QgsLegendSymbolItem::symbol ( ) const
inline

Returns associated symbol. May be nullptr.

Definition at line 51 of file qgslegendsymbolitem.h.

◆ userData()

QVariant QgsLegendSymbolItem::userData ( int  key) const

Retrieves the item's user data with the specified key.

See also
setUserData()
Since
QGIS 3.38

Definition at line 103 of file qgslegendsymbolitem.cpp.


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