QGIS API Documentation  3.0.2-Girona (307d082)
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;
27 
28 
43 class CORE_EXPORT QgsAnnotationManager : public QObject
44 {
45  Q_OBJECT
46 
47  public:
48 
53  explicit QgsAnnotationManager( QgsProject *project SIP_TRANSFERTHIS = nullptr );
54 
55  ~QgsAnnotationManager() override;
56 
63  bool addAnnotation( QgsAnnotation *annotation SIP_TRANSFER );
64 
74  bool removeAnnotation( QgsAnnotation *annotation );
75 
80  void clear();
81 
86  QList< QgsAnnotation * > annotations() const;
87 
94  QList< QgsAnnotation * > cloneAnnotations() const SIP_FACTORY;
95 
101  bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
102 
107  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
108 
109  signals:
110 
112  void annotationAdded( QgsAnnotation *annotation );
113 
115  void annotationRemoved();
116 
118  void annotationAboutToBeRemoved( QgsAnnotation *annotation );
119 
120  private:
121 
122  QgsProject *mProject = nullptr;
123 
124  QList< QgsAnnotation * > mAnnotations;
125 
126  void createAnnotationFromXml( const QDomElement &element, const QgsReadWriteContext &context );
127 
128 };
129 
130 #endif // QGSANNOTATIONMANAGER_H
The class is used as a container of context for various read/write operations on other objects...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Manages storage of a set of QgsAnnotation annotation objects.
Abstract base class for annotation items which are drawn over a map.
Definition: qgsannotation.h:47
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Reads and writes project states.
Definition: qgsproject.h:82
#define SIP_FACTORY
Definition: qgis_sip.h:69