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;
118 int type()
const override;
119 QIcon
icon()
const override;
120 QgsLayoutItem::Flags
itemFlags()
const override;
127 void adjustBoxSize();
135 void setResizeToContents(
bool enabled );
141 bool resizeToContents()
const;
153 void setAutoUpdateModel(
bool autoUpdate );
160 bool autoUpdateModel()
const;
166 void setLegendFilterByMapEnabled(
bool enabled );
179 void setLegendFilterOutAtlas(
bool doFilter );
185 bool legendFilterOutAtlas()
const;
191 void setTitle(
const QString &title );
197 QString title()
const;
203 Qt::AlignmentFlag titleAlignment()
const;
209 void setTitleAlignment( Qt::AlignmentFlag alignment );
252 double lineSpacing()
const;
258 void setLineSpacing(
double spacing );
264 double boxSpace()
const;
270 void setBoxSpace(
double space );
276 double columnSpace()
const;
282 void setColumnSpace(
double spacing );
288 QColor fontColor()
const;
294 void setFontColor(
const QColor &color );
300 double symbolWidth()
const;
306 void setSymbolWidth(
double width );
316 void setSymbolAlignment( Qt::AlignmentFlag alignment );
326 Qt::AlignmentFlag symbolAlignment()
const;
332 double symbolHeight()
const;
338 void setSymbolHeight(
double height );
344 double wmsLegendWidth()
const;
350 void setWmsLegendWidth(
double width );
356 double wmsLegendHeight()
const;
362 void setWmsLegendHeight(
double height );
368 void setWrapString(
const QString &
string );
374 QString wrapString()
const;
380 int columnCount()
const;
386 void setColumnCount(
int count );
393 bool splitLayer()
const;
400 void setSplitLayer(
bool enabled );
406 bool equalColumnWidth()
const;
412 void setEqualColumnWidth(
bool equalize );
420 bool drawRasterStroke()
const;
429 void setDrawRasterStroke(
bool enabled );
438 QColor rasterStrokeColor()
const;
447 void setRasterStrokeColor(
const QColor &color );
456 double rasterStrokeWidth()
const;
465 void setRasterStrokeWidth(
double width );
487 void updateFilterByMap(
bool redraw =
true );
494 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
514 void invalidateCurrentMap();
516 void updateFilterByMapAndRedraw();
520 void mapLayerStyleOverridesChanged();
524 void onAtlasFeature();
526 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
537 std::unique_ptr< QgsLegendModel > mLegendModel;
538 std::unique_ptr< QgsLayerTreeGroup > mCustomLayerTree;
543 int mColumnCount = 1;
548 bool mLegendFilterByMap =
false;
549 bool mLegendFilterByExpression =
false;
552 bool mFilterOutAtlas =
false;
555 bool mFilterAskedForUpdate =
false;
557 void doUpdateFilterByMap();
559 bool mInAtlas =
false;
562 bool mInitialMapScaleCalculated =
false;
565 bool mForceResize =
false;
568 bool mSizeToContents =
true;
574 #endif // QGSLAYOUTITEMLEGEND_H The class is used as a container of context for various read/write operations on other objects...
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
virtual QIcon icon() const
Returns the item's icon.
Item model implementation based on layer tree model for layout legend.
QgsLegendModel * model()
Returns the legend model.
Base class for graphical items within a QgsLayout.
int type() const override
Returns a unique graphics item type identifier.
Abstract base class for all rendered symbols.
const QgsLegendSettings & legendSettings() const
Returns the legend's renderer settings object.
bool legendFilterByMapEnabled() const
Find out whether legend items are filtered to show just the ones visible in the associated map...
Contains detailed styling information relating to how a layout legend should be rendered.
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...
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Layout graphical items for displaying a map.
Namespace with helper functions for layer tree operations.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
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.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
This class is a base class for nodes in a layer tree.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
Style
Component of legends which can be styled.
Contains settings and helpers relating to a render of a QgsLayoutItem.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
virtual QString displayName() const
Gets item display name.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
QgsLayoutItemMap * linkedMap() const
Returns the associated map.
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...
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
Flags flags() const
Returns OR-ed combination of model flags.
A layout item subclass for map legends.
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
DataDefinedProperty
Data defined properties for different item types.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
Layer tree node points to a map layer.
The QgsLegendRenderer class handles automatic layout and rendering of legend.