LCOV - code coverage report
Current view: top level - core/annotations - qgsannotationmanager.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 1 0.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       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                 :            : 
      24                 :            : class QgsReadWriteContext;
      25                 :            : class QgsProject;
      26                 :            : class QgsAnnotation;
      27                 :            : class QgsStyleEntityVisitorInterface;
      28                 :            : 
      29                 :            : /**
      30                 :            :  * \ingroup core
      31                 :            :  * \class QgsAnnotationManager
      32                 :            :  *
      33                 :            :  * \brief Manages storage of a set of QgsAnnotation annotation objects.
      34                 :            :  *
      35                 :            :  * QgsAnnotationManager handles the storage, serializing and deserializing
      36                 :            :  * of QgsAnnotations. Usually this class is not constructed directly, but
      37                 :            :  * rather accessed through a QgsProject via QgsProject::annotationManager().
      38                 :            :  *
      39                 :            :  * QgsAnnotationManager retains ownership of all the annotations contained
      40                 :            :  * in the manager.
      41                 :            :  *
      42                 :            :  * \since QGIS 3.0
      43                 :            :  */
      44                 :            : class CORE_EXPORT QgsAnnotationManager : public QObject
      45                 :            : {
      46                 :          0 :     Q_OBJECT
      47                 :            : 
      48                 :            :   public:
      49                 :            : 
      50                 :            :     /**
      51                 :            :      * Constructor for QgsAnnotationManager. The project will become the parent object for this
      52                 :            :      * manager.
      53                 :            :      */
      54                 :            :     explicit QgsAnnotationManager( QgsProject *project SIP_TRANSFERTHIS = nullptr );
      55                 :            : 
      56                 :            :     ~QgsAnnotationManager() override;
      57                 :            : 
      58                 :            :     /**
      59                 :            :      * Adds an annotation to the manager. Ownership of the annotation is transferred to the manager.
      60                 :            :      * Returns TRUE if the addition was successful, or FALSE if the annotation could not be added.
      61                 :            :      * \see removeAnnotation()
      62                 :            :      * \see annotationAdded()
      63                 :            :      */
      64                 :            :     bool addAnnotation( QgsAnnotation *annotation SIP_TRANSFER );
      65                 :            : 
      66                 :            :     /**
      67                 :            :      * Removes an annotation from the manager. The annotation is deleted.
      68                 :            :      * Returns TRUE if the removal was successful, or FALSE if the removal failed (eg as a result
      69                 :            :      * of removing an annotation which is not contained in the manager).
      70                 :            :      * \see addAnnotation()
      71                 :            :      * \see annotationRemoved()
      72                 :            :      * \see annotationAboutToBeRemoved()
      73                 :            :      * \see clear()
      74                 :            :      */
      75                 :            :     bool removeAnnotation( QgsAnnotation *annotation );
      76                 :            : 
      77                 :            :     /**
      78                 :            :      * Removes and deletes all annotations from the manager.
      79                 :            :      * \see removeAnnotation()
      80                 :            :      */
      81                 :            :     void clear();
      82                 :            : 
      83                 :            :     /**
      84                 :            :      * Returns a list of all annotations contained in the manager.
      85                 :            :      * \see cloneAnnotations()
      86                 :            :      */
      87                 :            :     QList< QgsAnnotation * > annotations() const;
      88                 :            : 
      89                 :            :     /**
      90                 :            :      * Returns a list containing clones of all annotations contained
      91                 :            :      * in the manager. The caller takes responsibility for deleting
      92                 :            :      * all returned annotations.
      93                 :            :      * \see annotations()
      94                 :            :      */
      95                 :            :     QList< QgsAnnotation * > cloneAnnotations() const SIP_FACTORY;
      96                 :            : 
      97                 :            :     /**
      98                 :            :      * Reads the manager's state from a DOM element, restoring all annotations
      99                 :            :      * present in the XML document.
     100                 :            :      * \see writeXml()
     101                 :            :      */
     102                 :            :     bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
     103                 :            : 
     104                 :            :     /**
     105                 :            :      * Returns a DOM element representing the state of the manager.
     106                 :            :      * \see readXml()
     107                 :            :      */
     108                 :            :     QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
     109                 :            : 
     110                 :            :     /**
     111                 :            :      * Accepts the specified style entity \a visitor, causing it to visit all style entities associated
     112                 :            :      * within the contained annotations.
     113                 :            :      *
     114                 :            :      * Returns TRUE if the visitor should continue visiting other objects, or FALSE if visiting
     115                 :            :      * should be canceled.
     116                 :            :      *
     117                 :            :      * \since QGIS 3.10
     118                 :            :      */
     119                 :            :     bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
     120                 :            : 
     121                 :            :   signals:
     122                 :            : 
     123                 :            :     //! Emitted when a annotation has been added to the manager
     124                 :            :     void annotationAdded( QgsAnnotation *annotation );
     125                 :            : 
     126                 :            :     //! Emitted when an annotation was removed from the manager
     127                 :            :     void annotationRemoved();
     128                 :            : 
     129                 :            :     //! Emitted when an annotation is about to be removed from the manager
     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

Generated by: LCOV version 1.14