QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsLayoutManager Class Reference

Manages storage of a set of layouts. More...

#include <qgslayoutmanager.h>

Inheritance diagram for QgsLayoutManager:

Signals

void layoutAboutToBeAdded (const QString &name)
 Emitted when a layout is about to be added to the manager.
void layoutAboutToBeRemoved (const QString &name)
 Emitted when a layout is about to be removed from the manager.
void layoutAdded (const QString &name)
 Emitted when a layout has been added to the manager.
void layoutRemoved (const QString &name)
 Emitted when a layout was removed from the manager.
void layoutRenamed (QgsMasterLayoutInterface *layout, const QString &newName)
 Emitted when a layout is renamed.
Signals inherited from QgsProjectStoredObjectManagerBase
void objectAboutToBeAdded (const QString &name)
 Emitted when an object is about to be added to the manager.
void objectAboutToBeRemoved (const QString &name)
 Emitted when an object is about to be removed from the manager.
void objectAdded (const QString &name)
 Emitted when an object has been added to the manager.
void objectRemoved (const QString &name)
 Emitted when an object was removed from the manager.

Public Member Functions

 QgsLayoutManager (QgsProject *project=nullptr)
 Constructor for QgsLayoutManager.
 ~QgsLayoutManager () override
bool accept (QgsStyleEntityVisitorInterface *visitor) const
 Accepts the specified style entity visitor, causing it to visit all style entities associated within the contained layouts.
bool addLayout (QgsMasterLayoutInterface *layout)
 Adds a layout to the manager.
void clear ()
 Removes and deletes all layouts from the manager.
QgsMasterLayoutInterfaceduplicateLayout (const QgsMasterLayoutInterface *layout, const QString &newName)
 Duplicates an existing layout from the manager.
QString generateUniqueTitle (QgsMasterLayoutInterface::Type type=QgsMasterLayoutInterface::PrintLayout) const
 Generates a unique title for a new layout of the specified type, which does not clash with any already contained by the manager.
QgsMasterLayoutInterfacelayoutByName (const QString &name) const
 Returns the layout with a matching name, or nullptr if no matching layouts were found.
QList< QgsMasterLayoutInterface * > layouts () const
 Returns a list of all layouts contained in the manager.
QList< QgsPrintLayout * > printLayouts () const
 Returns a list of all print layouts contained in the manager.
bool readXml (const QDomElement &element, const QDomDocument &doc)
 Reads the manager's state from a DOM element, restoring all layouts present in the XML document.
bool removeLayout (QgsMasterLayoutInterface *layout)
 Removes a layout from the manager.
QDomElement writeXml (QDomDocument &doc) const
 Returns a DOM element representing the state of the manager.
Public Member Functions inherited from QgsAbstractProjectStoredObjectManager< QgsMasterLayoutInterface >
 QgsAbstractProjectStoredObjectManager (QgsProject *project=nullptr)
 Constructor for QgsAbstractProjectStoredObjectManager, for objects attached to the specified project.
 ~QgsAbstractProjectStoredObjectManager () override
QgsMasterLayoutInterfaceobjectByName (const QString &name) const
 Returns the object with a matching name, or nullptr if no matching objects were found.
QList< QgsMasterLayoutInterface * > objects () const
 Returns the list of objects contained within the manager.
Public Member Functions inherited from QgsProjectStoredObjectManagerBase
 QgsProjectStoredObjectManagerBase (QgsProject *project=nullptr)
 Constructor for QgsProjectStoredObjectManagerBase, for objects attached to the specified project.

Protected Member Functions

void setupObjectConnections (QgsMasterLayoutInterface *layout) override
Protected Member Functions inherited from QgsAbstractProjectStoredObjectManager< QgsMasterLayoutInterface >
bool addObject (QgsMasterLayoutInterface *object)
 Adds an object to the manager.
void clearObjects ()
 Removes and deletes all objects from the manager.
bool removeObject (QgsMasterLayoutInterface *object)
 Removes an object from the manager.
virtual void setupObjectConnections (QgsMasterLayoutInterface *object)
 Sets up additional connections to an object, called when the object is first added to the manager.
Protected Member Functions inherited from QgsProjectStoredObjectManagerBase
void markProjectDirty ()
 Marks the project as dirty.

Additional Inherited Members

Protected Attributes inherited from QgsAbstractProjectStoredObjectManager< QgsMasterLayoutInterface >
QList< QgsMasterLayoutInterface * > mObjects
 Attached objects, owned by the manager.
Protected Attributes inherited from QgsProjectStoredObjectManagerBase
QgsProjectmProject = nullptr
 Associated project.

Detailed Description

Manages storage of a set of layouts.

QgsLayoutManager handles the storage, serializing and deserializing of print layouts and reports. Usually this class is not constructed directly, but rather accessed through a QgsProject via QgsProject::layoutManager().

QgsLayoutManager retains ownership of all the layouts contained in the manager.

