QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
28 class CORE_EXPORT QgsLayoutItemGroup: public QgsLayoutItem
29 {
30  Q_OBJECT
31 
32  public:
33 
37  explicit QgsLayoutItemGroup( QgsLayout *layout );
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  protected:
80  void draw( QgsLayoutItemRenderContext &context ) override;
81  bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
82  bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
83 
84  private:
85 
86  void resetBoundingRect();
87  void updateBoundingRect( QgsLayoutItem *item );
88  void setSceneRect( const QRectF &rectangle );
89 
90  QList< QString > mItemUuids;
91  QList< QPointer< QgsLayoutItem >> mItems;
92  QRectF mBoundingRectangle;
93 };
94 
95 #endif //QGSLAYOUTITEMGROUP_H
96 
97 
98 
QgsLayoutItem::cleanup
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
Definition: qgslayoutitem.cpp:99
QgsLayoutItem::writePropertiesToElement
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
Definition: qgslayoutitem.cpp:1325
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsLayoutItem::finalizeRestoreFromXml
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Definition: qgslayoutitem.cpp:824
QgsLayoutItemRenderContext
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:45
QgsLayoutItem::readPropertiesFromElement
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
Definition: qgslayoutitem.cpp:1330
QgsLayoutItem::draw
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsLayoutItem::type
int type() const override
Returns a unique graphics item type identifier.
Definition: qgslayoutitem.cpp:124
QgsLayoutItem::exportLayerBehavior
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
Definition: qgslayoutitem.cpp:247
QgsLayoutItem::ExportLayerBehavior
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
Definition: qgslayoutitem.h:428
qgslayoutitem.h
QgsLayoutItem::setVisibility
virtual void setVisibility(bool visible)
Sets whether the item is visible.
Definition: qgslayoutitem.cpp:170
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsLayoutItem::paint
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.
Definition: qgslayoutitem.cpp:285
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:113
QgsLayoutItemGroup
A container for grouping several QgsLayoutItems.
Definition: qgslayoutitemgroup.h:29
QgsLayoutItem::attemptMove
virtual void attemptMove(const QgsLayoutPoint &point, bool useReferencePoint=true, bool includesFrame=false, int page=-1)
Attempts to move the item to a specified point.
Definition: qgslayoutitem.cpp:466
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsLayoutItem::displayName
virtual QString displayName() const
Gets item display name.
Definition: qgslayoutitem.cpp:107
QgsLayoutItem::attemptResize
virtual void attemptResize(const QgsLayoutSize &size, bool includesFrame=false)
Attempts to resize the item to a specified target size.
Definition: qgslayoutitem.cpp:428
QgsLayoutSize
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:41
QgsLayoutItem::QgsLayoutItemGroup
friend class QgsLayoutItemGroup
Definition: qgslayoutitem.h:1320
QgsLayoutPoint
This class provides a method of storing points, consisting of an x and y coordinate,...
Definition: qgslayoutpoint.h:40