QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
18 #ifndef QGSLAYOUTITEMLEGEND_H
19 #define QGSLAYOUTITEMLEGEND_H
21 #include "qgis_core.h"
54 QVariant
data(
const QModelIndex &index,
int role )
const override;
56 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
131 int type()
const override;
132 QIcon
icon()
const override;
133 QgsLayoutItem::Flags
itemFlags()
const override;
140 void adjustBoxSize();
148 void setResizeToContents(
bool enabled );
154 bool resizeToContents()
const;
166 void setAutoUpdateModel(
bool autoUpdate );
173 bool autoUpdateModel()
const;
179 void setLegendFilterByMapEnabled(
bool enabled );
192 void setLegendFilterOutAtlas(
bool doFilter );
198 bool legendFilterOutAtlas()
const;
204 void setTitle(
const QString &title );
210 QString title()
const;
216 Qt::AlignmentFlag titleAlignment()
const;
222 void setTitleAlignment( Qt::AlignmentFlag alignment );
265 double lineSpacing()
const;
271 void setLineSpacing(
double spacing );
277 double boxSpace()
const;
283 void setBoxSpace(
double space );
289 double columnSpace()
const;
295 void setColumnSpace(
double spacing );
301 QColor fontColor()
const;
307 void setFontColor(
const QColor &color );
313 double symbolWidth()
const;
319 void setSymbolWidth(
double width );
327 double maximumSymbolSize()
const;
337 void setMaximumSymbolSize(
double size );
345 double minimumSymbolSize()
const;
355 void setMinimumSymbolSize(
double size );
365 void setSymbolAlignment( Qt::AlignmentFlag alignment );
375 Qt::AlignmentFlag symbolAlignment()
const;
381 double symbolHeight()
const;
387 void setSymbolHeight(
double height );
393 double wmsLegendWidth()
const;
399 void setWmsLegendWidth(
double width );
405 double wmsLegendHeight()
const;
411 void setWmsLegendHeight(
double height );
417 void setWrapString(
const QString &
string );
423 QString wrapString()
const;
429 int columnCount()
const;
435 void setColumnCount(
int count );
442 bool splitLayer()
const;
449 void setSplitLayer(
bool enabled );
455 bool equalColumnWidth()
const;
461 void setEqualColumnWidth(
bool equalize );
469 bool drawRasterStroke()
const;
478 void setDrawRasterStroke(
bool enabled );
487 QColor rasterStrokeColor()
const;
496 void setRasterStrokeColor(
const QColor &color );
505 double rasterStrokeWidth()
const;
514 void setRasterStrokeWidth(
double width );
535 QString themeName()
const;
545 void updateFilterByMap(
bool redraw =
true );
552 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
573 void invalidateCurrentMap();
575 void updateFilterByMapAndRedraw();
579 void mapLayerStyleOverridesChanged();
581 void mapThemeChanged(
const QString &theme );
585 void onAtlasFeature();
587 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
590 void clearLegendCachedData();
600 void setModelStyleOverrides(
const QMap<QString, QString> &overrides );
602 std::unique_ptr< QgsLegendModel > mLegendModel;
603 std::unique_ptr< QgsLayerTreeGroup > mCustomLayerTree;
608 int mColumnCount = 1;
613 bool mLegendFilterByMap =
false;
614 bool mLegendFilterByExpression =
false;
617 bool mFilterOutAtlas =
false;
620 bool mFilterAskedForUpdate =
false;
622 void doUpdateFilterByMap();
624 bool mInAtlas =
false;
627 bool mInitialMapScaleCalculated =
false;
630 bool mForceResize =
false;
633 bool mSizeToContents =
true;
642 #endif // QGSLAYOUTITEMLEGEND_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Style
Component of legends which can be styled.
This class is a base class for nodes in a layer tree.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
The class is used as a container of context for various read/write operations on other objects.
virtual QIcon icon() const
Returns the item's icon.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Contains settings and helpers relating to a render of a QgsLayoutItem.
An interface for classes which can visit style entity (e.g.
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
QgsLegendModel * model()
Returns the legend model.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Abstract base class for all rendered symbols.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
void refreshLegend()
Emitted to refresh the legend.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
const QgsLegendSettings & legendSettings() const
Returns the legend's renderer settings object.
int type() const override
Returns a unique graphics item type identifier.
A layout item subclass for map legends.
@ AllProperties
All properties for item.
bool legendFilterByMapEnabled() const
Find out whether legend items are filtered to show just the ones visible in the associated map.
Namespace with helper functions for layer tree operations.
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
Layer tree node points to a map layer.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Handles preparing a paint surface for the layout item and painting the item's content.
QgsLayoutItemMap * linkedMap() const
Returns the associated map.
Base class for graphical items within a QgsLayout.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
Layout graphical items for displaying a map.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
virtual QString displayName() const
Gets item display name.
Flags flags() const
Returns OR-ed combination of model flags.
The QgsLegendRenderer class handles automatic layout and rendering of legend.
QList< QgsLayerTreeModelLegendNode * > layerLegendNodes(QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent=false)
Returns filtered list of active legend nodes attached to a particular layer node (by default it retur...
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Item model implementation based on layer tree model for layout legend.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
DataDefinedProperty
Data defined properties for different item types.
Contains detailed styling information relating to how a layout legend should be rendered.