18 #ifndef QGSLAYOUTITEMLEGEND_H 19 #define QGSLAYOUTITEMLEGEND_H 21 #include "qgis_core.h" 49 QVariant
data(
const QModelIndex &index,
int role )
const override;
51 Qt::ItemFlags
flags(
const QModelIndex &index )
const override;
79 int type()
const override;
80 QIcon
icon()
const override;
81 QgsLayoutItem::Flags
itemFlags()
const override;
96 void setResizeToContents(
bool enabled );
102 bool resizeToContents()
const;
114 void setAutoUpdateModel(
bool autoUpdate );
121 bool autoUpdateModel()
const;
127 void setLegendFilterByMapEnabled(
bool enabled );
140 void setLegendFilterOutAtlas(
bool doFilter );
146 bool legendFilterOutAtlas()
const;
152 void setTitle(
const QString &title );
158 QString title()
const;
164 Qt::AlignmentFlag titleAlignment()
const;
170 void setTitleAlignment( Qt::AlignmentFlag alignment );
213 double lineSpacing()
const;
219 void setLineSpacing(
double spacing );
225 double boxSpace()
const;
231 void setBoxSpace(
double space );
237 double columnSpace()
const;
243 void setColumnSpace(
double spacing );
249 QColor fontColor()
const;
255 void setFontColor(
const QColor &color );
261 double symbolWidth()
const;
267 void setSymbolWidth(
double width );
273 double symbolHeight()
const;
279 void setSymbolHeight(
double height );
285 double wmsLegendWidth()
const;
291 void setWmsLegendWidth(
double width );
297 double wmsLegendHeight()
const;
303 void setWmsLegendHeight(
double height );
309 void setWrapString(
const QString &
string );
315 QString wrapString()
const;
321 int columnCount()
const;
327 void setColumnCount(
int count );
334 bool splitLayer()
const;
341 void setSplitLayer(
bool enabled );
347 bool equalColumnWidth()
const;
353 void setEqualColumnWidth(
bool equalize );
361 bool drawRasterStroke()
const;
370 void setDrawRasterStroke(
bool enabled );
379 QColor rasterStrokeColor()
const;
388 void setRasterStrokeColor(
const QColor &color );
397 double rasterStrokeWidth()
const;
406 void setRasterStrokeWidth(
double width );
428 void updateFilterByMap(
bool redraw =
true );
435 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
455 void invalidateCurrentMap();
457 void updateFilterByMapAndRedraw();
461 void mapLayerStyleOverridesChanged();
465 void onAtlasFeature();
467 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
477 std::unique_ptr< QgsLegendModel > mLegendModel;
478 std::unique_ptr< QgsLayerTreeGroup > mCustomLayerTree;
483 int mColumnCount = 1;
488 bool mLegendFilterByMap =
false;
489 bool mLegendFilterByExpression =
false;
492 bool mFilterOutAtlas =
false;
495 bool mFilterAskedForUpdate =
false;
497 void doUpdateFilterByMap();
499 bool mInAtlas =
false;
502 bool mInitialMapScaleCalculated =
false;
505 bool mForceResize =
false;
508 bool mSizeToContents =
true;
514 #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...
Composer legend components style.
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.
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.
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.
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.
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...
The QgsLegendRenderer class handles automatic layout and rendering of legend.