QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
95 qDeleteAll( mMetadata );
100 return mMetadata.value( metadataId );
105 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
107 if ( it.value()->type() == type )
118 const int id = mMetadata.count();
119 mMetadata[id] = metadata;
126 if ( mItemGroups.contains( group.
id ) )
129 mItemGroups.insert( group.
id, group );
135 return mItemGroups[ id ];
140 if ( !mMetadata.contains( metadataId ) )
143 std::unique_ptr< QgsAnnotationItem > item( mMetadata.value( metadataId )->createItem() );
145 return item.release();
147 const QString type = mMetadata.value( metadataId )->type();
153 if ( !mMetadata.contains( metadataId ) )
156 mMetadata.value( metadataId )->newItemAddedToLayer( item, layer );
164 const QString &type = item->
type();
165 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
167 if ( it.value()->type() == type )
168 return it.value()->createItemWidget( item );
176 return mMetadata.keys();
182 QObject::tr(
"Polygon" ),
186 QgsAnnotationPolygonItemWidget *widget =
new QgsAnnotationPolygonItemWidget(
nullptr );
187 widget->setItem( item );
189 }, QString(), Qgis::AnnotationItemGuiFlags(),
nullptr,
192 return new QgsCreatePolygonItemMapTool( canvas, cadDockWidget );
196 QObject::tr(
"Line" ),
200 QgsAnnotationLineItemWidget *widget =
new QgsAnnotationLineItemWidget(
nullptr );
201 widget->setItem( item );
203 }, QString(), Qgis::AnnotationItemGuiFlags(),
nullptr,
206 return new QgsCreateLineItemMapTool( canvas, cadDockWidget );
210 QObject::tr(
"Marker" ),
214 QgsAnnotationMarkerItemWidget *widget =
new QgsAnnotationMarkerItemWidget(
nullptr );
215 widget->setItem( item );
217 }, QString(), Qgis::AnnotationItemGuiFlags(),
nullptr,
220 return new QgsCreateMarkerItemMapTool( canvas, cadDockWidget );
224 QObject::tr(
"Text at Point" ),
228 QgsAnnotationPointTextItemWidget *widget =
new QgsAnnotationPointTextItemWidget(
nullptr );
229 widget->setItem( item );
231 }, QString(), Qgis::AnnotationItemGuiFlags(),
nullptr,
234 return new QgsCreatePointTextItemMapTool( canvas, cadDockWidget );
int metadataIdForItemType(const QString &type) const
Returns the GUI item metadata ID which corresponds to the specified annotation item type.
QString id
Unique (untranslated) group ID string.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsAnnotationItemGuiGroup & itemGroup(const QString &id)
Returns a reference to the item group with matching id.
QList< int > itemMetadataIds() const
Returns a list of available item metadata ids handled by the registry.
bool addAnnotationItemGuiMetadata(QgsAnnotationItemAbstractGuiMetadata *metadata)
Registers the gui metadata for a new annotation item type.
~QgsAnnotationItemGuiRegistry() override
QgsAnnotationItem * createItem(const QString &type) const
Creates a new instance of a annotation item given the item type.
QgsAnnotationItem * createItem(int metadataId) const
Creates a new instance of an annotation item given the item metadata metadataId.
void typeAdded(int metadataId)
Emitted whenever a new item type is added to the registry, with the specified metadataId.
QgsAnnotationItemAbstractGuiMetadata * itemMetadata(int metadataId) const
Returns the metadata for the specified item 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.
Represents a map layer containing a set of georeferenced annotations, e.g. markers,...
QgsAnnotationItemGuiRegistry(QObject *parent=nullptr)
Creates a new empty item GUI registry.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
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.
Stores GUI metadata about a group of annotation item classes.
void addDefaultItems()
Populates the registry with default items.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.