| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   40   if ( mAnnotations.contains( annotation ) )
 
   43   mAnnotations << annotation;
 
   54   if ( !mAnnotations.contains( annotation ) )
 
   58   mAnnotations.removeAll( annotation );
 
   67   for ( 
auto *a : std::as_const( mAnnotations ) )
 
   80   QList<QgsAnnotation *> results;
 
   81   for ( 
const auto *a : std::as_const( mAnnotations ) )
 
   83     results << a->clone();
 
   94   QDomElement annotationsElem = element.firstChildElement( QStringLiteral( 
"Annotations" ) );
 
   96   QDomElement annotationElement = annotationsElem.firstChildElement( QStringLiteral( 
"Annotation" ) );
 
   97   while ( ! annotationElement .isNull() )
 
   99     createAnnotationFromXml( annotationElement, context );
 
  100     annotationElement = annotationElement.nextSiblingElement( QStringLiteral( 
"Annotation" ) );
 
  104   if ( annotationElement.isNull() )
 
  106     QDomNodeList oldItemList = element.elementsByTagName( QStringLiteral( 
"TextAnnotationItem" ) );
 
  107     for ( 
int i = 0; i < oldItemList.size(); ++i )
 
  109       createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
 
  111     oldItemList = element.elementsByTagName( QStringLiteral( 
"FormAnnotationItem" ) );
 
  112     for ( 
int i = 0; i < oldItemList.size(); ++i )
 
  114       createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
 
  116     oldItemList = element.elementsByTagName( QStringLiteral( 
"HtmlAnnotationItem" ) );
 
  117     for ( 
int i = 0; i < oldItemList.size(); ++i )
 
  119       createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
 
  121     oldItemList = element.elementsByTagName( QStringLiteral( 
"SVGAnnotationItem" ) );
 
  122     for ( 
int i = 0; i < oldItemList.size(); ++i )
 
  124       createAnnotationFromXml( oldItemList.at( i ).toElement(), context );
 
  133   QDomElement annotationsElem = doc.createElement( QStringLiteral( 
"Annotations" ) );
 
  134   QListIterator<QgsAnnotation *> i( mAnnotations );
 
  137   while ( i.hasPrevious() )
 
  146     annotation->
writeXml( annotationsElem, doc, context );
 
  148   return annotationsElem;
 
  153   if ( mAnnotations.empty() )
 
  162     if ( !a->accept( visitor ) )
 
  172 void QgsAnnotationManager::createAnnotationFromXml( 
const QDomElement &element, 
const QgsReadWriteContext &context )
 
  174   QString type = element.tagName();
 
  179   annotation->
readXml( element, context );
 
  
void annotationAdded(QgsAnnotation *annotation)
Emitted when a annotation has been added to the manager.
 
void setMapPositionCrs(const QgsCoordinateReferenceSystem &crs)
Sets the CRS of the map position.
 
virtual void writeXml(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
Writes the annotation state to a DOM element.
 
The class is used as a container of context for various read/write operations on other objects.
 
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
 
virtual void readXml(const QDomElement &itemElem, const QgsReadWriteContext &context)=0
Restores the annotation's state from a DOM element.
 
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
 
virtual bool visitExit(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor stops visiting a node.
 
@ Annotations
Annotations collection.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
QList< QgsAnnotation * > cloneAnnotations() const
Returns a list containing clones of all annotations contained in the manager.
 
bool removeAnnotation(QgsAnnotation *annotation)
Removes an annotation from the manager.
 
bool addAnnotation(QgsAnnotation *annotation)
Adds an annotation to the manager.
 
Abstract base class for annotation items which are drawn over a map.
 
void annotationAboutToBeRemoved(QgsAnnotation *annotation)
Emitted when an annotation is about to be removed from the manager.
 
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the state of the manager.
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
void clear()
Removes and deletes all annotations from the manager.
 
void setDirty(bool b=true)
Flag the project as dirty (modified).
 
Contains information relating to a node (i.e.
 
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
 
bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated within ...
 
QList< QgsAnnotation * > annotations() const
Returns a list 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.
 
void annotationRemoved()
Emitted when an annotation was removed from the manager.
 
QgsCoordinateReferenceSystem mapPositionCrs() const
Returns the CRS of the map position, or an invalid CRS if the annotation does not have a fixed map po...
 
QgsAnnotationManager(QgsProject *project=nullptr)
Constructor for QgsAnnotationManager.
 
QgsCoordinateReferenceSystem crs
 
~QgsAnnotationManager() override