QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Signals | Public Member Functions | List of all members
QgsAnnotationManager Class Reference

Manages storage of a set of QgsAnnotation annotation objects. More...

#include <qgsannotationmanager.h>

Inheritance diagram for QgsAnnotationManager:
Inheritance graph
[legend]

Signals

void annotationAboutToBeRemoved (QgsAnnotation *annotation)
 Emitted when an annotation is about to be removed from the manager.
 
void annotationAdded (QgsAnnotation *annotation)
 Emitted when a annotation has been added to the manager.
 
void annotationRemoved ()
 Emitted when an annotation was removed from the manager.
 

Public Member Functions

 QgsAnnotationManager (QgsProject *project=nullptr)
 Constructor for QgsAnnotationManager.
 
 ~QgsAnnotationManager () override
 
bool accept (QgsStyleEntityVisitorInterface *visitor) const
 Accepts the specified style entity visitor, causing it to visit all style entities associated within the contained annotations.
 
bool addAnnotation (QgsAnnotation *annotation)
 Adds an annotation to the manager.
 
QList< QgsAnnotation * > annotations () const
 Returns a list of all annotations contained in the manager.
 
void clear ()
 Removes and deletes all annotations from the manager.
 
QList< QgsAnnotation * > cloneAnnotations () const
 Returns a list containing clones of all annotations contained in the manager.
 
bool readXml (const QDomElement &element, const QgsReadWriteContext &context)
 Reads the manager's state from a DOM element, restoring all annotations present in the XML document.
 
bool readXmlAndUpgradeToAnnotationLayerItems (const QDomElement &element, const QgsReadWriteContext &context, QgsAnnotationLayer *layer, const QgsCoordinateTransformContext &transformContext)
 Reads the manager's state from a DOM element, restoring annotations present in the XML document.
 
bool removeAnnotation (QgsAnnotation *annotation)
 Removes an annotation from the manager.
 
QDomElement writeXml (QDomDocument &doc, const QgsReadWriteContext &context) const
 Returns a DOM element representing the state of the manager.
 

Detailed Description

Manages storage of a set of QgsAnnotation annotation objects.

QgsAnnotationManager handles the storage, serializing and deserializing of QgsAnnotations. Usually this class is not constructed directly, but rather accessed through a QgsProject via QgsProject::annotationManager().

QgsAnnotationManager retains ownership of all the annotations contained in the manager.

Definition at line 46 of file qgsannotationmanager.h.

Constructor & Destructor Documentation

◆ QgsAnnotationManager()

QgsAnnotationManager::QgsAnnotationManager ( QgsProject project = nullptr)
explicit

Constructor for QgsAnnotationManager.

The project will become the parent object for this manager.

Definition at line 31 of file qgsannotationmanager.cpp.

◆ ~QgsAnnotationManager()

QgsAnnotationManager::~QgsAnnotationManager ( )
override

Definition at line 38 of file qgsannotationmanager.cpp.

Member Function Documentation

◆ accept()

bool QgsAnnotationManager::accept ( QgsStyleEntityVisitorInterface visitor) const

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

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

Since
QGIS 3.10

Definition at line 331 of file qgsannotationmanager.cpp.

◆ addAnnotation()

bool QgsAnnotationManager::addAnnotation ( QgsAnnotation annotation)

Adds an annotation to the manager.

Ownership of the annotation is transferred to the manager. Returns true if the addition was successful, or false if the annotation could not be added.

See also
removeAnnotation()
annotationAdded()

Definition at line 43 of file qgsannotationmanager.cpp.

◆ annotationAboutToBeRemoved

void QgsAnnotationManager::annotationAboutToBeRemoved ( QgsAnnotation annotation)
signal

Emitted when an annotation is about to be removed from the manager.

◆ annotationAdded

void QgsAnnotationManager::annotationAdded ( QgsAnnotation annotation)
signal

Emitted when a annotation has been added to the manager.

◆ annotationRemoved

void QgsAnnotationManager::annotationRemoved ( )
signal

Emitted when an annotation was removed from the manager.

◆ annotations()

QList< QgsAnnotation * > QgsAnnotationManager::annotations ( ) const

Returns a list of all annotations contained in the manager.

See also
cloneAnnotations()

Definition at line 81 of file qgsannotationmanager.cpp.

◆ clear()

void QgsAnnotationManager::clear ( )

Removes and deletes all annotations from the manager.

See also
removeAnnotation()

Definition at line 73 of file qgsannotationmanager.cpp.

◆ cloneAnnotations()

QList< QgsAnnotation * > QgsAnnotationManager::cloneAnnotations ( ) const

Returns a list containing clones of all annotations contained in the manager.

The caller takes responsibility for deleting all returned annotations.

See also
annotations()

Definition at line 86 of file qgsannotationmanager.cpp.

◆ readXml()

bool QgsAnnotationManager::readXml ( const QDomElement &  element,
const QgsReadWriteContext context 
)

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

See also
writeXml()

Definition at line 96 of file qgsannotationmanager.cpp.

◆ readXmlAndUpgradeToAnnotationLayerItems()

bool QgsAnnotationManager::readXmlAndUpgradeToAnnotationLayerItems ( const QDomElement &  element,
const QgsReadWriteContext context,
QgsAnnotationLayer layer,
const QgsCoordinateTransformContext transformContext 
)

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

Annotations which can be safely converted to QgsAnnotationItem subclasses will be automatically converted to those, and stored in the specified annotation layer.

Note
Not available in Python bindings
See also
writeXml()
Since
QGIS 3.40

Definition at line 101 of file qgsannotationmanager.cpp.

◆ removeAnnotation()

bool QgsAnnotationManager::removeAnnotation ( QgsAnnotation annotation)

Removes an annotation from the manager.

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

See also
addAnnotation()
annotationRemoved()
annotationAboutToBeRemoved()
clear()

Definition at line 57 of file qgsannotationmanager.cpp.

◆ writeXml()

QDomElement QgsAnnotationManager::writeXml ( QDomDocument &  doc,
const QgsReadWriteContext context 
) const

Returns a DOM element representing the state of the manager.

See also
readXml()

Definition at line 311 of file qgsannotationmanager.cpp.


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