24#include <QImageReader>
27#include "moc_qgsannotationitemguiregistry.cpp"
29using namespace Qt::StringLiterals;
100 qDeleteAll( mMetadata );
105 return mMetadata.value( metadataId );
110 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
112 if ( it.value()->type() == type )
123 const int id = mMetadata.count();
124 mMetadata[id] = metadata;
131 if ( mItemGroups.contains( group.
id ) )
134 mItemGroups.insert( group.
id, group );
140 auto iter = mItemGroups.find(
id );
141 if ( iter == mItemGroups.end() )
151 auto it = mMetadata.constFind( metadataId );
152 if ( it == mMetadata.constEnd() )
155 std::unique_ptr<QgsAnnotationItem> item( it.value()->createItem() );
157 return item.release();
159 const QString type = it.value()->type();
165 auto it = mMetadata.constFind( metadataId );
166 if ( it == mMetadata.constEnd() )
169 it.value()->newItemAddedToLayer( item, layer );
177 const QString &type = item->
type();
178 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
180 if ( it.value()->type() == type )
181 return it.value()->createItemWidget( item );
189 return mMetadata.keys();
196 QObject::tr(
"Polygon Annotation" ),
199 QgsAnnotationPolygonItemWidget *widget =
new QgsAnnotationPolygonItemWidget(
nullptr );
200 widget->setItem( item );
211 QObject::tr(
"Line Annotation" ),
214 QgsAnnotationLineItemWidget *widget =
new QgsAnnotationLineItemWidget(
nullptr );
215 widget->setItem( item );
226 QObject::tr(
"Marker Annotation" ),
229 QgsAnnotationMarkerItemWidget *widget =
new QgsAnnotationMarkerItemWidget(
nullptr );
230 widget->setItem( item );
241 QObject::tr(
"Text Annotation at Point" ),
244 QgsAnnotationPointTextItemWidget *widget =
new QgsAnnotationPointTextItemWidget(
nullptr );
245 widget->setItem( item );
256 QObject::tr(
"Text Annotation along Line" ),
259 QgsAnnotationLineTextItemWidget *widget =
new QgsAnnotationLineTextItemWidget(
nullptr );
260 widget->setItem( item );
271 QObject::tr(
"Text Annotation in Rectangle" ),
274 QgsAnnotationRectangleTextItemWidget *widget =
new QgsAnnotationRectangleTextItemWidget(
nullptr );
275 widget->setItem( item );
286 QObject::tr(
"Picture Annotation" ),
289 QgsAnnotationPictureItemWidget *widget =
new QgsAnnotationPictureItemWidget(
nullptr );
290 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.