Class: QgsAnnotationItemGuiRegistry

Registry of available annotation item GUI behavior.

QgsAnnotationItemGuiRegistry is not usually directly created, but rather accessed through QgsGui.annotationItemGuiRegistry().

This acts as a companion to QgsAnnotationItemRegistry, handling only the components related to the GUI behavior of annotation items.

Added in version 3.22.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAnnotationItemGuiRegistry

Base classes

QObject

Methods

addAnnotationItemGuiMetadata

Registers the gui metadata for a new annotation item type.

addDefaultItems

Populates the registry with default items.

addItemGroup

Registers a new item group with the registry.

createItem

Creates a new instance of an annotation item given the item metadata metadataId.

createItemWidget

Creates a new instance of an annotation item configuration widget for the specified item.

itemGroup

Returns a reference to the item group with matching id.

itemMetadata

Returns the metadata for the specified item metadataId.

itemMetadataIds

Returns a list of available item metadata ids handled by the registry.

metadataIdForItemType

Returns the GUI item metadata ID which corresponds to the specified annotation item type.

newItemAddedToLayer

Called when a newly created item of the associated metadata metadataId has been added to a layer.

Signals

typeAdded

Emitted whenever a new item type is added to the registry, with the specified metadataId.

class qgis.gui.QgsAnnotationItemGuiRegistry[source]

Bases: QObject

__init__(parent: QObject | None = None)

Creates a new empty item GUI registry.

QgsAnnotationItemGuiRegistry is not usually directly created, but rather accessed through QgsGui.annotationItemGuiRegistry().

Parameters:

parent (Optional[QObject] = None)

addAnnotationItemGuiMetadata(self, metadata: QgsAnnotationItemAbstractGuiMetadata | None) bool[source]

Registers the gui metadata for a new annotation item type. Takes ownership of the metadata instance.

Parameters:

metadata (Optional[QgsAnnotationItemAbstractGuiMetadata])

Return type:

bool

addDefaultItems(self)[source]

Populates the registry with default items.

addItemGroup(self, group: QgsAnnotationItemGuiGroup) bool[source]

Registers a new item group with the registry. This must be done before calling addAnnotationItemGuiMetadata() for any item types associated with the group.

Returns True if group was added, or False if group could not be added (e.g. due to duplicate id value).

See also

itemGroup()

Parameters:

group (QgsAnnotationItemGuiGroup)

Return type:

bool

createItem(self, metadataId: int) QgsAnnotationItem | None[source]

Creates a new instance of an annotation item given the item metadata metadataId.

Parameters:

metadataId (int)

Return type:

Optional[QgsAnnotationItem]

createItemWidget(self, item: QgsAnnotationItem | None) QgsAnnotationItemBaseWidget | None[source]

Creates a new instance of an annotation item configuration widget for the specified item.

Parameters:

item (Optional[QgsAnnotationItem])

Return type:

Optional[QgsAnnotationItemBaseWidget]

itemGroup(self, id: str | None) QgsAnnotationItemGuiGroup

Returns a reference to the item group with matching id.

See also

addItemGroup()

Parameters:

id (Optional[str])

Return type:

QgsAnnotationItemGuiGroup

itemMetadata(self, metadataId: int) QgsAnnotationItemAbstractGuiMetadata | None[source]

Returns the metadata for the specified item metadataId. Returns None if a corresponding metadataId was not found in the registry.

Parameters:

metadataId (int)

Return type:

Optional[QgsAnnotationItemAbstractGuiMetadata]

itemMetadataIds(self) List[int]

Returns a list of available item metadata ids handled by the registry.

Return type:

List[int]

metadataIdForItemType(self, type: str | None) int[source]

Returns the GUI item metadata ID which corresponds to the specified annotation item type.

In the case that multiple GUI metadata classes exist for a single annotation item type then only the first encountered GUI metadata ID will be returned.

Returns -1 if no matching metadata is found in the GUI registry.

Parameters:

type (Optional[str])

Return type:

int

newItemAddedToLayer(self, metadataId: int, item: QgsAnnotationItem | None, layer: QgsAnnotationLayer | None)[source]

Called when a newly created item of the associated metadata metadataId has been added to a layer.

This is only called for additions which result from GUI operations - i.e. it is not called for items added programmatically.

Parameters:
signal typeAdded(metadataId: int)[source]

Emitted whenever a new item type is added to the registry, with the specified metadataId.

Parameters:

metadataId (int)