QGIS API Documentation
4.3.0-Master (9dce731a7a1)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
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 <memory>
21
22
#include "qgis_core.h"
23
#include "
qgis_sip.h
"
24
#include "
qgslayout.h
"
25
#include "
qgslayoutitem.h
"
26
#include "
qgslayoutitempage.h
"
27
#include "
qgslayoutpoint.h
"
28
#include "
qgslayoutserializableobject.h
"
29
30
#include <QObject>
31
#include <QString>
32
33
using namespace
Qt::StringLiterals;
34
35
class
QgsLayout
;
36
class
QgsLayoutGuideCollection
;
37
class
QgsMargins
;
38
44
class
CORE_EXPORT
QgsLayoutPageCollection
:
public
QObject,
public
QgsLayoutSerializableObject
45
{
46
Q_OBJECT
47
48
public
:
52
explicit
QgsLayoutPageCollection
(
QgsLayout
*
layout
SIP_TRANSFERTHIS
);
53
54
~QgsLayoutPageCollection
()
override
;
55
56
QString
stringType
()
const override
{
return
u
"LayoutPageCollection"
_s; }
57
QgsLayout
*
layout
()
override
;
58
64
QList< QgsLayoutItemPage * > pages();
65
70
int
pageCount()
const
;
71
79
QgsLayoutItemPage
*page(
int
pageNumber );
80
89
const
QgsLayoutItemPage
*page(
int
pageNumber )
const
SIP_SKIP
;
90
95
int
pageNumber(
QgsLayoutItemPage
*page )
const
;
96
102
QList< QgsLayoutItemPage * > visiblePages(
const
QRectF ®ion )
const
;
103
109
QList< int > visiblePageNumbers(
const
QRectF ®ion )
const
;
110
116
bool
pageIsEmpty(
int
page )
const
;
117
121
QList< QgsLayoutItem *> itemsOnPage(
int
page )
const
;
122
127
template
<
class
T>
void
itemsOnPage
( QList<T *> &itemList,
int
page
)
const
SIP_SKIP
128
{
129
itemList.clear();
130
const
QList<QGraphicsItem *> graphicsItemList = mLayout->items();
131
for
( QGraphicsItem *graphicsItem : graphicsItemList )
132
{
133
T *item =
dynamic_cast<
T *
>
( graphicsItem );
134
if
( item && item->page() ==
page
)
135
{
136
itemList.push_back( item );
137
}
138
}
139
}
140
149
bool
shouldExportPage(
int
page )
const
;
150
162
void
addPage(
QgsLayoutItemPage
*page
SIP_TRANSFER
);
163
173
QgsLayoutItemPage
*extendByNewPage();
174
190
void
insertPage(
QgsLayoutItemPage
*page
SIP_TRANSFER
,
int
beforePage );
191
203
void
deletePage(
int
pageNumber );
204
213
void
deletePage(
QgsLayoutItemPage
*page );
214
219
void
clear();
220
224
QgsLayoutItemPage
*takePage(
QgsLayoutItemPage
*page )
SIP_TRANSFERBACK
;
225
232
void
setPageStyleSymbol(
QgsFillSymbol
*symbol );
233
240
Q_DECL_DEPRECATED
const
QgsFillSymbol
*pageStyleSymbol() const
SIP_DEPRECATED
;
241
248
void
beginPageSizeChange();
249
256
void
endPageSizeChange();
257
262
void
reflow();
263
270
double
maximumPageWidth() const;
271
278
QSizeF maximumPageSize() const;
279
286
bool
hasUniformPageSizes() const;
287
302
int
pageNumberForPoint( QPointF point ) const;
303
319
int
predictPageNumberForPoint( QPointF point ) const;
320
331
QgsLayoutItemPage
*pageAtPoint( QPointF point ) const;
332
337
QPointF pagePositionToLayoutPosition(
int
page, const
QgsLayoutPoint
&position ) const;
338
343
QgsLayoutPoint
pagePositionToAbsolute(
int
page, const
QgsLayoutPoint
&position ) const;
344
350
QPointF positionOnPage( QPointF point ) const;
351
355
double
spaceBetweenPages() const;
356
360
double
pageShadowWidth() const;
361
370
void
resizeToContents( const
QgsMargins
&margins,
Qgis
::LayoutUnit marginUnits );
371
376
bool
writeXml( QDomElement &parentElement, QDomDocument &document, const
QgsReadWriteContext
&context ) const override;
377
382
bool
readXml( const QDomElement &collectionElement, const QDomDocument &document, const
QgsReadWriteContext
&context ) override;
383
387
QgsLayoutGuideCollection
&guides();
388
392
SIP_SKIP
const
QgsLayoutGuideCollection
&guides() const;
393
399
void
applyPropertiesToAllOtherPages(
int
sourcePage );
400
401
public slots:
402
406
void
redraw();
407
408
signals:
409
413
void
changed
();
414
421
void
pageAboutToBeRemoved
(
int
pageNumber
);
422
423
private:
424
QgsLayout
*mLayout =
nullptr
;
425
426
std::unique_ptr<
QgsLayoutGuideCollection
> mGuideCollection;
427
429
std::unique_ptr<
QgsFillSymbol
> mPageStyleSymbol;
430
431
QList<
QgsLayoutItemPage
* > mPages;
432
433
bool
mBlockUndoCommands = false;
434
435
QMap< QString, QPair<
int
,
QgsLayoutPoint
> > mPreviousItemPositions;
436
437
void
createDefaultPageStyleSymbol();
438
439
friend class
QgsLayoutPageCollectionUndoCommand
;
440
};
441
442
#endif
//QGSLAYOUTPAGECOLLECTION_H
Qgis
Provides global constants and enumerations for use throughout the application.
Definition
qgis.h:62
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition
qgsfillsymbol.h:30
QgsLayoutGuideCollection
Stores and manages the snap guides used by a layout.
Definition
qgslayoutguidecollection.h:168
QgsLayoutItemPage
Item representing the paper in a layout.
Definition
qgslayoutitempage.h:56
QgsLayoutPageCollection::changed
void changed()
Emitted when pages are added or removed from the collection.
QgsLayoutPageCollection::itemsOnPage
void itemsOnPage(QList< T * > &itemList, int page) const
Returns layout items of a specific type on a specified page.
Definition
qgslayoutpagecollection.h:127
QgsLayoutPageCollection::QgsLayoutPageCollection
QgsLayoutPageCollection(QgsLayout *layout)
Constructor for QgsLayoutItemPage, with the specified parent layout.
Definition
qgslayoutpagecollection.cpp:33
QgsLayoutPageCollection::QgsLayoutPageCollectionUndoCommand
friend class QgsLayoutPageCollectionUndoCommand
Definition
qgslayoutpagecollection.h:439
QgsLayoutPageCollection::layout
QgsLayout * layout() override
Returns the layout the object belongs to.
Definition
qgslayoutpagecollection.cpp:488
QgsLayoutPageCollection::pageAboutToBeRemoved
void pageAboutToBeRemoved(int pageNumber)
Emitted just before a page is removed from the collection.
QgsLayoutPageCollection::page
QgsLayoutItemPage * page(int pageNumber)
Returns a specific page (by pageNumber) from the collection.
Definition
qgslayoutpagecollection.cpp:503
QgsLayoutPageCollection::pageNumber
int pageNumber(QgsLayoutItemPage *page) const
Returns the page number for the specified page, or -1 if the page is not contained in the collection.
Definition
qgslayoutpagecollection.cpp:513
QgsLayoutPageCollection::stringType
QString stringType() const override
Returns the object type as a string.
Definition
qgslayoutpagecollection.h:56
QgsLayoutPoint
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
Definition
qgslayoutpoint.h:47
QgsLayoutSerializableObject
An interface for layout objects which can be stored and read from DOM elements.
Definition
qgslayoutserializableobject.h:35
QgsLayoutSerializableObject::layout
virtual QgsLayout * layout()=0
Returns the layout the object belongs to.
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition
qgslayout.h:51
QgsMargins
Defines the four margins of a rectangle.
Definition
qgsmargins.h:40
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
qgis_sip.h
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition
qgis_sip.h:113
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_SKIP
#define SIP_SKIP
Definition
qgis_sip.h:138
SIP_TRANSFER
#define SIP_TRANSFER
Definition
qgis_sip.h:35
SIP_TRANSFERBACK
#define SIP_TRANSFERBACK
Definition
qgis_sip.h:47
qgslayout.h
qgslayoutitem.h
qgslayoutitempage.h
qgslayoutpoint.h
qgslayoutserializableobject.h
Generated on
for QGIS API Documentation by
1.17.0