18#include "moc_qgsannotationitemregistry.cpp"
36 qDeleteAll( mMetadata );
41 if ( !mMetadata.isEmpty() )
44 mMetadata.insert( QStringLiteral(
"marker" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"marker" ), QObject::tr(
"Marker" ), QObject::tr(
"Markers" ),
46 mMetadata.insert( QStringLiteral(
"linestring" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"linestring" ), QObject::tr(
"Polyline" ), QObject::tr(
"Polylines" ),
48 mMetadata.insert( QStringLiteral(
"polygon" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"polygon" ), QObject::tr(
"Polygon" ), QObject::tr(
"Polygons" ),
50 mMetadata.insert( QStringLiteral(
"pointtext" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"pointtext" ), QObject::tr(
"Text at point" ), QObject::tr(
"Text at points" ),
52 mMetadata.insert( QStringLiteral(
"linetext" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"linetext" ), QObject::tr(
"Text along line" ), QObject::tr(
"Text along lines" ),
54 mMetadata.insert( QStringLiteral(
"recttext" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"recttext" ), QObject::tr(
"Text in rectangle" ), QObject::tr(
"Text in rectangles" ),
56 mMetadata.insert( QStringLiteral(
"picture" ),
new QgsAnnotationItemMetadata( QStringLiteral(
"picture" ), QObject::tr(
"Picture" ), QObject::tr(
"Pictures" ),
63 return mMetadata.value( type );
68 if ( !metadata || mMetadata.contains( metadata->
type() ) )
71 mMetadata[metadata->
type()] = metadata;
78 if ( !mMetadata.contains( type ) )
81 return mMetadata[type]->createItem();
86 QMap<QString, QString> types;
87 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
89 types.insert( it.key(), it.value()->visibleName() );
QgsAnnotationItem * createItem(const QString &type) const
Creates a new instance of a annotation item given the item type.
QgsAnnotationItemAbstractMetadata * itemMetadata(const QString &type) const
Returns the metadata for the specified item type.
~QgsAnnotationItemRegistry() override
void typeAdded(const QString &type, const QString &name)
Emitted whenever a new item type is added to the registry, with the specified type and visible name.
bool populate()
Populates the registry with standard item types.
QgsAnnotationItemRegistry(QObject *parent=nullptr)
Creates a new empty item registry.
QMap< QString, QString > itemTypes() const
Returns a map of available item types to translated name.
bool addItemType(QgsAnnotationItemAbstractMetadata *metadata)
Registers a new annotation item type.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
static QgsAnnotationLineItem * create()
Creates a new linestring annotation item.
static QgsAnnotationLineTextItem * create()
Creates a new linestring annotation item.
static QgsAnnotationMarkerItem * create()
Creates a new marker annotation item.
static QgsAnnotationPictureItem * create()
Creates a new polygon annotation item.
static QgsAnnotationPointTextItem * create()
Creates a new text at point annotation item.
static QgsAnnotationPolygonItem * create()
Creates a new polygon annotation item.
static QgsAnnotationRectangleTextItem * create()
Creates a new rectangle text annotation item.