QGIS API Documentation  3.6.0-Noosa (5873452)
Public Slots | Public Member Functions | List of all members
QgsSymbolLegendNode Class Reference

Implementation of legend node interface for displaying preview of vector symbols and their labels and allowing interaction with the symbol / renderer. More...

#include <qgslayertreemodellegendnode.h>

Inheritance diagram for QgsSymbolLegendNode:
Inheritance graph
[legend]

Public Slots

void checkAllItems ()
 Checks all items belonging to the same layer as this node. More...
 
void toggleAllItems ()
 Toggle all items belonging to the same layer as this node. More...
 
void uncheckAllItems ()
 Unchecks all items belonging to the same layer as this node. More...
 

Public Member Functions

 QgsSymbolLegendNode (QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent=nullptr)
 Constructor for QgsSymbolLegendNode. More...
 
QVariant data (int role) const override
 Returns data associated with the item. Must be implemented in derived class. More...
 
QSizeF drawSymbol (const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
 Draws symbol on the left side of the item. More...
 
Qt::ItemFlags flags () const override
 Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. More...
 
QSize iconSize () const
 
void invalidateMapBasedData () override
 Notification from model that information from associated map view has changed. More...
 
bool isScaleOK (double scale) const override
 
QSize minimumIconSize () const
 Calculates the minimum icon size to prevent cropping. More...
 
QSize minimumIconSize (QgsRenderContext *context) const
 Calculates the minimum icon size to prevent cropping. More...
 
bool setData (const QVariant &value, int role) override
 Sets some data associated with the item. Default implementation does nothing and returns false. More...
 
void setEmbeddedInParent (bool embedded) override
 
void setIconSize (QSize sz)
 Set the icon size. More...
 
void setSymbol (QgsSymbol *symbol)
 Sets the symbol to be used by the legend node. More...
 
void setTextOnSymbolLabel (const QString &label)
 Sets label of text to be shown on top of the symbol. More...
 
void setTextOnSymbolTextFormat (const QgsTextFormat &format)
 Sets format of text to be shown on top of the symbol. More...
 
void setUserLabel (const QString &userLabel) override
 
const QgsSymbolsymbol () const
 Returns the symbol used by the legend node. More...
 
QString textOnSymbolLabel () const
 Returns label of text to be shown on top of the symbol. More...
 
QgsTextFormat textOnSymbolTextFormat () const
 Returns text format of the label to be shown on top of the symbol. More...
 
- Public Member Functions inherited from QgsLayerTreeModelLegendNode
virtual ItemMetrics draw (const QgsLegendSettings &settings, ItemContext *ctx)
 Entry point called from QgsLegendRenderer to do the rendering. More...
 
virtual QSizeF drawSymbolText (const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const
 Draws label on the right side of the item. More...
 
virtual bool isEmbeddedInParent () const
 
QgsLayerTreeLayerlayerNode () const
 Returns pointer to the parent layer node. More...
 
QgsLayerTreeModelmodel () const
 Returns pointer to model owning this legend node. More...
 
virtual QString userLabel () const
 

Additional Inherited Members

- Public Types inherited from QgsLayerTreeModelLegendNode
enum  LegendNodeRoles { RuleKeyRole = Qt::UserRole, ParentRuleKeyRole }
 
- Signals inherited from QgsLayerTreeModelLegendNode
void dataChanged ()
 Emitted on internal data change so the layer tree model can forward the signal to views. More...
 
- Protected Member Functions inherited from QgsLayerTreeModelLegendNode
 QgsLayerTreeModelLegendNode (QgsLayerTreeLayer *nodeL, QObject *parent=nullptr)
 Construct the node with pointer to its parent layer node. More...
 
QgsRenderContextcreateTemporaryRenderContext () const
 Returns a temporary context or null if legendMapViewData are not valid. More...
 
- Protected Attributes inherited from QgsLayerTreeModelLegendNode
bool mEmbeddedInParent
 
QgsLayerTreeLayermLayerNode = nullptr
 
QString mUserLabel
 

Detailed Description

Implementation of legend node interface for displaying preview of vector symbols and their labels and allowing interaction with the symbol / renderer.

Since
QGIS 2.6

Definition at line 158 of file qgslayertreemodellegendnode.h.

Constructor & Destructor Documentation

◆ QgsSymbolLegendNode()

QgsSymbolLegendNode::QgsSymbolLegendNode ( QgsLayerTreeLayer nodeLayer,
const QgsLegendSymbolItem item,
QObject *  parent = nullptr 
)

Constructor for QgsSymbolLegendNode.

Parameters
nodeLayerlayer node
itemthe legend symbol item
parentattach a parent QObject to the legend node.

Definition at line 134 of file qgslayertreemodellegendnode.cpp.

Member Function Documentation

◆ checkAllItems

void QgsSymbolLegendNode::checkAllItems ( )
slot

Checks all items belonging to the same layer as this node.

See also
uncheckAllItems()
toggleAllItems()
Since
QGIS 2.14

Definition at line 226 of file qgslayertreemodellegendnode.cpp.

◆ data()

QVariant QgsSymbolLegendNode::data ( int  role) const
overridevirtual

Returns data associated with the item. Must be implemented in derived class.

Implements QgsLayerTreeModelLegendNode.

Definition at line 287 of file qgslayertreemodellegendnode.cpp.

◆ drawSymbol()

QSizeF QgsSymbolLegendNode::drawSymbol ( const QgsLegendSettings settings,
ItemContext ctx,
double  itemHeight 
) const
overridevirtual

Draws symbol on the left side of the item.

Parameters
settingsLegend layout configuration
ctxContext for rendering - may be null if only doing layout without actual rendering
itemHeightMinimal height of the legend item - used for correct positioning when rendering
Returns
Real size of the symbol (may be bigger than "normal" symbol size from settings)

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 386 of file qgslayertreemodellegendnode.cpp.

◆ flags()

Qt::ItemFlags QgsSymbolLegendNode::flags ( ) const
overridevirtual

Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 150 of file qgslayertreemodellegendnode.cpp.

◆ iconSize()

QSize QgsSymbolLegendNode::iconSize ( ) const
inline
Since
QGIS 2.10

Definition at line 192 of file qgslayertreemodellegendnode.h.

◆ invalidateMapBasedData()

void QgsSymbolLegendNode::invalidateMapBasedData ( )
overridevirtual

Notification from model that information from associated map view has changed.

Default implementation does nothing.

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 501 of file qgslayertreemodellegendnode.cpp.

◆ isScaleOK()

bool QgsSymbolLegendNode::isScaleOK ( double  scale) const
inlineoverridevirtual

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 182 of file qgslayertreemodellegendnode.h.

◆ minimumIconSize() [1/2]

QSize QgsSymbolLegendNode::minimumIconSize ( ) const

Calculates the minimum icon size to prevent cropping.

When evaluating the size for multiple icons it is more efficient to create a single render context in advance and use the variant which accepts a QgsRenderContext argument.

Since
QGIS 2.10

Definition at line 159 of file qgslayertreemodellegendnode.cpp.

◆ minimumIconSize() [2/2]

QSize QgsSymbolLegendNode::minimumIconSize ( QgsRenderContext context) const

Calculates the minimum icon size to prevent cropping.

When evaluating the size for multiple icons it is more efficient to create a single render context in advance and call this method instead of minimumIconSize().

Since
QGIS 2.18

Definition at line 165 of file qgslayertreemodellegendnode.cpp.

◆ setData()

bool QgsSymbolLegendNode::setData ( const QVariant &  value,
int  role 
)
overridevirtual

Sets some data associated with the item. Default implementation does nothing and returns false.

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 362 of file qgslayertreemodellegendnode.cpp.

◆ setEmbeddedInParent()

void QgsSymbolLegendNode::setEmbeddedInParent ( bool  embedded)
overridevirtual

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 494 of file qgslayertreemodellegendnode.cpp.

◆ setIconSize()

void QgsSymbolLegendNode::setIconSize ( QSize  sz)
inline

Set the icon size.

Since
QGIS 2.10

Definition at line 190 of file qgslayertreemodellegendnode.h.

◆ setSymbol()

void QgsSymbolLegendNode::setSymbol ( QgsSymbol symbol)

Sets the symbol to be used by the legend node.

The symbol change is also propagated to the associated vector layer's renderer.

Parameters
symbolnew symbol for node. Ownership is transferred.
See also
symbol()
Since
QGIS 2.14

Definition at line 207 of file qgslayertreemodellegendnode.cpp.

◆ setTextOnSymbolLabel()

void QgsSymbolLegendNode::setTextOnSymbolLabel ( const QString &  label)
inline

Sets label of text to be shown on top of the symbol.

Since
QGIS 3.2

Definition at line 237 of file qgslayertreemodellegendnode.h.

◆ setTextOnSymbolTextFormat()

void QgsSymbolLegendNode::setTextOnSymbolTextFormat ( const QgsTextFormat format)
inline

Sets format of text to be shown on top of the symbol.

Since
QGIS 3.2

Definition at line 249 of file qgslayertreemodellegendnode.h.

◆ setUserLabel()

void QgsSymbolLegendNode::setUserLabel ( const QString &  userLabel)
inlineoverridevirtual

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 180 of file qgslayertreemodellegendnode.h.

◆ symbol()

const QgsSymbol * QgsSymbolLegendNode::symbol ( ) const

Returns the symbol used by the legend node.

See also
setSymbol()
Since
QGIS 2.14

Definition at line 202 of file qgslayertreemodellegendnode.cpp.

◆ textOnSymbolLabel()

QString QgsSymbolLegendNode::textOnSymbolLabel ( ) const
inline

Returns label of text to be shown on top of the symbol.

Since
QGIS 3.2

Definition at line 231 of file qgslayertreemodellegendnode.h.

◆ textOnSymbolTextFormat()

QgsTextFormat QgsSymbolLegendNode::textOnSymbolTextFormat ( ) const
inline

Returns text format of the label to be shown on top of the symbol.

Since
QGIS 3.2

Definition at line 243 of file qgslayertreemodellegendnode.h.

◆ toggleAllItems

void QgsSymbolLegendNode::toggleAllItems ( )
slot

Toggle all items belonging to the same layer as this node.

See also
checkAllItems()
uncheckAllItems()
Since
QGIS 3.6

Definition at line 236 of file qgslayertreemodellegendnode.cpp.

◆ uncheckAllItems

void QgsSymbolLegendNode::uncheckAllItems ( )
slot

Unchecks all items belonging to the same layer as this node.

See also
checkAllItems()
toggleAllItems()
Since
QGIS 2.14

Definition at line 231 of file qgslayertreemodellegendnode.cpp.


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