18#ifndef QGSLAYOUTITEMLEGEND_H
19#define QGSLAYOUTITEMLEGEND_H
54 QVariant
data(
const QModelIndex &
index,
int role )
const override;
56 Qt::ItemFlags
flags(
const QModelIndex &
index )
const override;
131 bool layerShown(
QgsMapLayer *layer )
const override;
133 bool mIsDefaultLegend =
true;
160 int type()
const override;
161 QIcon
icon()
const override;
230 void setLegendFilterOutAtlas(
bool doFilter );
236 bool legendFilterOutAtlas()
const;
242 void setTitle(
const QString &title );
248 QString title()
const;
254 Qt::AlignmentFlag titleAlignment()
const;
260 void setTitleAlignment( Qt::AlignmentFlag alignment );
317 Q_DECL_DEPRECATED
void setLineSpacing(
double spacing )
SIP_DEPRECATED;
323 double boxSpace() const;
329 void setBoxSpace(
double space );
335 double columnSpace() const;
341 void setColumnSpace(
double spacing );
357 Q_DECL_DEPRECATED
void setFontColor( const QColor &color )
SIP_DEPRECATED;
363 double symbolWidth() const;
369 void setSymbolWidth(
double width );
377 double maximumSymbolSize() const;
387 void setMaximumSymbolSize(
double size );
395 double minimumSymbolSize() const;
405 void setMinimumSymbolSize(
double size );
415 void setSymbolAlignment( Qt::AlignmentFlag alignment );
425 Qt::AlignmentFlag symbolAlignment() const;
431 double symbolHeight() const;
437 void setSymbolHeight(
double height );
443 double wmsLegendWidth() const;
449 void setWmsLegendWidth(
double width );
455 double wmsLegendHeight() const;
461 void setWmsLegendHeight(
double height );
467 void setWrapString( const QString &
string );
473 QString wrapString() const;
479 int columnCount() const;
485 void setColumnCount(
int count );
492 bool splitLayer() const;
499 void setSplitLayer(
bool enabled );
505 bool equalColumnWidth() const;
511 void setEqualColumnWidth(
bool equalize );
519 bool drawRasterStroke() const;
528 void setDrawRasterStroke(
bool enabled );
537 QColor rasterStrokeColor() const;
546 void setRasterStrokeColor( const QColor &color );
555 double rasterStrokeWidth() const;
564 void setRasterStrokeWidth(
double width );
576 double autoWrapLinesAfter() const;
588 void setAutoWrapLinesAfter(
double length );
611 void setFilterByMapItems(
const QList< QgsLayoutItemMap * > &maps );
621 QList< QgsLayoutItemMap * > filterByMapItems()
const;
630 QString themeName()
const;
640 void updateFilterByMap(
bool redraw =
true );
647 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
649 void finalizeRestoreFromXml()
override;
652 ExportLayerBehavior exportLayerBehavior()
const override;
654 bool isRefreshing()
const override;
658 void refresh()
override;
659 void invalidateCache()
override;
664 bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const override;
665 bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context )
override;
670 void invalidateCurrentMap();
672 void updateFilterByMapAndRedraw();
676 void mapLayerStyleOverridesChanged();
678 void mapThemeChanged(
const QString &theme );
682 void onAtlasFeature();
687 void clearLegendCachedData();
697 void setModelStyleOverrides(
const QMap<QString, QString> &overrides );
699 void ensureModelIsInitialized()
const;
703 std::unique_ptr< QgsLegendModel > mLegendModel;
704 std::unique_ptr< QgsLayerTree > mCustomLayerTree;
705 bool mDeferLegendModelInitialization =
true;
710 int mColumnCount = 1;
715 QList< QString > mFilterByMapUuids;
716 QList< QPointer< QgsLayoutItemMap >> mFilterByMapItems;
718 bool mLegendFilterByMap =
false;
719 bool mLegendFilterByExpression =
false;
722 bool mFilterOutAtlas =
false;
725 bool mFilterAskedForUpdate =
false;
727 void doUpdateFilterByMap();
729 bool mInAtlas =
false;
732 bool mInitialMapScaleCalculated =
false;
735 bool mForceResize =
false;
738 bool mSizeToContents =
true;
LegendComponent
Component of legends which can be styled.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QModelIndex parent(const QModelIndex &child) const override
QgsLayerTreeFilterProxyModel(QObject *parent=nullptr)
Constructor.
Layer tree node points to a map layer.
A model representing the layer tree, including layers and groups of layers.
Flags flags() const
Returns OR-ed combination of model flags.
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
void nodeCustomPropertyChanged(QgsLayerTreeNode *node, const QString &key)
QgsLayerTreeModel(QgsLayerTree *rootNode, QObject *parent=nullptr)
Construct a new tree model with given layer tree (root node must not be nullptr).
QModelIndex parent(const QModelIndex &child) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Base class for nodes in a layer tree.
Namespace with helper functions for layer tree operations.
A layout item subclass for map legends.
bool autoUpdateModel() const
Returns whether the legend content should auto update to reflect changes in the project's layer tree.
QgsLegendModel * model()
Returns the legend model.
void adjustBoxSize()
Sets the legend's item bounds to fit the whole legend content.
QgsLayoutItemMap * linkedMap() const
Returns the associated map.
static QgsLayoutItemLegend * create(QgsLayout *layout)
Returns a new legend item for the specified layout.
bool requiresRasterization() const override
Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when ex...
const QgsLegendSettings & legendSettings() const
Returns the legend's renderer settings object.
bool resizeToContents() const
Returns whether the legend should automatically resize to fit its contents.
void setResizeToContents(bool enabled)
Sets whether the legend should automatically resize to fit its contents.
QgsLayoutItemLegend(QgsLayout *layout)
Constructor for QgsLayoutItemLegend, with the specified parent layout.
QString displayName() const override
Gets item display name.
int type() const override
QgsLayoutItem::Flags itemFlags() const override
Returns the item's flags, which indicate how the item behaves.
void setLegendFilterByMapEnabled(bool enabled)
Set whether legend items should be filtered to show just the ones visible in the associated map.
friend class QgsCompositionConverter
void setAutoUpdateModel(bool autoUpdate)
Sets whether the legend content should auto update to reflect changes in the project's layer tree.
QIcon icon() const override
Returns the item's icon.
bool containsAdvancedEffects() const override
Returns true if the item contains contents with blend modes or transparency effects which can only be...
bool legendFilterByMapEnabled() const
Find out whether legend items are filtered to show just the ones visible in the associated map.
Layout graphical items for displaying a map.
Contains settings and helpers relating to a render of a QgsLayoutItem.
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
friend class QgsLayoutItemMap
const QgsLayout * layout() const
Returns the layout the object is attached to.
DataDefinedProperty
Data defined properties for different item types.
@ AllProperties
All properties for item.
void setIsDefaultLegend(bool isDefault)
Sets whether the legend is showing the default legend for a project (as opposed to a customized legen...
QgsLegendFilterProxyModel(QObject *parent=nullptr)
Constructor for QgsLegendFilterProxyModel, with the specified parent object.
Item model implementation based on layer tree model for layout legend.
void clearCachedData(QgsLayerTreeNode *node) const
Clears any previously cached data for the specified node.
void refreshLegend()
Emitted to refresh the legend.
QgsLegendModel(QgsLayerTree *rootNode, QObject *parent=nullptr, QgsLayoutItemLegend *layout=nullptr)
Construct the model based on the given layer tree.
Handles automatic layout and rendering of legends.
Stores the appearance and layout settings for legend drawing with QgsLegendRenderer.
Contains detailed styling information relating to how a layout legend should be rendered.
Base class for all map layer types.
A container for the context for various read/write operations on objects.
An interface for classes which can visit style entity (e.g.
Abstract base class for all rendered symbols.