49 , mGridSettings( this )
54 setBackgroundBrush( Qt::NoBrush );
61 mUndoStack->blockCommands(
true );
63 deleteAndRemoveMultiFrames();
71 QList<QGraphicsItem *> itemList = items();
76 for ( QGraphicsItem *item : std::as_const( itemList ) )
93 QDomDocument currentDoc;
96 QDomElement elem =
writeXml( currentDoc, context );
97 currentDoc.appendChild( elem );
99 std::unique_ptr< QgsLayout > newLayout = std::make_unique< QgsLayout >( mProject );
101 newLayout->loadFromTemplate( currentDoc, context,
true, &ok );
107 return newLayout.release();
115 mPageCollection->addPage( page );
116 mUndoStack->stack()->clear();
121 deleteAndRemoveMultiFrames();
124 const QList<QGraphicsItem *> itemList = items();
125 for ( QGraphicsItem *item : itemList )
129 if ( cItem && !pItem )
131 removeLayoutItemPrivate( cItem );
134 mItemsModel->clear();
136 mPageCollection->clear();
137 mUndoStack->stack()->clear();
147 return mItemsModel.get();
152 QList<QgsLayoutItem *> layoutItemList;
154 const QList<QGraphicsItem *> graphicsItemList = selectedItems();
155 for ( QGraphicsItem *item : graphicsItemList )
158 if ( layoutItem && ( includeLockedItems || !layoutItem->
isLocked() ) )
160 layoutItemList.push_back( layoutItem );
164 return layoutItemList;
183 const QList<QGraphicsItem *> selectedItemList = selectedItems();
184 for ( QGraphicsItem *item : selectedItemList )
188 layoutItem->setSelected(
false );
197 bool result = mItemsModel->reorderItemUp( item );
198 if ( result && !deferUpdate )
210 bool result = mItemsModel->reorderItemDown( item );
211 if ( result && !deferUpdate )
223 bool result = mItemsModel->reorderItemToTop( item );
224 if ( result && !deferUpdate )
236 bool result = mItemsModel->reorderItemToBottom( item );
237 if ( result && !deferUpdate )
248 QList<QgsLayoutItem *> itemList;
252 if ( item->uuid() == uuid )
254 else if ( includeTemplateUuids && item->mTemplateUuid == uuid )
263 QList<QgsLayoutItem *> itemList;
267 if ( item->mTemplateUuid == uuid )
276 const QList<QGraphicsItem *> itemList = items();
277 for ( QGraphicsItem *item : itemList )
280 if ( layoutItem && layoutItem->
id() == id )
292 if ( mf->uuid() == uuid )
294 else if ( includeTemplateUuids && mf->mTemplateUuid == uuid )
309 const QList<QGraphicsItem *> itemList = items( position, Qt::IntersectsItemShape, Qt::DescendingOrder );
311 bool foundBelowItem =
false;
312 for ( QGraphicsItem *graphicsItem : itemList )
316 if ( layoutItem && !paperItem )
320 if ( ( ! belowItem || foundBelowItem ) && ( !ignoreLocked || !layoutItem->
isLocked() ) )
326 if ( layoutItem == belowItem )
329 foundBelowItem =
true;
369 return *mRenderContext;
374 return *mRenderContext;
379 return *mReportContext;
384 return *mReportContext;
390 mPageCollection->redraw();
395 return mPageCollection->guides();
400 return mPageCollection->guides();
408 if ( mReportContext->
layer() )
417 mCustomProperties.
setValue( key, value );
419 if ( key.startsWith( QLatin1String(
"variable" ) ) )
425 return mCustomProperties.
value( key, defaultValue );
430 mCustomProperties.
remove( key );
435 return mCustomProperties.
keys();
445 QList< QgsLayoutItemMap * > maps;
448 double largestMapArea = 0;
451 double area = map->rect().width() * map->rect().height();
452 if ( area > largestMapArea )
454 largestMapArea = area;
463 mWorldFileMapId = map ? map->
uuid() : QString();
469 return mPageCollection.get();
474 return mPageCollection.get();
483 const auto constItems = items();
484 for (
const QGraphicsItem *item : constItems )
491 if ( !isPage || !ignorePages )
499 itemBounds = layoutItem->mapToScene( layoutItem->rect() ).boundingRect();
502 itemBounds = item->sceneBoundingRect();
504 if ( bounds.isValid() )
505 bounds = bounds.united( itemBounds );
511 if ( bounds.isValid() && margin > 0.0 )
514 double maxWidth = mPageCollection->maximumPageWidth();
515 bounds.adjust( -maxWidth * margin, -maxWidth * margin, maxWidth * margin, maxWidth * margin );
528 const QList<QGraphicsItem *> itemList = items();
529 for ( QGraphicsItem *item : itemList )
534 if ( visibleOnly && !layoutItem->isVisible() )
538 if ( bounds.isValid() )
539 bounds = bounds.united( item->sceneBoundingRect() );
541 bounds = item->sceneBoundingRect();
550 addLayoutItemPrivate( item );
554 undoText = tr(
"Create %1" ).arg( metadata->visibleName() );
558 undoText = tr(
"Create Item" );
560 if ( !mUndoStack->isBlocked() )
566 std::unique_ptr< QgsLayoutItemDeleteUndoCommand > deleteCommand;
567 if ( !mUndoStack->isBlocked() )
569 mUndoStack->beginMacro( tr(
"Delete Items" ) );
572 removeLayoutItemPrivate( item );
575 mUndoStack->push( deleteCommand.release() );
576 mUndoStack->endMacro();
585 if ( !mMultiFrames.contains( multiFrame ) )
586 mMultiFrames << multiFrame;
591 mMultiFrames.removeAll( multiFrame );
601 QFile templateFile( path );
602 if ( !templateFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
607 QDomDocument saveDocument;
608 QDomElement elem =
writeXml( saveDocument, context );
609 saveDocument.appendChild( elem );
611 if ( templateFile.write( saveDocument.toByteArray() ) == -1 )
622 QList< QgsLayoutItem * > result;
642 QDomNodeList itemsNodes = doc.elementsByTagName( QStringLiteral(
"LayoutItem" ) );
643 for (
int i = 0; i < itemsNodes.count(); ++i )
645 QDomNode itemNode = itemsNodes.at( i );
646 if ( itemNode.isElement() )
648 itemNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
651 QDomNodeList multiFrameNodes = doc.elementsByTagName( QStringLiteral(
"LayoutMultiFrame" ) );
652 for (
int i = 0; i < multiFrameNodes.count(); ++i )
654 QDomNode multiFrameNode = multiFrameNodes.at( i );
655 if ( multiFrameNode.isElement() )
657 multiFrameNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
658 QDomNodeList frameNodes = multiFrameNode.toElement().elementsByTagName( QStringLiteral(
"childFrame" ) );
659 QDomNode itemNode = frameNodes.at( i );
660 if ( itemNode.isElement() )
662 itemNode.toElement().removeAttribute( QStringLiteral(
"uuid" ) );
670 QDomElement layoutElem = doc.documentElement();
671 if ( layoutElem.isNull() )
676 bool loadOk =
readXml( layoutElem, doc, context );
696 return mUndoStack.get();
701 return mUndoStack.get();
716 void saveState( QDomDocument &stateDoc )
const override
719 QDomElement documentElement = stateDoc.createElement( QStringLiteral(
"UndoState" ) );
721 stateDoc.appendChild( documentElement );
731 mLayout->readXmlLayoutSettings( stateDoc.documentElement(), stateDoc,
QgsReadWriteContext() );
732 mLayout->project()->setDirty(
true );
748 if ( items.size() < 2 )
754 mUndoStack->beginMacro( tr(
"Group Items" ) );
758 itemGroup->addItem( item );
763 std::unique_ptr< QgsLayoutItemGroupUndoCommand >
c(
new QgsLayoutItemGroupUndoCommand( QgsLayoutItemGroupUndoCommand::Grouped, returnGroup,
this, tr(
"Group Items" ) ) );
764 mUndoStack->push(
c.release() );
767 mUndoStack->endMacro();
775 QList<QgsLayoutItem *> ungroupedItems;
778 return ungroupedItems;
781 mUndoStack->beginMacro( tr(
"Ungroup Items" ) );
784 std::unique_ptr< QgsLayoutItemGroupUndoCommand >
c(
new QgsLayoutItemGroupUndoCommand( QgsLayoutItemGroupUndoCommand::Ungrouped, group,
this, tr(
"Ungroup Items" ) ) );
785 mUndoStack->push(
c.release() );
789 ungroupedItems = group->
items();
793 mUndoStack->endMacro();
795 return ungroupedItems;
800 const QList< QGraphicsItem * > constItems = items();
801 for (
const QGraphicsItem *item : constItems )
807 if ( !layoutItem->
accept( visitor ) )
815 mUndoStack->blockCommands(
true );
816 mPageCollection->beginPageSizeChange();
818 mPageCollection->reflow();
819 mPageCollection->endPageSizeChange();
820 mUndoStack->blockCommands(
false );
824void QgsLayout::writeXmlLayoutSettings( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext & )
const
826 mCustomProperties.
writeXml( element, document );
828 element.setAttribute( QStringLiteral(
"worldFileMap" ), mWorldFileMapId );
829 element.setAttribute( QStringLiteral(
"printResolution" ), mRenderContext->
dpi() );
834 QDomElement element = document.createElement( QStringLiteral(
"Layout" ) );
837 return object->writeXml( element, document, context );
840 save( &mGridSettings );
841 save( mPageCollection.get() );
844 const QList<QGraphicsItem *> itemList = items();
845 for (
const QGraphicsItem *graphicsItem : itemList )
852 item->writeXml( element, document, context );
859 if ( mf->frameCount() > 0 )
860 mf->writeXml( element, document, context );
863 writeXmlLayoutSettings( element, document, context );
867bool QgsLayout::readXmlLayoutSettings(
const QDomElement &layoutElement,
const QDomDocument &,
const QgsReadWriteContext & )
869 mCustomProperties.
readXml( layoutElement );
871 mWorldFileMapId = layoutElement.attribute( QStringLiteral(
"worldFileMap" ) );
872 mRenderContext->
setDpi( layoutElement.attribute( QStringLiteral(
"printResolution" ), QStringLiteral(
"300" ) ).toDouble() );
882 mItemsModel->rebuildZList();
887void QgsLayout::removeLayoutItemPrivate(
QgsLayoutItem *item )
889 mItemsModel->setItemRemoved( item );
896 emit itemRemoved( item );
902void QgsLayout::deleteAndRemoveMultiFrames()
904 qDeleteAll( mMultiFrames );
905 mMultiFrames.clear();
908QPointF QgsLayout::minPointFromXml(
const QDomElement &elem )
const
910 double minX = std::numeric_limits<double>::max();
911 double minY = std::numeric_limits<double>::max();
912 const QDomNodeList itemList = elem.elementsByTagName( QStringLiteral(
"LayoutItem" ) );
914 for (
int i = 0; i < itemList.size(); ++i )
916 const QDomElement currentItemElem = itemList.at( i ).toElement();
921 minX = std::min( minX, layoutPoint.x() );
922 minY = std::min( minY, layoutPoint.y() );
925 return found ? QPointF( minX, minY ) : QPointF( 0, 0 );
930 int counter = mItemsModel->zOrderListSize();
931 const QList<QgsLayoutItem *> zOrderList = mItemsModel->zOrderList();
933 if ( addUndoCommands )
935 mUndoStack->beginMacro( tr(
"Change Item Stacking" ) );
941 if ( addUndoCommands )
943 mUndoStack->beginCommand( currentItem, QString() );
945 currentItem->setZValue( counter );
946 if ( addUndoCommands )
948 mUndoStack->endCommand();
953 if ( addUndoCommands )
955 mUndoStack->endMacro();
961 if ( layoutElement.nodeName() != QLatin1String(
"Layout" ) )
968 return object->readXml( layoutElement, document, context );
971 std::unique_ptr< QgsScopedRuntimeProfile > profile;
973 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Read layout settings" ), QStringLiteral(
"projectload" ) );
975 blockSignals(
true );
976 readXmlLayoutSettings( layoutElement, document, context );
977 blockSignals(
false );
980 profile->switchTask( tr(
"Load pages" ) );
981 restore( mPageCollection.get() );
983 profile->switchTask( tr(
"Load snapping settings" ) );
984 restore( &mSnapper );
986 profile->switchTask( tr(
"Load grid settings" ) );
987 restore( &mGridSettings );
990 profile->switchTask( tr(
"Restore items" ) );
1000 QList< QgsLayoutItem * > newItems;
1001 QList< QgsLayoutMultiFrame * > newMultiFrames;
1006 int zOrderOffset = mItemsModel->zOrderListSize();
1008 QPointF pasteShiftPos;
1009 int pageNumber = -1;
1015 QPointF minItemPos = minPointFromXml( parentElement );
1018 pasteShiftPos = *position - minItemPos;
1021 pageNumber = mPageCollection->pageNumberForPoint( *position );
1025 std::unique_ptr< QgsScopedRuntimeProfile > profile;
1027 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Read items" ), QStringLiteral(
"projectload" ) );
1032 const QDomNodeList multiFrameList = parentElement.elementsByTagName( QStringLiteral(
"LayoutMultiFrame" ) );
1033 for (
int i = 0; i < multiFrameList.size(); ++i )
1035 const QDomElement multiFrameElem = multiFrameList.at( i ).toElement();
1036 const int itemType = multiFrameElem.attribute( QStringLiteral(
"type" ) ).toInt();
1042 profile->switchTask( tr(
"Load %1" ).arg( metadata->visibleName() ) );
1052 mf->readXml( multiFrameElem, document, context );
1055 mf->setCreateUndoCommands(
true );
1070 newMultiFrames << m;
1073 const QDomNodeList layoutItemList = parentElement.childNodes();
1074 for (
int i = 0; i < layoutItemList.size(); ++i )
1076 const QDomElement currentItemElem = layoutItemList.at( i ).toElement();
1077 if ( currentItemElem.nodeName() != QLatin1String(
"LayoutItem" ) )
1080 const int itemType = currentItemElem.attribute( QStringLiteral(
"type" ) ).toInt();
1086 profile->switchTask( tr(
"Load %1" ).arg( metadata->visibleName() ) );
1097 item->readXml( currentItemElem, document, context );
1103 item->attemptMove( posOnPage,
true,
false, pageNumber );
1107 item->attemptMoveBy( pasteShiftPos.x(), pasteShiftPos.y() );
1120 newMultiFrames << html;
1128 layoutItem->setZValue( layoutItem->zValue() + zOrderOffset );
1129 newItems << layoutItem;
1136 std::unique_ptr< QgsScopedRuntimeProfile > itemProfile;
1139 profile->switchTask( tr(
"Finalize restore" ) );
1144 itemProfile = std::make_unique< QgsScopedRuntimeProfile >( item->
displayName(), QStringLiteral(
"projectload" ) );
1147 itemProfile.reset();
1152 itemProfile = std::make_unique< QgsScopedRuntimeProfile >( mf->displayName(), QStringLiteral(
"projectload" ) );
1153 mf->finalizeRestoreFromXml();
1155 itemProfile.reset();
1160 item->mTemplateUuid.clear();
1164 mf->mTemplateUuid.clear();
1172 profile->switchTask( tr(
"Update model" ) );
1173 mItemsModel->rebuildZList();
1183void QgsLayout::itemBackgroundTaskCountChanged(
int count )
1185 QgsLayoutItem *item = qobject_cast<QgsLayoutItem *>( sender() );
1190 mBackgroundTaskCount.insert( item, count );
1192 mBackgroundTaskCount.remove( item );
1196 for (
auto it = mBackgroundTaskCount.constBegin(); it != mBackgroundTaskCount.constEnd(); ++it )
1198 total += it.value();
LayoutUnit
Layout measurement units.
Base class for commands to undo/redo layout and layout object changes.
virtual void saveState(QDomDocument &stateDoc) const =0
Saves the state of the object to the specified stateDoc.
virtual void restoreState(QDomDocument &stateDoc)=0
Restores the state of the object from the specified stateDoc.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
static bool isCompositionTemplate(const QDomDocument &document)
Check if the given document is a composition template.
static QDomDocument convertCompositionTemplate(const QDomDocument &document, QgsProject *project)
Convert a composition template document to a layout template.
static QgsExpressionContextScope * layoutScope(const QgsLayout *layout)
Creates a new scope which contains variables and functions relating to a QgsLayout layout.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void loadFromSettings()
Loads grid settings from the application layout settings.
Stores and manages the snap guides used by a layout.
A container for grouping several QgsLayoutItems.
void removeItems()
Removes all items from the group (but does not delete them).
QList< QgsLayoutItem * > items() const
Returns a list of items contained by the group.
static QgsLayoutItemHtml * createFromLabel(QgsLayoutItemLabel *label)
Returns a new QgsLayoutItemHtml matching the content and rendering of a given label.
A layout item subclass for text labels.
@ ModeHtml
Label displays rendered HTML content.
Layout graphical items for displaying a map.
Item representing the paper in a layout.
void setPageSize(const QgsLayoutSize &size)
Sets the size of the page.
Base class for graphical items within a QgsLayout.
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
virtual void setSelected(bool selected)
Sets whether the item should be selected.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
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 QString uuid() const
Returns the item identification string.
QString id() const
Returns the item's ID name.
void backgroundTaskCountChanged(int count)
Emitted whenever the number of background tasks an item is executing changes.
QgsLayoutMeasurement convert(QgsLayoutMeasurement measurement, Qgis::LayoutUnit targetUnits) const
Converts a measurement from one unit to another.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
double length() const
Returns the length of the measurement.
A model for items attached to a layout.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
A manager for a collection of pages in a layout.
This class provides a method of storing points, consisting of an x and y coordinate,...
static QgsLayoutPoint decodePoint(const QString &string)
Decodes a point from a string.
Stores information relating to the current rendering settings for a layout.
void setDpi(double dpi)
Sets the dpi for outputting the layout.
double dpi() const
Returns the dpi for outputting the layout.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
Stores information relating to the current reporting context for a layout.
QgsVectorLayer * layer() const
Returns the vector layer associated with the layout's context.
An interface for layout objects which can be stored and read from DOM elements.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest ...
An undo stack for QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
friend class QgsLayoutItemDeleteUndoCommand
void removeMultiFrame(QgsLayoutMultiFrame *multiFrame)
Removes a multiFrame from the layout (but does not delete it).
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the layout.
void updateBounds()
Updates the scene bounds of the layout.
bool saveAsTemplate(const QString &path, const QgsReadWriteContext &context) const
Saves the layout as a template at the given file path.
QgsAbstractLayoutUndoCommand * createCommand(const QString &text, int id=0, QUndoCommand *parent=nullptr) override
Creates a new layout undo command with the specified text and parent.
void initializeDefaults()
Initializes an empty layout, e.g.
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
void removeCustomProperty(const QString &key)
Remove a custom property from the layout.
QgsLayoutModel * itemsModel()
Returns the items model attached to the layout.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
void variablesChanged()
Emitted whenever the expression variables stored in the layout have been changed.
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
void addMultiFrame(QgsLayoutMultiFrame *multiFrame)
Adds a multiFrame to the layout.
void setUnits(Qgis::LayoutUnit units)
Sets the native measurement units for the layout.
QgsLayoutGuideCollection & guides()
Returns a reference to the layout's guide collection, which manages page snap guides.
QList< QgsLayoutItem * > ungroupItems(QgsLayoutItemGroup *group)
Ungroups items by removing them from an item group and removing the group from the layout.
bool moveItemToTop(QgsLayoutItem *item, bool deferUpdate=false)
Raises an item up to the top of the z-order.
QgsLayoutItemMap * referenceMap() const
Returns the map item which will be used to generate corresponding world files when the layout is expo...
void changed()
Emitted when properties of the layout change.
bool moveItemToBottom(QgsLayoutItem *item, bool deferUpdate=false)
Lowers an item down to the bottom of the z-order.
QgsLayoutItemGroup * groupItems(const QList< QgsLayoutItem * > &items)
Creates a new group from a list of layout items and adds the group to the layout.
QList< QgsLayoutItem * > addItemsFromXml(const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context, QPointF *position=nullptr, bool pasteInPlace=false)
Add items from an XML representation to the layout.
friend class QgsLayoutItemAddItemCommand
void reloadSettings()
Refreshes the layout when global layout related options change.
double convertToLayoutUnits(QgsLayoutMeasurement measurement) const
Converts a measurement into the layout's native units.
virtual bool readXml(const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context)
Sets the collection's state from a DOM element.
QStringList customProperties() const
Returns list of keys stored in custom properties for the layout.
QgsLayout * clone() const
Creates a clone of the layout.
QgsLayoutItem * layoutItemAt(QPointF position, bool ignoreLocked=false) const
Returns the topmost layout item at a specified position.
void clear()
Clears the layout.
QgsLayoutItem * itemByTemplateUuid(const QString &uuid) const
Returns the layout item with matching template uuid unique identifier, or nullptr if a matching item ...
friend class QgsLayoutUndoCommand
bool lowerItem(QgsLayoutItem *item, bool deferUpdate=false)
Lowers an item down the z-order.
QgsLayoutMeasurement convertFromLayoutUnits(double length, Qgis::LayoutUnit unit) const
Converts a length measurement from the layout's native units to a specified target unit.
friend class QgsLayoutModel
QList< QgsLayoutItem * > loadFromTemplate(const QDomDocument &document, const QgsReadWriteContext &context, bool clearExisting=true, bool *ok=nullptr)
Load a layout template document.
static const QgsSettingsEntryStringList * settingsSearchPathForTemplates
Settings entry search path for templates.
bool raiseItem(QgsLayoutItem *item, bool deferUpdate=false)
Raises an item up the z-order.
QList< QgsLayoutItem * > selectedLayoutItems(bool includeLockedItems=true)
Returns list of selected layout items.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from the layout.
void selectedItemChanged(QgsLayoutItem *selected)
Emitted whenever the selected item changes.
void deselectAll()
Clears any selected items in the layout.
void setSelectedItem(QgsLayoutItem *item)
Clears any selected items and sets item as the current selection.
QRectF layoutBounds(bool ignorePages=false, double margin=0.0) const
Calculates the bounds of all non-gui items in the layout.
void refresh()
Forces the layout, and all items contained within it, to refresh.
void backgroundTaskCountChanged(int total)
Emitted whenever the total number of background tasks running in items from the layout changes.
void removeLayoutItem(QgsLayoutItem *item)
Removes an item from the layout.
void refreshed()
Emitted when the layout has been refreshed and items should also be refreshed and updated.
friend class QgsLayoutItemGroupUndoCommand
void updateZValues(bool addUndoCommands=true)
Resets the z-values of items based on their position in the internal z order list.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the layout's current state.
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
virtual QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Returns the layout's state encapsulated in a DOM element.
void setReferenceMap(QgsLayoutItemMap *map)
Sets the map item which will be used to generate corresponding world files when the layout is exporte...
QList< QgsLayoutMultiFrame * > multiFrames() const
Returns a list of multi frames contained in the layout.
void addLayoutItem(QgsLayoutItem *item)
Adds an item to the layout.
QgsLayoutMultiFrame * multiFrameByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout multiframe with matching uuid unique identifier, or nullptr if a matching multifra...
bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
QgsProject * project() const
The project associated with the layout.
void itemAdded(QgsLayoutItem *item)
Emitted when an item was added to the layout.
QRectF pageItemBounds(int page, bool visibleOnly=false) const
Returns the bounding box of the items contained on a specified page.
QgsLayout(QgsProject *project)
Construct a new layout linked to the specified project.
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
void setValue(const QString &key, const QVariant &value)
Add an entry to the store with the specified key.
QStringList keys() const
Returns a list of all stored keys.
void writeXml(QDomNode &parentNode, QDomDocument &doc) const
Writes the store contents to an XML node.
void remove(const QString &key)
Removes a key (entry) from the store.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for the given key.
void readXml(const QDomNode &parentNode, const QString &keyStartsWith=QString())
Read store contents from an XML node.
A class to describe the version of a project.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
void setDirty(bool b=true)
Flag the project as dirty (modified).
QgsProjectVersion lastSaveVersion() const
Returns the QGIS version which the project was last saved using.
The class is used as a container of context for various read/write operations on other objects.
bool groupIsActive(const QString &group) const
Returns true if the specified group is currently being logged, i.e.
A string list settings entry.
static QgsSettingsTreeNode * sTreeLayout
An interface for classes which can visit style entity (e.g.
static Q_INVOKABLE Qgis::LayoutUnit decodeLayoutUnit(const QString &string, bool *ok=nullptr)
Decodes a layout unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.