24#include <QImageReader>
98 qDeleteAll( mMetadata );
103 return mMetadata.value( metadataId );
108 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
110 if ( it.value()->type() == type )
121 const int id = mMetadata.count();
122 mMetadata[id] = metadata;
129 if ( mItemGroups.contains( group.
id ) )
132 mItemGroups.insert( group.
id, group );
138 return mItemGroups[ id ];
143 if ( !mMetadata.contains( metadataId ) )
146 std::unique_ptr< QgsAnnotationItem > item( mMetadata.value( metadataId )->createItem() );
148 return item.release();
150 const QString type = mMetadata.value( metadataId )->type();
156 if ( !mMetadata.contains( metadataId ) )
159 mMetadata.value( metadataId )->newItemAddedToLayer( item, layer );
167 const QString &type = item->
type();
168 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
170 if ( it.value()->type() == type )
171 return it.value()->createItemWidget( item );
179 return mMetadata.keys();
185 QObject::tr(
"Polygon Annotation" ),
189 QgsAnnotationPolygonItemWidget *widget =
new QgsAnnotationPolygonItemWidget(
nullptr );
190 widget->setItem( item );
199 QObject::tr(
"Line Annotation" ),
203 QgsAnnotationLineItemWidget *widget =
new QgsAnnotationLineItemWidget(
nullptr );
204 widget->setItem( item );
213 QObject::tr(
"Marker Annotation" ),
217 QgsAnnotationMarkerItemWidget *widget =
new QgsAnnotationMarkerItemWidget(
nullptr );
218 widget->setItem( item );
227 QObject::tr(
"Text Annotation at Point" ),
231 QgsAnnotationPointTextItemWidget *widget =
new QgsAnnotationPointTextItemWidget(
nullptr );
232 widget->setItem( item );
241 QObject::tr(
"Text Annotation along Line" ),
245 QgsAnnotationLineTextItemWidget *widget =
new QgsAnnotationLineTextItemWidget(
nullptr );
246 widget->setItem( item );
255 QObject::tr(
"Text Annotation in Rectangle" ),
259 QgsAnnotationRectangleTextItemWidget *widget =
new QgsAnnotationRectangleTextItemWidget(
nullptr );
260 widget->setItem( item );
269 QObject::tr(
"Picture" ),
273 QgsAnnotationPictureItemWidget *widget =
new QgsAnnotationPictureItemWidget(
nullptr );
274 widget->setItem( item );
QFlags< AnnotationItemGuiFlag > AnnotationItemGuiFlags
Annotation item GUI flags.
Stores GUI metadata about a group of annotation item classes.
QString id
Unique (untranslated) group ID string.
QgsAnnotationItemBaseWidget * createItemWidget(QgsAnnotationItem *item) const
Creates a new instance of an annotation item configuration widget for the specified item.
bool addItemGroup(const QgsAnnotationItemGuiGroup &group)
Registers a new item group with the registry.
QgsAnnotationItemAbstractGuiMetadata * itemMetadata(int metadataId) const
Returns the metadata for the specified item metadataId.
bool addAnnotationItemGuiMetadata(QgsAnnotationItemAbstractGuiMetadata *metadata)
Registers the gui metadata for a new annotation item type.
void addDefaultItems()
Populates the registry with default items.
QList< int > itemMetadataIds() const
Returns a list of available item metadata ids handled by the registry.
int metadataIdForItemType(const QString &type) const
Returns the GUI item metadata ID which corresponds to the specified annotation item type.
~QgsAnnotationItemGuiRegistry() override
const QgsAnnotationItemGuiGroup & itemGroup(const QString &id)
Returns a reference to the item group with matching id.
void typeAdded(int metadataId)
Emitted whenever a new item type is added to the registry, with the specified metadataId.
QgsAnnotationItem * createItem(int metadataId) const
Creates a new instance of an annotation item given the item metadata metadataId.
void newItemAddedToLayer(int metadataId, QgsAnnotationItem *item, QgsAnnotationLayer *layer)
Called when a newly created item of the associated metadata metadataId has been added to a layer.
QgsAnnotationItemGuiRegistry(QObject *parent=nullptr)
Creates a new empty item GUI registry.
QgsAnnotationItem * createItem(const QString &type) const
Creates a new instance of a annotation item given the item type.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.
Represents a map layer containing a set of georeferenced annotations, e.g.
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A map tool to digitize line text items.
A map tool to digitize point text items.
A map tool to digitize rectangle text items.
Map canvas is a class for displaying all GIS data types on a canvas.