QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgslayoutpagecollection.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutpagecollection.h
3 --------------------------
4 begin : July 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 QGSLAYOUTPAGECOLLECTION_H
18#define QGSLAYOUTPAGECOLLECTION_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgslayout.h"
23#include "qgslayoutitempage.h"
24#include "qgslayoutitem.h"
26#include "qgslayoutpoint.h"
27#include <QObject>
28#include <memory>
29
30class QgsLayout;
32class QgsMargins;
33
40class CORE_EXPORT QgsLayoutPageCollection : public QObject, public QgsLayoutSerializableObject
41{
42
43 Q_OBJECT
44
45 public:
46
51
52 ~QgsLayoutPageCollection() override;
53
54 QString stringType() const override { return QStringLiteral( "LayoutPageCollection" ); }
55 QgsLayout *layout() override;
56
62 QList< QgsLayoutItemPage * > pages();
63
68 int pageCount() const;
69
77 QgsLayoutItemPage *page( int pageNumber );
78
87 const QgsLayoutItemPage *page( int pageNumber ) const SIP_SKIP;
88
93 int pageNumber( QgsLayoutItemPage *page ) const;
94
100 QList< QgsLayoutItemPage * > visiblePages( const QRectF &region ) const;
101
107 QList< int > visiblePageNumbers( const QRectF &region ) const;
108
114 bool pageIsEmpty( int page ) const;
115
119 QList< QgsLayoutItem *> itemsOnPage( int page ) const;
120
125 template<class T> void itemsOnPage( QList<T *> &itemList, int page ) const SIP_SKIP
126 {
127 itemList.clear();
128 const QList<QGraphicsItem *> graphicsItemList = mLayout->items();
129 for ( QGraphicsItem *graphicsItem : graphicsItemList )
130 {
131 T *item = dynamic_cast<T *>( graphicsItem );
132 if ( item && item->page() == page )
133 {
134 itemList.push_back( item );
135 }
136 }
137 }
138
147 bool shouldExportPage( int page ) const;
148
160 void addPage( QgsLayoutItemPage *page SIP_TRANSFER );
161
171 QgsLayoutItemPage *extendByNewPage();
172
188 void insertPage( QgsLayoutItemPage *page SIP_TRANSFER, int beforePage );
189
201 void deletePage( int pageNumber );
202
211 void deletePage( QgsLayoutItemPage *page );
212
217 void clear();
218
223
230 void setPageStyleSymbol( QgsFillSymbol *symbol );
231
238 Q_DECL_DEPRECATED const QgsFillSymbol *pageStyleSymbol() const SIP_DEPRECATED;
239
246 void beginPageSizeChange();
247
254 void endPageSizeChange();
255
260 void reflow();
261
268 double maximumPageWidth() const;
269
276 QSizeF maximumPageSize() const;
277
284 bool hasUniformPageSizes() const;
285
300 int pageNumberForPoint( QPointF point ) const;
301
317 int predictPageNumberForPoint( QPointF point ) const;
318
329 QgsLayoutItemPage *pageAtPoint( QPointF point ) const;
330
335 QPointF pagePositionToLayoutPosition( int page, const QgsLayoutPoint &position ) const;
336
341 QgsLayoutPoint pagePositionToAbsolute( int page, const QgsLayoutPoint &position ) const;
342
348 QPointF positionOnPage( QPointF point ) const;
349
353 double spaceBetweenPages() const;
354
358 double pageShadowWidth() const;
359
368 void resizeToContents( const QgsMargins &margins, Qgis::LayoutUnit marginUnits );
369
374 bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
375
380 bool readXml( const QDomElement &collectionElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
381
385 QgsLayoutGuideCollection &guides();
386
390 SIP_SKIP const QgsLayoutGuideCollection &guides() const;
391
392 public slots:
393
397 void redraw();
398
399 signals:
400
404 void changed();
405
412 void pageAboutToBeRemoved( int pageNumber );
413
414 private:
415
416 QgsLayout *mLayout = nullptr;
417
418 std::unique_ptr< QgsLayoutGuideCollection > mGuideCollection;
419
421 std::unique_ptr< QgsFillSymbol > mPageStyleSymbol;
422
423 QList< QgsLayoutItemPage * > mPages;
424
425 bool mBlockUndoCommands = false;
426
427 QMap< QString, QPair< int, QgsLayoutPoint > > mPreviousItemPositions;
428
429 void createDefaultPageStyleSymbol();
430
431 friend class QgsLayoutPageCollectionUndoCommand;
432};
433
434#endif //QGSLAYOUTPAGECOLLECTION_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Stores and manages the snap guides used by a layout.
Item representing the paper in a layout.
A manager for a collection of pages in a layout.
void itemsOnPage(QList< T * > &itemList, int page) const
Returns layout items of a specific type on a specified page.
QString stringType() const override
Returns the object type as a string.
This class provides a method of storing points, consisting of an x and y coordinate,...
An interface for layout objects which can be stored and read from DOM elements.
virtual QgsLayout * layout()=0
Returns the layout the object belongs to.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
The QgsMargins class defines the four margins of a rectangle.
Definition qgsmargins.h:38
The class is used as a container of context for various read/write operations on other objects.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_TRANSFERBACK
Definition qgis_sip.h:48