18#ifndef QGSLAYOUTITEMLEGEND_H
19#define QGSLAYOUTITEMLEGEND_H
55 QVariant
data(
const QModelIndex &
index,
int role )
const override;
57 Qt::ItemFlags
flags(
const QModelIndex &
index )
const override;
137 bool layerShown(
QgsMapLayer *layer )
const override;
139 bool mIsDefaultLegend =
true;
140 bool mFilterToCheckedLayers =
false;
172 int type()
const override;
173 QIcon
icon()
const override;
277 void setLegendFilterOutAtlas(
bool doFilter );
283 bool legendFilterOutAtlas()
const;
289 void setTitle(
const QString &title );
295 QString title()
const;
301 Qt::AlignmentFlag titleAlignment()
const;
307 void setTitleAlignment( Qt::AlignmentFlag alignment );
364 Q_DECL_DEPRECATED
void setLineSpacing(
double spacing )
SIP_DEPRECATED;
370 double boxSpace() const;
376 void setBoxSpace(
double space );
382 double columnSpace() const;
388 void setColumnSpace(
double spacing );
404 Q_DECL_DEPRECATED
void setFontColor( const QColor &color )
SIP_DEPRECATED;
410 double symbolWidth() const;
416 void setSymbolWidth(
double width );
424 double maximumSymbolSize() const;
434 void setMaximumSymbolSize(
double size );
442 double minimumSymbolSize() const;
452 void setMinimumSymbolSize(
double size );
462 void setSymbolAlignment( Qt::AlignmentFlag alignment );
472 Qt::AlignmentFlag symbolAlignment() const;
478 double symbolHeight() const;
484 void setSymbolHeight(
double height );
490 double wmsLegendWidth() const;
496 void setWmsLegendWidth(
double width );
502 double wmsLegendHeight() const;
508 void setWmsLegendHeight(
double height );
514 void setWrapString( const QString &
string );
520 QString wrapString() const;
526 int columnCount() const;
532 void setColumnCount(
int count );
539 bool splitLayer() const;
546 void setSplitLayer(
bool enabled );
552 bool equalColumnWidth() const;
558 void setEqualColumnWidth(
bool equalize );
566 bool drawRasterStroke() const;
575 void setDrawRasterStroke(
bool enabled );
584 QColor rasterStrokeColor() const;
593 void setRasterStrokeColor( const QColor &color );
602 double rasterStrokeWidth() const;
611 void setRasterStrokeWidth(
double width );
623 double autoWrapLinesAfter() const;
635 void setAutoWrapLinesAfter(
double length );
658 void setFilterByMapItems(
const QList< QgsLayoutItemMap * > &maps );
668 QList< QgsLayoutItemMap * > filterByMapItems()
const;
677 QString themeName()
const;
687 void updateFilterByMap(
bool redraw =
true );
694 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
696 void finalizeRestoreFromXml()
override;
699 ExportLayerBehavior exportLayerBehavior()
const override;
701 bool isRefreshing()
const override;
705 void refresh()
override;
706 void invalidateCache()
override;
711 bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const override;
712 bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context )
override;
717 void invalidateCurrentMap();
719 void updateFilterByMapAndRedraw();
723 void mapLayerStyleOverridesChanged();
725 void mapThemeChanged(
const QString &theme );
729 void onAtlasFeature();
735 void clearLegendCachedData();
745 void setModelStyleOverrides(
const QMap<QString, QString> &overrides );
747 void ensureModelIsInitialized()
const;
754 bool requiresFilteringBecauseOfRendererSetting();
758 std::unique_ptr< QgsLegendModel > mLegendModel;
759 std::unique_ptr< QgsLayerTree > mCustomLayerTree;
763 bool mDeferLegendModelInitialization =
true;
768 int mColumnCount = 1;
773 QList< QString > mFilterByMapUuids;
774 QList< QPointer< QgsLayoutItemMap >> mFilterByMapItems;
776 bool mLegendFilterByMap =
false;
777 bool mLegendFilterByExpression =
false;
780 bool mFilterOutAtlas =
false;
783 bool mFilterAskedForUpdate =
false;
785 void doUpdateFilterByMap();
787 bool mInAtlas =
false;
790 bool mInitialMapScaleCalculated =
false;
793 bool mForceResize =
false;
796 bool mSizeToContents =
true;
Provides global constants and enumerations for use throughout the application.
LegendComponent
Component of legends which can be styled.
LegendSyncMode
Legend synchronization mode.
@ AllProjectLayers
Synchronize to all project layers.
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
void nodeVisibilityChanged(QgsLayerTreeNode *node)
Base class for nodes in a layer tree.
Namespace with helper functions for layer tree operations.
A layout item subclass for map legends.
Q_DECL_DEPRECATED 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.
Qgis::LegendSyncMode syncMode() const
Returns the legend's synchronization mode.
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...
static const QgsSettingsEntryEnumFlag< Qgis::LegendSyncMode > * settingDefaultLegendSyncMode
Settings entry - Layout legend synchronization mode.
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 setSyncMode(Qgis::LegendSyncMode mode)
Sets the legend's synchronization mode.
Q_DECL_DEPRECATED 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...
void resetManualLayers(Qgis::LegendSyncMode mode)
Resets the current legend manual configuration, including layer set and settings.
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...
void setFilterToCheckedLayers(bool filter)
Sets whether only checked layers should be shown.
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.