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;
141 bool layerShown(
QgsMapLayer *layer )
const override;
143 bool mIsDefaultLegend =
true;
144 bool mFilterToCheckedLayers =
false;
178 int type()
const override;
179 QIcon
icon()
const override;
283 void setLegendFilterOutAtlas(
bool doFilter );
289 bool legendFilterOutAtlas()
const;
295 void setTitle(
const QString &title );
301 QString title()
const;
307 Qt::AlignmentFlag titleAlignment()
const;
313 void setTitleAlignment( Qt::AlignmentFlag alignment );
370 Q_DECL_DEPRECATED
void setLineSpacing(
double spacing )
SIP_DEPRECATED;
376 double boxSpace() const;
382 void setBoxSpace(
double space );
388 double columnSpace() const;
394 void setColumnSpace(
double spacing );
410 Q_DECL_DEPRECATED
void setFontColor( const QColor &color )
SIP_DEPRECATED;
416 double symbolWidth() const;
422 void setSymbolWidth(
double width );
430 double maximumSymbolSize() const;
440 void setMaximumSymbolSize(
double size );
448 double minimumSymbolSize() const;
458 void setMinimumSymbolSize(
double size );
468 void setSymbolAlignment( Qt::AlignmentFlag alignment );
478 Qt::AlignmentFlag symbolAlignment() const;
484 double symbolHeight() const;
490 void setSymbolHeight(
double height );
496 double wmsLegendWidth() const;
502 void setWmsLegendWidth(
double width );
508 double wmsLegendHeight() const;
514 void setWmsLegendHeight(
double height );
520 void setWrapString( const QString &
string );
526 QString wrapString() const;
532 int columnCount() const;
538 void setColumnCount(
int count );
545 bool splitLayer() const;
552 void setSplitLayer(
bool enabled );
558 bool equalColumnWidth() const;
564 void setEqualColumnWidth(
bool equalize );
572 bool drawRasterStroke() const;
581 void setDrawRasterStroke(
bool enabled );
590 QColor rasterStrokeColor() const;
599 void setRasterStrokeColor( const QColor &color );
608 double rasterStrokeWidth() const;
617 void setRasterStrokeWidth(
double width );
629 double autoWrapLinesAfter() const;
641 void setAutoWrapLinesAfter(
double length );
664 void setFilterByMapItems(
const QList< QgsLayoutItemMap * > &maps );
674 QList< QgsLayoutItemMap * > filterByMapItems()
const;
683 QString themeName()
const;
693 void updateFilterByMap(
bool redraw =
true );
700 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
702 void finalizeRestoreFromXml()
override;
705 ExportLayerBehavior exportLayerBehavior()
const override;
707 bool isRefreshing()
const override;
711 void refresh()
override;
712 void invalidateCache()
override;
717 bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const override;
718 bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context )
override;
723 void invalidateCurrentMap();
725 void updateFilterByMapAndRedraw();
729 void mapLayerStyleOverridesChanged();
731 void mapThemeChanged(
const QString &theme );
735 void onAtlasFeature();
741 void clearLegendCachedData();
751 void setModelStyleOverrides(
const QMap<QString, QString> &overrides );
753 void ensureModelIsInitialized()
const;
760 bool requiresFilteringBecauseOfRendererSetting();
764 std::unique_ptr< QgsLegendModel > mLegendModel;
765 std::unique_ptr< QgsLayerTree > mCustomLayerTree;
769 bool mDeferLegendModelInitialization =
true;
774 int mColumnCount = 1;
779 QList< QString > mFilterByMapUuids;
780 QList< QPointer< QgsLayoutItemMap >> mFilterByMapItems;
782 bool mLegendFilterByMap =
false;
783 bool mLegendFilterByExpression =
false;
786 bool mFilterOutAtlas =
false;
789 bool mFilterAskedForUpdate =
false;
791 void doUpdateFilterByMap();
793 bool mInAtlas =
false;
796 bool mInitialMapScaleCalculated =
false;
799 bool mForceResize =
false;
802 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.