QGIS API Documentation
3.0.2-Girona (307d082)
|
A manager for a collection of pages in a layout. More...
#include <qgslayoutpagecollection.h>
Public Slots | |
void | redraw () |
Triggers a redraw for all pages. More... | |
Signals | |
void | changed () |
Emitted when pages are added or removed from the collection. More... | |
void | pageAboutToBeRemoved (int pageNumber) |
Emitted just before a page is removed from the collection. More... | |
Public Member Functions | |
QgsLayoutPageCollection (QgsLayout *layout) | |
Constructor for QgsLayoutItemPage, with the specified parent layout. More... | |
~QgsLayoutPageCollection () override | |
void | addPage (QgsLayoutItemPage *page) |
Adds a page to the collection. More... | |
void | beginPageSizeChange () |
Should be called before changing any page item sizes, and followed by a call to endPageSizeChange(). More... | |
void | clear () |
Removes all pages from the collection. More... | |
void | deletePage (int pageNumber) |
Deletes a page from the collection. More... | |
void | deletePage (QgsLayoutItemPage *page) |
Deletes a page from the collection. More... | |
void | endPageSizeChange () |
Should be called after changing any page item sizes, and preceded by a call to beginPageSizeChange(). More... | |
QgsLayoutItemPage * | extendByNewPage () |
Adds a new page to the end of the collection. More... | |
QgsLayoutGuideCollection & | guides () |
Returns a reference to the collection's guide collection, which manages page snap guides. More... | |
const QgsLayoutGuideCollection & | guides () const |
Returns a reference to the collection's guide collection, which manages page snap guides. More... | |
bool | hasUniformPageSizes () const |
Returns true if the layout has uniform page sizes, e.g. More... | |
void | insertPage (QgsLayoutItemPage *page, int beforePage) |
Inserts a page into a specific position in the collection. More... | |
QList< QgsLayoutItem * > | itemsOnPage (int page) const |
Returns a list of layout items on the specified page index. More... | |
template<class T > | |
void | itemsOnPage (QList< T *> &itemList, int page) const |
Returns layout items of a specific type on a specified page. More... | |
QgsLayout * | layout () override |
Returns the layout the object belongs to. More... | |
QSizeF | maximumPageSize () const |
Returns the maximum size of any page in the collection, by area. More... | |
double | maximumPageWidth () const |
Returns the maximum width of pages in the collection. More... | |
QgsLayoutItemPage * | page (int pageNumber) |
Returns a specific page (by pageNumber) from the collection. More... | |
const QgsLayoutItemPage * | page (int pageNumber) const |
Returns a specific page (by pageNumber) from the collection. More... | |
QgsLayoutItemPage * | pageAtPoint (QPointF point) const |
Returns the page at a specified point (in layout coordinates). More... | |
int | pageCount () const |
Returns the number of pages in the collection. More... | |
bool | pageIsEmpty (int page) const |
Returns whether a given page index is empty, ie, it contains no items except for the background paper item. More... | |
int | pageNumber (QgsLayoutItemPage *page) const |
Returns the page number for the specified page, or -1 if the page is not contained in the collection. More... | |
int | pageNumberForPoint (QPointF point) const |
Returns the page number corresponding to a point in the layout (in layout units). More... | |
QgsLayoutPoint | pagePositionToAbsolute (int page, const QgsLayoutPoint &position) const |
Converts a position on a page to an absolute position in (maintaining the units from the input position). More... | |
QPointF | pagePositionToLayoutPosition (int page, const QgsLayoutPoint &position) const |
Converts a position on a page to an absolute position in layout coordinates. More... | |
QList< QgsLayoutItemPage *> | pages () |
Returns a list of pages in the collection. More... | |
double | pageShadowWidth () const |
Returns the size of the page shadow, in layout units. More... | |
const QgsFillSymbol * | pageStyleSymbol () const |
Returns the symbol to use for drawing pages in the collection. More... | |
QPointF | positionOnPage (QPointF point) const |
Returns the position within a page of a point in the layout (in layout units). More... | |
int | predictPageNumberForPoint (QPointF point) const |
Returns the theoretical page number corresponding to a point in the layout (in layout units), assuming that enough pages exist in the layout to cover that point. More... | |
bool | readXml (const QDomElement &collectionElement, const QDomDocument &document, const QgsReadWriteContext &context) override |
Sets the collection's state from a DOM element. More... | |
void | reflow () |
Forces the page collection to reflow the arrangement of pages, e.g. More... | |
void | resizeToContents (const QgsMargins &margins, QgsUnitTypes::LayoutUnit marginUnits) |
Resizes the layout to a single page which fits the current contents of the layout. More... | |
void | setPageStyleSymbol (QgsFillSymbol *symbol) |
Sets the symbol to use for drawing pages in the collection. More... | |
bool | shouldExportPage (int page) const |
Returns whether the specified page number should be included in exports of the layouts. More... | |
double | spaceBetweenPages () const |
Returns the space between pages, in layout units. More... | |
QString | stringType () const override |
Return the object type as a string. More... | |
QgsLayoutItemPage * | takePage (QgsLayoutItemPage *page) |
Takes a page from the collection, returning ownership of the page to the caller. More... | |
QList< int > | visiblePageNumbers (QRectF region) const |
Returns a list of the page numbers which are visible within the specified region (in layout coordinates). More... | |
QList< QgsLayoutItemPage *> | visiblePages (QRectF region) const |
Returns a list of the pages which are visible within the specified region (in layout coordinates). More... | |
bool | writeXml (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const override |
Stores the collection's state in a DOM element. More... | |
Public Member Functions inherited from QgsLayoutSerializableObject | |
QgsAbstractLayoutUndoCommand * | createCommand (const QString &text, int id, QUndoCommand *parent=nullptr) override |
Creates a new layout undo command with the specified text and parent. More... | |
Public Member Functions inherited from QgsLayoutUndoObjectInterface | |
virtual | ~QgsLayoutUndoObjectInterface ()=default |
Destructor for QgsLayoutUndoObjectInterface. More... | |
Friends | |
class | QgsLayoutPageCollectionUndoCommand |
A manager for a collection of pages in a layout.
Definition at line 40 of file qgslayoutpagecollection.h.
|
explicit |
Constructor for QgsLayoutItemPage, with the specified parent layout.
Definition at line 26 of file qgslayoutpagecollection.cpp.
|
override |
Definition at line 34 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::addPage | ( | QgsLayoutItemPage * | page | ) |
Adds a page to the collection.
Ownership of the page is transferred to the collection, and the page will automatically be added to the collection's layout() (there is no need to manually add the page item to the layout). The page will be added after all pages currently contained in the collection.
Calling addPage() automatically triggers a reflow() of pages.
Definition at line 541 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::beginPageSizeChange | ( | ) |
Should be called before changing any page item sizes, and followed by a call to endPageSizeChange().
If page size changes are wrapped in these calls, then items will maintain their same relative position on pages after the page sizes are updated.
Definition at line 57 of file qgslayoutpagecollection.cpp.
|
signal |
Emitted when pages are added or removed from the collection.
void QgsLayoutPageCollection::clear | ( | ) |
Removes all pages from the collection.
Definition at line 672 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::deletePage | ( | int | pageNumber | ) |
Deletes a page from the collection.
The page will automatically be removed from the collection's layout().
Page numbers in collections begin at 0 - so a pageNumber of 0 will delete the first page in the collection.
Calling deletePage() automatically triggers a reflow() of pages.
Definition at line 604 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::deletePage | ( | QgsLayoutItemPage * | page | ) |
Deletes a page from the collection.
The page will automatically be removed from the collection's layout().
Calling deletePage() automatically triggers a reflow() of pages.
Definition at line 638 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::endPageSizeChange | ( | ) |
Should be called after changing any page item sizes, and preceded by a call to beginPageSizeChange().
If page size changes are wrapped in these calls, then items will maintain their same relative position on pages after the page sizes are updated.
Definition at line 72 of file qgslayoutpagecollection.cpp.
QgsLayoutItemPage * QgsLayoutPageCollection::extendByNewPage | ( | ) |
Adds a new page to the end of the collection.
This page will inherit the same size as the current final page in the collection.
The newly created page will be returned.
Definition at line 552 of file qgslayoutpagecollection.cpp.
QgsLayoutGuideCollection & QgsLayoutPageCollection::guides | ( | ) |
Returns a reference to the collection's guide collection, which manages page snap guides.
Definition at line 409 of file qgslayoutpagecollection.cpp.
const QgsLayoutGuideCollection & QgsLayoutPageCollection::guides | ( | ) | const |
Returns a reference to the collection's guide collection, which manages page snap guides.
Definition at line 414 of file qgslayoutpagecollection.cpp.
bool QgsLayoutPageCollection::hasUniformPageSizes | ( | ) | const |
Returns true if the layout has uniform page sizes, e.g.
all pages are the same size.
This method does not consider differing units as non-uniform sizes, only the actual physical size of the pages.
Definition at line 130 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::insertPage | ( | QgsLayoutItemPage * | page, |
int | beforePage | ||
) |
Inserts a page into a specific position in the collection.
Ownership of the page is transferred to the collection, and the page will automatically be added to the collection's layout() (there is no need to manually add the page item to the layout).
The page will be added after before the page number specified by beforePage. (Page numbers in collections begin at 0 - so a beforePage of 0 will insert the page before all existing pages).
Calling insertPage() automatically triggers a reflow() of pages.
Definition at line 564 of file qgslayoutpagecollection.cpp.
QList< QgsLayoutItem * > QgsLayoutPageCollection::itemsOnPage | ( | int | page | ) | const |
Returns a list of layout items on the specified page index.
Definition at line 500 of file qgslayoutpagecollection.cpp.
|
inline |
Returns layout items of a specific type on a specified page.
Definition at line 125 of file qgslayoutpagecollection.h.
|
overridevirtual |
Returns the layout the object belongs to.
Implements QgsLayoutSerializableObject.
Definition at line 427 of file qgslayoutpagecollection.cpp.
QSizeF QgsLayoutPageCollection::maximumPageSize | ( | ) | const |
Returns the maximum size of any page in the collection, by area.
The returned value is in layout units.
Definition at line 113 of file qgslayoutpagecollection.cpp.
double QgsLayoutPageCollection::maximumPageWidth | ( | ) | const |
Returns the maximum width of pages in the collection.
The returned value is in layout units.
Definition at line 103 of file qgslayoutpagecollection.cpp.
QgsLayoutItemPage * QgsLayoutPageCollection::page | ( | int | pageNumber | ) |
Returns a specific page (by pageNumber) from the collection.
Internal page numbering starts at 0 - so a pageNumber of 0 corresponds to the first page in the collection. A nullptr is returned if an invalid page number is specified.
Definition at line 442 of file qgslayoutpagecollection.cpp.
const QgsLayoutItemPage * QgsLayoutPageCollection::page | ( | int | pageNumber | ) | const |
Returns a specific page (by pageNumber) from the collection.
Internal page numbering starts at 0 - so a pageNumber of 0 corresponds to the first page in the collection. A nullptr is returned if an invalid page number is specified.
Definition at line 447 of file qgslayoutpagecollection.cpp.
|
signal |
Emitted just before a page is removed from the collection.
Page numbers in collections begin at 0 - so a page number of 0 indicates the first page.
QgsLayoutItemPage * QgsLayoutPageCollection::pageAtPoint | ( | QPointF | point | ) | const |
Returns the page at a specified point (in layout coordinates).
If no page exists at point, nullptr will be returned.
Definition at line 195 of file qgslayoutpagecollection.cpp.
int QgsLayoutPageCollection::pageCount | ( | ) | const |
Returns the number of pages in the collection.
Definition at line 437 of file qgslayoutpagecollection.cpp.
bool QgsLayoutPageCollection::pageIsEmpty | ( | int | page | ) | const |
Returns whether a given page index is empty, ie, it contains no items except for the background paper item.
Definition at line 481 of file qgslayoutpagecollection.cpp.
int QgsLayoutPageCollection::pageNumber | ( | QgsLayoutItemPage * | page | ) | const |
Returns the page number for the specified page, or -1 if the page is not contained in the collection.
Definition at line 452 of file qgslayoutpagecollection.cpp.
int QgsLayoutPageCollection::pageNumberForPoint | ( | QPointF | point | ) | const |
Returns the page number corresponding to a point in the layout (in layout units).
Page numbers in collections begin at 0 - so a page number of 0 indicates the first page.
Definition at line 148 of file qgslayoutpagecollection.cpp.
QgsLayoutPoint QgsLayoutPageCollection::pagePositionToAbsolute | ( | int | page, |
const QgsLayoutPoint & | position | ||
) | const |
Converts a position on a page to an absolute position in (maintaining the units from the input position).
Definition at line 220 of file qgslayoutpagecollection.cpp.
QPointF QgsLayoutPageCollection::pagePositionToLayoutPosition | ( | int | page, |
const QgsLayoutPoint & | position | ||
) | const |
Converts a position on a page to an absolute position in layout coordinates.
\
Definition at line 210 of file qgslayoutpagecollection.cpp.
QList< QgsLayoutItemPage * > QgsLayoutPageCollection::pages | ( | ) |
Returns a list of pages in the collection.
Definition at line 432 of file qgslayoutpagecollection.cpp.
double QgsLayoutPageCollection::pageShadowWidth | ( | ) | const |
Returns the size of the page shadow, in layout units.
Definition at line 265 of file qgslayoutpagecollection.cpp.
|
inline |
Returns the symbol to use for drawing pages in the collection.
Definition at line 232 of file qgslayoutpagecollection.h.
QPointF QgsLayoutPageCollection::positionOnPage | ( | QPointF | point | ) | const |
Returns the position within a page of a point in the layout (in layout units).
Definition at line 231 of file qgslayoutpagecollection.cpp.
int QgsLayoutPageCollection::predictPageNumberForPoint | ( | QPointF | point | ) | const |
Returns the theoretical page number corresponding to a point in the layout (in layout units), assuming that enough pages exist in the layout to cover that point.
If there are insufficient pages currently in the layout, this method will assume that extra "imaginary" pages have been added at the end of the layout until that point is reached. These imaginary pages will inherit the size of the existing final page in the layout.
Page numbers in collections begin at 0 - so a page number of 0 indicates the first page.
Definition at line 165 of file qgslayoutpagecollection.cpp.
|
overridevirtual |
Sets the collection's state from a DOM element.
collectionElement is the DOM node corresponding to the collection.
Implements QgsLayoutSerializableObject.
Definition at line 359 of file qgslayoutpagecollection.cpp.
|
slot |
Triggers a redraw for all pages.
Definition at line 419 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::reflow | ( | ) |
Forces the page collection to reflow the arrangement of pages, e.g.
to account for page size/orientation change.
Definition at line 88 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::resizeToContents | ( | const QgsMargins & | margins, |
QgsUnitTypes::LayoutUnit | marginUnits | ||
) |
Resizes the layout to a single page which fits the current contents of the layout.
Calling this method resets the number of pages to 1, with the size set to the minimum size required to fit all existing layout items. Items will also be repositioned so that the new top-left bounds of the layout is at the point (marginLeft, marginTop). An optional margin can be specified.
Definition at line 270 of file qgslayoutpagecollection.cpp.
void QgsLayoutPageCollection::setPageStyleSymbol | ( | QgsFillSymbol * | symbol | ) |
Sets the symbol to use for drawing pages in the collection.
Ownership is not transferred, and a copy of the symbol is created internally.
Definition at line 43 of file qgslayoutpagecollection.cpp.
bool QgsLayoutPageCollection::shouldExportPage | ( | int | page | ) | const |
Returns whether the specified page number should be included in exports of the layouts.
Definition at line 515 of file qgslayoutpagecollection.cpp.
double QgsLayoutPageCollection::spaceBetweenPages | ( | ) | const |
Returns the space between pages, in layout units.
Definition at line 260 of file qgslayoutpagecollection.cpp.
|
inlineoverridevirtual |
Return the object type as a string.
This string must be a unique, single word, character only representation of the item type, eg "LayoutScaleBar"
Implements QgsLayoutSerializableObject.
Definition at line 54 of file qgslayoutpagecollection.h.
QgsLayoutItemPage * QgsLayoutPageCollection::takePage | ( | QgsLayoutItemPage * | page | ) |
Takes a page from the collection, returning ownership of the page to the caller.
Definition at line 692 of file qgslayoutpagecollection.cpp.
QList< int > QgsLayoutPageCollection::visiblePageNumbers | ( | QRectF | region | ) | const |
Returns a list of the page numbers which are visible within the specified region (in layout coordinates).
Definition at line 468 of file qgslayoutpagecollection.cpp.
QList< QgsLayoutItemPage * > QgsLayoutPageCollection::visiblePages | ( | QRectF | region | ) | const |
Returns a list of the pages which are visible within the specified region (in layout coordinates).
Definition at line 457 of file qgslayoutpagecollection.cpp.
|
overridevirtual |
Stores the collection's state in a DOM element.
The parentElement should refer to the parent layout's DOM element.
Implements QgsLayoutSerializableObject.
Definition at line 341 of file qgslayoutpagecollection.cpp.
|
friend |
Definition at line 425 of file qgslayoutpagecollection.h.