QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgslayoutitemgroup.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemgroup.h
3 ---------------------
4 begin : October 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSLAYOUTITEMGROUP_H
18#define QGSLAYOUTITEMGROUP_H
19
20#include "qgis_core.h"
21#include "qgslayoutitem.h"
22
27class CORE_EXPORT QgsLayoutItemGroup: public QgsLayoutItem
28{
29 Q_OBJECT
30
31 public:
32
36 explicit QgsLayoutItemGroup( QgsLayout *layout );
37 ~QgsLayoutItemGroup() override;
38
39 void cleanup() override;
40
41 int type() const override;
42 QString displayName() const override;
43
49 static QgsLayoutItemGroup *create( QgsLayout *layout ) SIP_FACTORY;
50
55 void addItem( QgsLayoutItem *item SIP_TRANSFER );
56
61 void removeItems();
62
66 QList<QgsLayoutItem *> items() const;
67
68 //overridden to also hide grouped items
69 void setVisibility( bool visible ) override;
70
71 //overridden to move child items
72 void attemptMove( const QgsLayoutPoint &point, bool useReferencePoint = true, bool includesFrame = false, int page = -1 ) override;
73 void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;
74
75 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
76
77 void finalizeRestoreFromXml() override;
79
80 QRectF rectWithFrame() const override;
81
82 protected:
83 void draw( QgsLayoutItemRenderContext &context ) override;
84 bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
85 bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
86
87 private slots:
88 void updateBoundingRect();
89
90 private:
91
92 QList< QString > mItemUuids;
93 QList< QPointer< QgsLayoutItem >> mItems;
94 QRectF mRectWithFrame;
95};
96
97#endif //QGSLAYOUTITEMGROUP_H
98
99
100
A container for grouping several QgsLayoutItems.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:43
Base class for graphical items within a QgsLayout.
friend class QgsLayoutItemGroup
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
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.
virtual QRectF rectWithFrame() const
Returns the item's rectangular bounds, including any bleed caused by the item's frame.
virtual void setVisibility(bool visible)
Sets whether the item is visible.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
int type() const override
Returns a unique graphics item type identifier.
virtual QString displayName() const
Gets item display name.
virtual void attemptResize(const QgsLayoutSize &size, bool includesFrame=false)
Attempts to resize the item to a specified target size.
virtual void attemptMove(const QgsLayoutPoint &point, bool useReferencePoint=true, bool includesFrame=false, int page=-1)
Attempts to move the item to a specified point.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
This class provides a method of storing points, consisting of an x and y coordinate,...
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:40
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
The class is used as a container of context for various read/write operations on other objects.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76