16#ifndef QGSANNOTATIONREGISTRY_H
17#define QGSANNOTATIONREGISTRY_H
34typedef std::function <
QgsAnnotation*() > QgsCreateAnnotationFunc;
41class CORE_EXPORT QgsAnnotationMetadata
49 QgsAnnotationMetadata(
const QString &
typeName,
const QgsCreateAnnotationFunc &createFunc )
51 , mCreateFunc( createFunc )
57 QString type()
const {
return mTypeName; }
62 QgsAnnotation *createAnnotation()
const {
return mCreateFunc ? mCreateFunc() : nullptr ; }
67 QgsCreateAnnotationFunc mCreateFunc =
nullptr;
69 QgsAnnotationMetadata() =
default;
70 friend class QMap< QString, QgsAnnotationMetadata >;
79class CORE_EXPORT QgsAnnotationRegistry
88 QgsAnnotationRegistry()
100 bool addAnnotationType(
const QgsAnnotationMetadata &metadata )
102 if ( mMetadata.contains( metadata.type() ) )
105 mMetadata.insert( metadata.type(), metadata );
115 if ( !mMetadata.contains(
typeName ) )
118 return mMetadata.value(
typeName ).createAnnotation();
123 QMap< QString, QgsAnnotationMetadata > mMetadata;
Abstract base class for annotation items which are drawn over a map.
static QgsHtmlAnnotation * create()
Returns a new QgsHtmlAnnotation object.
static QgsSvgAnnotation * create()
Returns a new QgsSvgAnnotation object.
static QgsTextAnnotation * create()
Returns a new QgsTextAnnotation object.