QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
#include <qgslayertreemodellegendnode.h>
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... | |
QgsSymbol * | customSymbol () const |
Returns the node's custom symbol. 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... | |
QString | evaluateLabel (const QgsExpressionContext &context=QgsExpressionContext(), const QString &label=QString()) |
Evaluates and returns the text label of the current node. More... | |
QJsonObject | exportSymbolToJson (const QgsLegendSettings &settings, const QgsRenderContext &context) const override |
Adds a symbol in base64 string within a JSON object with the key "icon". 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... | |
QgsLegendPatchShape | patchShape () const |
Returns the symbol patch shape to use when rendering the legend node symbol. More... | |
void | setCustomSymbol (QgsSymbol *symbol) |
Sets the node's custom symbol. 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 | setPatchShape (const QgsLegendPatchShape &shape) |
Sets the symbol patch shape to use when rendering the legend node symbol. 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 QgsSymbol * | symbol () const |
Returns the symbol used by the legend node. More... | |
QString | symbolLabel () const |
Label of the symbol, user defined label will be used, otherwise will default to the label made by QGIS. 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 bool | columnBreak () const |
Returns whether a forced column break should occur before the node. More... | |
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... | |
QJsonObject | exportToJson (const QgsLegendSettings &settings, const QgsRenderContext &context) |
Entry point called from QgsLegendRenderer to do the rendering in a JSON object. More... | |
virtual bool | isEmbeddedInParent () const |
QgsLayerTreeLayer * | layerNode () const |
Returns pointer to the parent layer node. More... | |
QgsLayerTreeModel * | model () const |
Returns pointer to model owning this legend node. More... | |
virtual void | setColumnBreak (bool breakBeforeNode) |
Sets whether a forced column break should occur before the node. More... | |
virtual void | setUserPatchSize (QSizeF size) |
Sets the user (overridden) size for the legend node. More... | |
virtual QString | userLabel () const |
virtual QSizeF | userPatchSize () const |
Returns the user (overridden) size for the legend node. More... | |
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... | |
QgsRenderContext * | createTemporaryRenderContext () const |
Returns a temporary context or nullptr if legendMapViewData are not valid. More... | |
Protected Attributes inherited from QgsLayerTreeModelLegendNode | |
bool | mColumnBreakBeforeNode = false |
bool | mEmbeddedInParent |
QgsLayerTreeLayer * | mLayerNode = nullptr |
QgsLegendPatchShape | mPatchShape |
QString | mUserLabel |
QSizeF | mUserSize |
Implementation of legend node interface for displaying preview of vector symbols and their labels and allowing interaction with the symbol / renderer.
Definition at line 283 of file qgslayertreemodellegendnode.h.
QgsSymbolLegendNode::QgsSymbolLegendNode | ( | QgsLayerTreeLayer * | nodeLayer, |
const QgsLegendSymbolItem & | item, | ||
QObject * | parent = nullptr |
||
) |
Constructor for QgsSymbolLegendNode.
nodeLayer | layer node |
item | the legend symbol item |
parent | attach a parent QObject to the legend node. |
Definition at line 235 of file qgslayertreemodellegendnode.cpp.
|
slot |
Checks all items belonging to the same layer as this node.
Definition at line 365 of file qgslayertreemodellegendnode.cpp.
QgsSymbol * QgsSymbolLegendNode::customSymbol | ( | ) | const |
Returns the node's custom symbol.
If a non-nullptr
value is returned, then this symbol will be used for rendering the legend node instead of the default symbol().
Definition at line 336 of file qgslayertreemodellegendnode.cpp.
|
overridevirtual |
Returns data associated with the item. Must be implemented in derived class.
Implements QgsLayerTreeModelLegendNode.
Definition at line 428 of file qgslayertreemodellegendnode.cpp.
|
overridevirtual |
Draws symbol on the left side of the item.
settings | Legend layout configuration |
ctx | Context for rendering - may be nullptr if only doing layout without actual rendering |
itemHeight | Minimal height of the legend item - used for correct positioning when rendering |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 516 of file qgslayertreemodellegendnode.cpp.
QString QgsSymbolLegendNode::evaluateLabel | ( | const QgsExpressionContext & | context = QgsExpressionContext() , |
const QString & | label = QString() |
||
) |
Evaluates and returns the text label of the current node.
context | extra QgsExpressionContext to use for evaluating the expression |
label | text to evaluate instead of the layer layertree string |
Definition at line 738 of file qgslayertreemodellegendnode.cpp.
|
overridevirtual |
Adds a symbol in base64 string within a JSON object with the key "icon".
settings | Legend layout configuration |
context | Rendering context |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 653 of file qgslayertreemodellegendnode.cpp.
|
overridevirtual |
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 251 of file qgslayertreemodellegendnode.cpp.
|
inline |
Definition at line 320 of file qgslayertreemodellegendnode.h.
|
overridevirtual |
Notification from model that information from associated map view has changed.
Default implementation does nothing.
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 710 of file qgslayertreemodellegendnode.cpp.
|
inlineoverridevirtual |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 310 of file qgslayertreemodellegendnode.h.
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.
Definition at line 260 of file qgslayertreemodellegendnode.cpp.
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().
Definition at line 266 of file qgslayertreemodellegendnode.cpp.
QgsLegendPatchShape QgsSymbolLegendNode::patchShape | ( | ) | const |
Returns the symbol patch shape to use when rendering the legend node symbol.
Definition at line 319 of file qgslayertreemodellegendnode.cpp.
void QgsSymbolLegendNode::setCustomSymbol | ( | QgsSymbol * | symbol | ) |
Sets the node's custom symbol.
If a non-nullptr
value is set, then this symbol will be used for rendering the legend node instead of the default symbol().
Ownership of symbol is transferred.
Definition at line 341 of file qgslayertreemodellegendnode.cpp.
|
overridevirtual |
Sets some data associated with the item. Default implementation does nothing and returns false
.
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 492 of file qgslayertreemodellegendnode.cpp.
|
overridevirtual |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 703 of file qgslayertreemodellegendnode.cpp.
|
inline |
void QgsSymbolLegendNode::setPatchShape | ( | const QgsLegendPatchShape & | shape | ) |
Sets the symbol patch shape to use when rendering the legend node symbol.
Definition at line 331 of file qgslayertreemodellegendnode.cpp.
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.
symbol | new symbol for node. Ownership is transferred. |
Definition at line 346 of file qgslayertreemodellegendnode.cpp.
|
inline |
Sets label of text to be shown on top of the symbol.
Definition at line 365 of file qgslayertreemodellegendnode.h.
|
inline |
Sets format of text to be shown on top of the symbol.
Definition at line 377 of file qgslayertreemodellegendnode.h.
|
inlineoverridevirtual |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 308 of file qgslayertreemodellegendnode.h.
const QgsSymbol * QgsSymbolLegendNode::symbol | ( | ) | const |
Returns the symbol used by the legend node.
Definition at line 300 of file qgslayertreemodellegendnode.cpp.
QString QgsSymbolLegendNode::symbolLabel | ( | ) | const |
Label of the symbol, user defined label will be used, otherwise will default to the label made by QGIS.
Definition at line 305 of file qgslayertreemodellegendnode.cpp.
|
inline |
Returns label of text to be shown on top of the symbol.
Definition at line 359 of file qgslayertreemodellegendnode.h.
|
inline |
Returns text format of the label to be shown on top of the symbol.
Definition at line 371 of file qgslayertreemodellegendnode.h.
|
slot |
Toggle all items belonging to the same layer as this node.
Definition at line 375 of file qgslayertreemodellegendnode.cpp.
|
slot |
Unchecks all items belonging to the same layer as this node.
Definition at line 370 of file qgslayertreemodellegendnode.cpp.