QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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
37 ~QgsLayoutItemGroup() override;
38
39 void cleanup() override;
40
41 int type() const override;
42 QString displayName() const override;
43
50
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
void removeItems()
Removes all items from the group (but does not delete them).
void addItem(QgsLayoutItem *item)
Adds an item to the group.
QgsLayoutItemGroup(QgsLayout *layout)
Constructor for QgsLayoutItemGroup, belonging to the specified layout.
QList< QgsLayoutItem * > items() const
Returns a list of items contained by the group.
static QgsLayoutItemGroup * create(QgsLayout *layout)
Returns a new group item for the specified layout.
Contains settings and helpers relating to a render of a QgsLayoutItem.
friend class QgsLayoutItemGroup
friend class QgsLayout
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
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.
int page() const
Returns the page the item is currently on, with the first page returning 0.
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.
const QgsLayout * layout() const
Returns the layout the object is attached to.
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
A container for the context for various read/write operations on objects.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84