Definition at line 49 of file qgslayoutmanager.h.

Constructor & Destructor Documentation

◆ QgsLayoutManager()

QgsLayoutManager::QgsLayoutManager ( QgsProject * project = nullptr)
explicit

Constructor for QgsLayoutManager.

The project will become the parent object for this manager.

Definition at line 30 of file qgslayoutmanager.cpp.

◆ ~QgsLayoutManager()

QgsLayoutManager::~QgsLayoutManager ( )
override

Definition at line 40 of file qgslayoutmanager.cpp.

Member Function Documentation

◆ accept()

bool QgsLayoutManager::accept ( QgsStyleEntityVisitorInterface * visitor) const

Accepts the specified style entity visitor, causing it to visit all style entities associated within the contained layouts.

Returns true if the visitor should continue visiting other objects, or false if visiting should be canceled.

Since
QGIS 3.10

Definition at line 261 of file qgslayoutmanager.cpp.

◆ addLayout()

bool QgsLayoutManager::addLayout ( QgsMasterLayoutInterface * layout)

Adds a layout to the manager.

Ownership of the layout is transferred to the manager. Returns true if the addition was successful, or false if the layout could not be added (eg as a result of a duplicate layout name).

See also
removeLayout()
layoutAdded()

Definition at line 45 of file qgslayoutmanager.cpp.

◆ clear()

void QgsLayoutManager::clear ( )

Removes and deletes all layouts from the manager.

See also
removeLayout()

Definition at line 55 of file qgslayoutmanager.cpp.

◆ duplicateLayout()

QgsMasterLayoutInterface * QgsLayoutManager::duplicateLayout ( const QgsMasterLayoutInterface * layout,
const QString & newName )

Duplicates an existing layout from the manager.

The new layout will automatically be stored in the manager. Returns the new layout if duplication was successful.

Definition at line 211 of file qgslayoutmanager.cpp.

◆ generateUniqueTitle()

QString QgsLayoutManager::generateUniqueTitle ( QgsMasterLayoutInterface::Type type = QgsMasterLayoutInterface::PrintLayout) const

Generates a unique title for a new layout of the specified type, which does not clash with any already contained by the manager.

Definition at line 235 of file qgslayoutmanager.cpp.

◆ layoutAboutToBeAdded

void QgsLayoutManager::layoutAboutToBeAdded ( const QString & name)
signal

Emitted when a layout is about to be added to the manager.

◆ layoutAboutToBeRemoved

void QgsLayoutManager::layoutAboutToBeRemoved ( const QString & name)
signal

Emitted when a layout is about to be removed from the manager.

◆ layoutAdded

void QgsLayoutManager::layoutAdded ( const QString & name)
signal

Emitted when a layout has been added to the manager.

◆ layoutByName()

QgsMasterLayoutInterface * QgsLayoutManager::layoutByName ( const QString & name) const

Returns the layout with a matching name, or nullptr if no matching layouts were found.

Definition at line 79 of file qgslayoutmanager.cpp.

◆ layoutRemoved

void QgsLayoutManager::layoutRemoved ( const QString & name)
signal

Emitted when a layout was removed from the manager.

◆ layoutRenamed

void QgsLayoutManager::layoutRenamed ( QgsMasterLayoutInterface * layout,
const QString & newName )
signal

Emitted when a layout is renamed.

◆ layouts()

QList< QgsMasterLayoutInterface * > QgsLayoutManager::layouts ( ) const

Returns a list of all layouts contained in the manager.

Definition at line 60 of file qgslayoutmanager.cpp.

◆ printLayouts()

QList< QgsPrintLayout * > QgsLayoutManager::printLayouts ( ) const

Returns a list of all print layouts contained in the manager.

Definition at line 65 of file qgslayoutmanager.cpp.

◆ readXml()

bool QgsLayoutManager::readXml ( const QDomElement & element,
const QDomDocument & doc )

Reads the manager's state from a DOM element, restoring all layouts present in the XML document.

See also
writeXml()

Definition at line 84 of file qgslayoutmanager.cpp.

◆ removeLayout()

bool QgsLayoutManager::removeLayout ( QgsMasterLayoutInterface * layout)

Removes a layout from the manager.

The layout is deleted. Returns true if the removal was successful, or false if the removal failed (eg as a result of removing a layout which is not contained in the manager).

See also
addLayout()
layoutRemoved()
layoutAboutToBeRemoved()
clear()

Definition at line 50 of file qgslayoutmanager.cpp.

◆ setupObjectConnections()

void QgsLayoutManager::setupObjectConnections ( QgsMasterLayoutInterface * layout)
overrideprotected

Definition at line 282 of file qgslayoutmanager.cpp.

◆ writeXml()

QDomElement QgsLayoutManager::writeXml ( QDomDocument & doc) const

Returns a DOM element representing the state of the manager.

See also
readXml()

Definition at line 197 of file qgslayoutmanager.cpp.


The documentation for this class was generated from the following files: