24#include <QImageReader>
26#include "moc_qgsannotationitemguiregistry.cpp"
99 qDeleteAll( mMetadata );
104 return mMetadata.value( metadataId );
109 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
111 if ( it.value()->type() == type )
122 const int id = mMetadata.count();
123 mMetadata[id] = metadata;
130 if ( mItemGroups.contains( group.
id ) )
133 mItemGroups.insert( group.
id, group );
139 auto iter = mItemGroups.find(
id );
140 if ( iter == mItemGroups.end() )
150 auto it = mMetadata.constFind( metadataId );
151 if ( it == mMetadata.constEnd() )
154 std::unique_ptr<QgsAnnotationItem> item( it.value()->createItem() );
156 return item.release();
158 const QString type = it.value()->type();
164 auto it = mMetadata.constFind( metadataId );
165 if ( it == mMetadata.constEnd() )
168 it.value()->newItemAddedToLayer( item, layer );
176 const QString &type = item->
type();
177 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
179 if ( it.value()->type() == type )
180 return it.value()->createItemWidget( item );
188 return mMetadata.keys();
194 QgsAnnotationPolygonItemWidget *widget =
new QgsAnnotationPolygonItemWidget(
nullptr );
195 widget->setItem( item );
199 QgsAnnotationLineItemWidget *widget =
new QgsAnnotationLineItemWidget(
nullptr );
200 widget->setItem( item );
204 QgsAnnotationMarkerItemWidget *widget =
new QgsAnnotationMarkerItemWidget(
nullptr );
205 widget->setItem( item );
209 QgsAnnotationPointTextItemWidget *widget =
new QgsAnnotationPointTextItemWidget(
nullptr );
210 widget->setItem( item );
214 QgsAnnotationLineTextItemWidget *widget =
new QgsAnnotationLineTextItemWidget(
nullptr );
215 widget->setItem( item );
219 QgsAnnotationRectangleTextItemWidget *widget =
new QgsAnnotationRectangleTextItemWidget(
nullptr );
220 widget->setItem( item );
224 QgsAnnotationPictureItemWidget *widget =
new QgsAnnotationPictureItemWidget(
nullptr );
225 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) const
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.