30 QDomDocument currentDoc;
33 QDomElement elem =
writeXml( currentDoc, context );
34 currentDoc.appendChild( elem );
36 std::unique_ptr< QgsPrintLayout > newLayout = qgis::make_unique< QgsPrintLayout >(
project() );
38 newLayout->loadFromTemplate( currentDoc, context,
true, &ok );
44 return newLayout.release();
71 layoutElem.setAttribute( QStringLiteral(
"name" ), mName );
72 mAtlas->
writeXml( layoutElem, document, context );
81 QDomElement atlasElem = layoutElement.firstChildElement( QStringLiteral(
"Atlas" ) );
82 mAtlas->
readXml( atlasElem, document, context );
84 setName( layoutElement.attribute( QStringLiteral(
"name" ) ) );
91 return writeXml( document, context );
96 return readXml( layoutElement, document, context );
QgsPrintLayout * clone() const override
Creates a clone of the layout.
QgsPrintLayout(QgsProject *project)
Constructor for QgsPrintLayout.
The class is used as a container of context for various read/write operations on other objects...
virtual bool readXml(const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context)
Sets the collection's state from a DOM element.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the layout's current state.
bool readXml(const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets the collection's state from a DOM element.
bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const override
Stores the objects's state in a DOM element.
bool readXml(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets the objects's state from a DOM element.
QgsProject * layoutProject() const override
The project associated with the layout.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
Reads and writes project states.
QgsLayoutAtlas * atlas()
Returns the print layout's atlas.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const override
Returns the layout's state encapsulated in a DOM element.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the layout's current state.
static QgsExpressionContextScope * atlasScope(QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
QIcon icon() const override
Returns an icon for the layout.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void nameChanged(const QString &name)
Emitted when the layout's name is changed.
bool readLayoutXml(const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets the layout's state from a DOM element.
QgsProject * project() const
The project associated with the layout.
bool enabled() const
Returns whether the atlas generation is enabled.
QgsMasterLayoutInterface::Type layoutType() const override
Returns the master layout type.
virtual QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Returns the layout's state encapsulated in a DOM element.
void setName(const QString &name) override
Sets the layout's name.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
void updateSettings() override
Refreshes the layout when global layout related options change.
void reloadSettings()
Refreshes the layout when global layout related options change.
Individual print layout (QgsPrintLayout)
QString name() const override
Returns the layout's name.
QDomElement writeLayoutXml(QDomDocument &document, const QgsReadWriteContext &context) const override
Returns the layout's state encapsulated in a DOM element.