18#include "moc_qgsannotationitemguiregistry.cpp"
25#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 QgsAnnotationPolygonItemWidget *widget =
new QgsAnnotationPolygonItemWidget(
nullptr );
186 widget->setItem( item );
190 QgsAnnotationLineItemWidget *widget =
new QgsAnnotationLineItemWidget(
nullptr );
191 widget->setItem( item );
195 QgsAnnotationMarkerItemWidget *widget =
new QgsAnnotationMarkerItemWidget(
nullptr );
196 widget->setItem( item );
200 QgsAnnotationPointTextItemWidget *widget =
new QgsAnnotationPointTextItemWidget(
nullptr );
201 widget->setItem( item );
205 QgsAnnotationLineTextItemWidget *widget =
new QgsAnnotationLineTextItemWidget(
nullptr );
206 widget->setItem( item );
210 QgsAnnotationRectangleTextItemWidget *widget =
new QgsAnnotationRectangleTextItemWidget(
nullptr );
211 widget->setItem( item );
215 QgsAnnotationPictureItemWidget *widget =
new QgsAnnotationPictureItemWidget(
nullptr );
216 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.