16#ifndef QGSANNOTATIONREGISTRY_H
17#define QGSANNOTATIONREGISTRY_H
34typedef std::function <
QgsAnnotation*() > QgsCreateAnnotationFunc;
42class CORE_EXPORT QgsAnnotationMetadata
50 QgsAnnotationMetadata(
const QString &
typeName,
const QgsCreateAnnotationFunc &createFunc )
52 , mCreateFunc( createFunc )
58 QString type()
const {
return mTypeName; }
63 QgsAnnotation *createAnnotation()
const {
return mCreateFunc ? mCreateFunc() : nullptr ; }
68 QgsCreateAnnotationFunc mCreateFunc =
nullptr;
70 QgsAnnotationMetadata() =
default;
71 friend class QMap< QString, QgsAnnotationMetadata >;
81class CORE_EXPORT QgsAnnotationRegistry
90 QgsAnnotationRegistry()
102 bool addAnnotationType(
const QgsAnnotationMetadata &metadata )
104 if ( mMetadata.contains( metadata.type() ) )
107 mMetadata.insert( metadata.type(), metadata );
117 if ( !mMetadata.contains(
typeName ) )
120 return mMetadata.value(
typeName ).createAnnotation();
125 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.