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;
95 void setResizeToContents(
bool enabled );
101 bool resizeToContents()
const;
113 void setAutoUpdateModel(
bool autoUpdate );
120 bool autoUpdateModel()
const;
126 void setLegendFilterByMapEnabled(
bool enabled );
139 void setLegendFilterOutAtlas(
bool doFilter );
145 bool legendFilterOutAtlas()
const;
151 void setTitle(
const QString &title );
157 QString title()
const;
163 Qt::AlignmentFlag titleAlignment()
const;
169 void setTitleAlignment( Qt::AlignmentFlag alignment );
212 double lineSpacing()
const;
218 void setLineSpacing(
double spacing );
224 double boxSpace()
const;
230 void setBoxSpace(
double space );
236 double columnSpace()
const;
242 void setColumnSpace(
double spacing );
248 QColor fontColor()
const;
254 void setFontColor(
const QColor &color );
260 double symbolWidth()
const;
266 void setSymbolWidth(
double width );
272 double symbolHeight()
const;
278 void setSymbolHeight(
double height );
284 double wmsLegendWidth()
const;
290 void setWmsLegendWidth(
double width );
296 double wmsLegendHeight()
const;
302 void setWmsLegendHeight(
double height );
308 void setWrapString(
const QString &
string );
314 QString wrapString()
const;
320 int columnCount()
const;
326 void setColumnCount(
int count );
333 bool splitLayer()
const;
340 void setSplitLayer(
bool enabled );
346 bool equalColumnWidth()
const;
352 void setEqualColumnWidth(
bool equalize );
360 bool drawRasterStroke()
const;
369 void setDrawRasterStroke(
bool enabled );
378 QColor rasterStrokeColor()
const;
387 void setRasterStrokeColor(
const QColor &color );
396 double rasterStrokeWidth()
const;
405 void setRasterStrokeWidth(
double width );
427 void updateFilterByMap(
bool redraw =
true );
434 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
452 void synchronizeWithModel();
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...
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.
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.
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.
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.
virtual QString displayName() const
Get 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.
virtual void refreshDataDefinedProperty(const QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
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
Return 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.