QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsannotationmanager.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationmanager.h
3  ----------------------
4  Date : January 2017
5  Copyright : (C) 2017 Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSANNOTATIONMANAGER_H
17 #define QGSANNOTATIONMANAGER_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include <QObject>
22 #include <QDomElement>
23 
25 class QgsProject;
26 class QgsAnnotation;
28 
44 class CORE_EXPORT QgsAnnotationManager : public QObject
45 {
46  Q_OBJECT
47 
48  public:
49 
54  explicit QgsAnnotationManager( QgsProject *project SIP_TRANSFERTHIS = nullptr );
55 
56  ~QgsAnnotationManager() override;
57 
64  bool addAnnotation( QgsAnnotation *annotation SIP_TRANSFER );
65 
75  bool removeAnnotation( QgsAnnotation *annotation );
76 
81  void clear();
82 
87  QList< QgsAnnotation * > annotations() const;
88 
95  QList< QgsAnnotation * > cloneAnnotations() const SIP_FACTORY;
96 
102  bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
103 
108  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
109 
119  bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
120 
121  signals:
122 
124  void annotationAdded( QgsAnnotation *annotation );
125 
127  void annotationRemoved();
128 
130  void annotationAboutToBeRemoved( QgsAnnotation *annotation );
131 
132  private:
133 
134  QgsProject *mProject = nullptr;
135 
136  QList< QgsAnnotation * > mAnnotations;
137 
138  void createAnnotationFromXml( const QDomElement &element, const QgsReadWriteContext &context );
139 
140 };
141 
142 #endif // QGSANNOTATIONMANAGER_H
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
qgis.h
QgsStyleEntityVisitorInterface
Definition: qgsstyleentityvisitor.h:33
QgsProject
Definition: qgsproject.h:92
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsAnnotation
Abstract base class for annotation items which are drawn over a map.
Definition: qgsannotation.h:49
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsAnnotationManager
Manages storage of a set of QgsAnnotation annotation objects.
Definition: qgsannotationmanager.h:44
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53