31#include "moc_qgsannotationitemregistry.cpp"
33using namespace Qt::StringLiterals;
46 qDeleteAll( mMetadata );
51 if ( !mMetadata.isEmpty() )
66 return mMetadata.value( type );
71 if ( !metadata || mMetadata.contains( metadata->
type() ) )
74 mMetadata[metadata->
type()] = metadata;
81 if ( !mMetadata.contains( type ) )
84 return std::unique_ptr<QgsAnnotationItem>( mMetadata[type]->
createItem() );
89 QMap<QString, QString> types;
90 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
92 types.insert( it.key(), it.value()->visibleName() );
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.
std::unique_ptr< QgsAnnotationItem > createItem(const QString &type) const
Creates a new instance of a annotation item given the item type.
bool addItemType(QgsAnnotationItemAbstractMetadata *metadata)
Registers a new annotation item type.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
static std::unique_ptr< QgsAnnotationLineItem > create()
Creates a new linestring annotation item.
static std::unique_ptr< QgsAnnotationLineTextItem > create()
Creates a new linestring annotation item.
static std::unique_ptr< QgsAnnotationMarkerItem > create()
Creates a new marker annotation item.
static std::unique_ptr< QgsAnnotationPictureItem > create()
Creates a new polygon annotation item.
static std::unique_ptr< QgsAnnotationPointTextItem > create()
Creates a new text at point annotation item.
static std::unique_ptr< QgsAnnotationPolygonItem > create()
Creates a new polygon annotation item.
static std::unique_ptr< QgsAnnotationRectangleTextItem > create()
Creates a new rectangle text annotation item.