QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
19 #ifndef QGSLAYERTREEMODELLEGENDNODE_H
20 #define QGSLAYERTREEMODELLEGENDNODE_H
25 #include "qgis_core.h"
57 if ( qobject_cast<QgsSymbolLegendNode *> ( sipCpp ) )
58 sipType = sipType_QgsSymbolLegendNode;
59 else if ( qobject_cast<QgsDataDefinedSizeLegendNode *> ( sipCpp ) )
60 sipType = sipType_QgsDataDefinedSizeLegendNode;
61 else if ( qobject_cast<QgsImageLegendNode *> ( sipCpp ) )
62 sipType = sipType_QgsImageLegendNode;
63 else if ( qobject_cast<QgsRasterSymbolLegendNode *> ( sipCpp ) )
64 sipType = sipType_QgsRasterSymbolLegendNode;
65 else if ( qobject_cast<QgsSimpleLegendNode *> ( sipCpp ) )
66 sipType = sipType_QgsSimpleLegendNode;
67 else if ( qobject_cast<QgsWmsLegendNode *> ( sipCpp ) )
68 sipType = sipType_QgsWmsLegendNode;
69 else if ( qobject_cast<QgsColorRampLegendNode *> ( sipCpp ) )
70 sipType = sipType_QgsColorRampLegendNode;
83 RuleKeyRole = Qt::UserRole,
108 virtual Qt::ItemFlags flags()
const;
111 virtual QVariant data(
int role )
const = 0;
114 virtual bool setData(
const QVariant &value,
int role );
119 virtual QString
userLabel()
const {
return mUserLabel; }
120 virtual void setUserLabel(
const QString &userLabel ) { mUserLabel = userLabel; }
131 virtual QSizeF userPatchSize()
const;
142 virtual void setUserPatchSize( QSizeF size );
150 virtual void setColumnBreak(
bool breakBeforeNode ) { mColumnBreakBeforeNode = breakBeforeNode; }
158 virtual bool columnBreak()
const {
return mColumnBreakBeforeNode; }
160 virtual bool isScaleOK(
double scale )
const { Q_UNUSED( scale )
return true; }
177 QPainter *painter =
nullptr;
189 Q_DECL_DEPRECATED
double labelXOffset = 0.0;
203 double columnLeft = 0.0;
211 double columnRight = 0.0;
218 double maxSiblingSymbolWidth = 0.0;
294 void checkAllItems();
302 void uncheckAllItems();
310 void toggleAllItems();
332 bool mEmbeddedInParent;
336 bool mColumnBreakBeforeNode = false;
344 void checkAll(
bool state );
348 #include "qgslegendsymbolitem.h"
375 Qt::ItemFlags
flags()
const override;
376 QVariant
data(
int role )
const override;
377 bool setData(
const QVariant &value,
int role )
override;
387 bool isScaleOK(
double scale )
const override {
return mItem.isScaleOK( scale ); }
406 QSize minimumIconSize()
const;
460 QString symbolLabel()
const;
515 mutable QPixmap mPixmap;
517 bool mSymbolUsesMapUnits;
521 QString mTextOnSymbolLabel;
524 std::unique_ptr< QgsSymbol > mCustomSymbol;
527 static const int INDENT_SIZE = 20;
560 QVariant
data(
int role )
const override;
590 QVariant
data(
int role )
const override;
623 Qt::ItemFlags
flags()
const override;
624 QVariant
data(
int role )
const override;
625 bool setData(
const QVariant &value,
int role )
override;
646 bool mCheckable =
false;
673 QVariant
data(
int role )
const override;
683 void getLegendGraphicFinished(
const QImage & );
684 void getLegendGraphicErrored(
const QString & );
685 void getLegendGraphicProgress( qint64, qint64 );
690 QImage getLegendGraphic()
const;
692 QImage renderMessage(
const QString &msg )
const;
698 mutable std::unique_ptr<QgsImageFetcher> mFetcher;
716 QVariant
data(
int role )
const override;
721 void cacheImage()
const;
723 mutable QImage mImage;
749 QVariant
data(
int role )
const override;
771 void textWidthHeight(
double &width,
double &height,
QgsRenderContext &ctx,
const QgsTextFormat &textFormat,
const QStringList &textLines )
const;
775 #endif // QGSLAYERTREEMODELLEGENDNODE_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isCheckable() const
Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.
Handles asynchronous download of images.
static double MINIMUM_SIZE
virtual bool isEmbeddedInParent() const
QgsTextFormat textOnSymbolTextFormat() const
Returns text format of the label to be shown on top of the symbol.
virtual void invalidateMapBasedData()
Notification from model that information from associated map view has changed.
virtual QVariant data(int role) const =0
Returns data associated with the item. Must be implemented in derived class.
static double MAXIMUM_SIZE
QSizeF patchSize
Symbol patch size to render for the node.
Contains settings for how a map layer will be labeled.
Implementation of legend node interface for displaying arbitrary label with icon.
@ SimpleLegend
Simple label with icon legend node type.
Q_DECL_DEPRECATED QPointF point
Top-left corner of the legend item.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Contains information about the context of a rendering operation.
bool isScaleOK(double scale) const override
QgsLegendPatchShape patchShape
The patch shape to render for the node.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Abstract base class for all rendered symbols.
Produces legend node with a marker symbol.
LegendNodeRoles
Legend node data roles.
Represents a patch shape for use in map legends.
Produces legend node for a labeling text symbol.
virtual QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const
Adds a symbol in base64 string within a JSON object with the key "icon".
virtual QString userLabel() const
virtual Qt::ItemFlags flags() const
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
virtual ItemMetrics draw(const QgsLegendSettings &settings, ItemContext *ctx)
Entry point called from QgsLegendRenderer to do the rendering.
#define Q_NOWARN_DEPRECATED_POP
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Container for all settings relating to text rendering.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
@ EmbeddedWidget
Embedded widget placeholder node type.
@ NodeTypeRole
Type of node. Added in 3.16.
@ ImageLegend
Raster image legend node type.
@ DataDefinedSizeLegend
Marker symbol legend node type.
@ ColorRampLegend
Color ramp legend (since QGIS 3.18)
Layer tree node points to a map layer.
void setTextOnSymbolTextFormat(const QgsTextFormat &format)
Sets format of text to be shown on top of the symbol.
void setIconSize(QSize sz)
Set the icon size.
void setTextOnSymbolLabel(const QString &label)
Sets label of text to be shown on top of the symbol.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
Implementation of legend node interface for displaying WMS legend entries.
NodeTypes
Types of legend nodes.
@ ParentRuleKeyRole
Rule key of the parent legend node - for legends with tree hierarchy (QString). Added in 2....
virtual void setEmbeddedInParent(bool embedded)
@ RasterSymbolLegend
Raster symbol legend node type.
virtual bool columnBreak() const
Returns whether a forced column break should occur before the node.
Single scope for storing variables and functions for use within a QgsExpressionContext....
virtual bool setData(const QVariant &value, int role)
Sets some data associated with the item. Default implementation does nothing and returns false.
virtual void setUserLabel(const QString &userLabel)
QgsLayerTreeLayer * layerNode() const
Returns pointer to the parent layer node.
void setUserLabel(const QString &userLabel) override
Implementation of legend node interface for displaying arbitrary raster image.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QString ruleKey() const
Returns the unique identifier of node for identification of the item within renderer.
QString textOnSymbolLabel() const
Returns label of text to be shown on top of the symbol.
Implementation of legend node interface for displaying raster legend entries.
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item.
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
virtual bool isScaleOK(double scale) const
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
#define Q_NOWARN_DEPRECATED_PUSH
@ SymbolLegend
Vector symbol legend node type.
@ WmsLegend
WMS legend node type.
virtual void setColumnBreak(bool breakBeforeNode)
Sets whether a forced column break should occur before the node.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...