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;
453 void invalidateCurrentMap();
455 void updateFilterByMapAndRedraw();
459 void mapLayerStyleOverridesChanged();
463 void onAtlasFeature();
465 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
475 std::unique_ptr< QgsLegendModel > mLegendModel;
476 std::unique_ptr< QgsLayerTreeGroup > mCustomLayerTree;
481 int mColumnCount = 1;
486 bool mLegendFilterByMap =
false;
487 bool mLegendFilterByExpression =
false;
490 bool mFilterOutAtlas =
false;
493 bool mFilterAskedForUpdate =
false;
495 void doUpdateFilterByMap();
497 bool mInAtlas =
false;
500 bool mInitialMapScaleCalculated =
false;
503 bool mForceResize =
false;
506 bool mSizeToContents =
true;
512 #endif // QGSLAYOUTITEMLEGEND_H The class is used as a container of context for various read/write operations on other objects...
Item model implementation based on layer tree model for layout legend.
virtual QIcon icon() const
Returns the item's icon.
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.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
Flags flags() const
Returns OR-ed combination of model flags.
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.
QgsLayoutItemMap * linkedMap() const
Returns the associated map.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
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.
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.
Contains settings and helpers relating to a render of a QgsLayoutItem.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
bool legendFilterByMapEnabled() const
Find out whether legend items are filtered to show just the ones visible in the associated map...
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
const QgsLegendSettings & legendSettings() const
Returns the legend's renderer settings object.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
virtual QString displayName() const
Gets item display name.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
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.