QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
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;
131 int type()
const override;
132 QIcon
icon()
const override;
133 QgsLayoutItem::Flags
itemFlags()
const override;
140 void adjustBoxSize();
148 void setResizeToContents(
bool enabled );
154 bool resizeToContents()
const;
166 void setAutoUpdateModel(
bool autoUpdate );
173 bool autoUpdateModel()
const;
179 void setLegendFilterByMapEnabled(
bool enabled );
192 void setLegendFilterOutAtlas(
bool doFilter );
198 bool legendFilterOutAtlas()
const;
204 void setTitle(
const QString &title );
210 QString title()
const;
216 Qt::AlignmentFlag titleAlignment()
const;
222 void setTitleAlignment( Qt::AlignmentFlag alignment );
265 double lineSpacing()
const;
271 void setLineSpacing(
double spacing );
277 double boxSpace()
const;
283 void setBoxSpace(
double space );
289 double columnSpace()
const;
295 void setColumnSpace(
double spacing );
301 QColor fontColor()
const;
307 void setFontColor(
const QColor &color );
313 double symbolWidth()
const;
319 void setSymbolWidth(
double width );
329 void setSymbolAlignment( Qt::AlignmentFlag alignment );
339 Qt::AlignmentFlag symbolAlignment()
const;
345 double symbolHeight()
const;
351 void setSymbolHeight(
double height );
357 double wmsLegendWidth()
const;
363 void setWmsLegendWidth(
double width );
369 double wmsLegendHeight()
const;
375 void setWmsLegendHeight(
double height );
381 void setWrapString(
const QString &
string );
387 QString wrapString()
const;
393 int columnCount()
const;
399 void setColumnCount(
int count );
406 bool splitLayer()
const;
413 void setSplitLayer(
bool enabled );
419 bool equalColumnWidth()
const;
425 void setEqualColumnWidth(
bool equalize );
433 bool drawRasterStroke()
const;
442 void setDrawRasterStroke(
bool enabled );
451 QColor rasterStrokeColor()
const;
460 void setRasterStrokeColor(
const QColor &color );
469 double rasterStrokeWidth()
const;
478 void setRasterStrokeWidth(
double width );
499 QString themeName()
const;
509 void updateFilterByMap(
bool redraw =
true );
516 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
537 void invalidateCurrentMap();
539 void updateFilterByMapAndRedraw();
543 void mapLayerStyleOverridesChanged();
545 void mapThemeChanged(
const QString &theme );
549 void onAtlasFeature();
551 void nodeCustomPropertyChanged(
QgsLayerTreeNode *node,
const QString &key );
554 void clearLegendCachedData();
564 void setModelStyleOverrides(
const QMap<QString, QString> &overrides );
566 std::unique_ptr< QgsLegendModel > mLegendModel;
567 std::unique_ptr< QgsLayerTreeGroup > mCustomLayerTree;
572 int mColumnCount = 1;
577 bool mLegendFilterByMap =
false;
578 bool mLegendFilterByExpression =
false;
581 bool mFilterOutAtlas =
false;
584 bool mFilterAskedForUpdate =
false;
586 void doUpdateFilterByMap();
588 bool mInAtlas =
false;
591 bool mInitialMapScaleCalculated =
false;
594 bool mForceResize =
false;
597 bool mSizeToContents =
true;
606 #endif // QGSLAYOUTITEMLEGEND_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Style
Component of legends which can be styled.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual QIcon icon() const
Returns the item's icon.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
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...
QgsLegendModel * model()
Returns the legend model.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
const QgsLegendSettings & legendSettings() const
Returns the legend's renderer settings object.
int type() const override
Returns a unique graphics item type identifier.
@ AllProperties
All properties for item.
bool legendFilterByMapEnabled() const
Find out whether legend items are filtered to show just the ones visible in the associated map.
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
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.
QgsLayoutItemMap * linkedMap() const
Returns the associated map.
Base class for graphical items within a QgsLayout.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
Layout graphical items for displaying a map.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
virtual QString displayName() const
Gets item display name.
Flags flags() const
Returns OR-ed combination of model flags.
The QgsLegendRenderer class handles automatic layout and rendering of legend. The content is given by...
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
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
DataDefinedProperty
Data defined properties for different item types.