18#include "moc_qgsannotationitemguiregistry.cpp"
25#include <QImageReader>
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 return mItemGroups[ id ];
144 if ( !mMetadata.contains( metadataId ) )
147 std::unique_ptr< QgsAnnotationItem > item( mMetadata.value( metadataId )->createItem() );
149 return item.release();
151 const QString type = mMetadata.value( metadataId )->type();
157 if ( !mMetadata.contains( metadataId ) )
160 mMetadata.value( metadataId )->newItemAddedToLayer( item, layer );
168 const QString &type = item->
type();
169 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
171 if ( it.value()->type() == type )
172 return it.value()->createItemWidget( item );
180 return mMetadata.keys();
186 QObject::tr(
"Polygon Annotation" ),
190 QgsAnnotationPolygonItemWidget *widget =
new QgsAnnotationPolygonItemWidget(
nullptr );
191 widget->setItem( item );
200 QObject::tr(
"Line Annotation" ),
204 QgsAnnotationLineItemWidget *widget =
new QgsAnnotationLineItemWidget(
nullptr );
205 widget->setItem( item );
214 QObject::tr(
"Marker Annotation" ),
218 QgsAnnotationMarkerItemWidget *widget =
new QgsAnnotationMarkerItemWidget(
nullptr );
219 widget->setItem( item );
228 QObject::tr(
"Text Annotation at Point" ),
232 QgsAnnotationPointTextItemWidget *widget =
new QgsAnnotationPointTextItemWidget(
nullptr );
233 widget->setItem( item );
242 QObject::tr(
"Text Annotation along Line" ),
246 QgsAnnotationLineTextItemWidget *widget =
new QgsAnnotationLineTextItemWidget(
nullptr );
247 widget->setItem( item );
256 QObject::tr(
"Text Annotation in Rectangle" ),
260 QgsAnnotationRectangleTextItemWidget *widget =
new QgsAnnotationRectangleTextItemWidget(
nullptr );
261 widget->setItem( item );
270 QObject::tr(
"Picture" ),
274 QgsAnnotationPictureItemWidget *widget =
new QgsAnnotationPictureItemWidget(
nullptr );
275 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.