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¶
Base classes¶
Methods
Registers the gui metadata for a new annotation item type. |
|
Populates the registry with default items. |
|
Registers a new item group with the registry. |
|
Creates a new instance of an annotation item given the item metadata metadataId. |
|
Creates a new instance of an annotation item configuration widget for the specified item. |
|
Returns a reference to the item group with matching id. |
|
Returns the metadata for the specified item metadataId. |
|
Returns a list of available item metadata ids handled by the registry. |
|
Returns the GUI item metadata ID which corresponds to the specified annotation item type. |
|
Called when a newly created item of the associated metadata metadataId has been added to a layer. |
Signals
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
- 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, orFalse
if group could not be added (e.g. due to duplicate id value).See also
- 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
- Parameters:
id (Optional[str])
- Return type:
- itemMetadata(self, metadataId: int) QgsAnnotationItemAbstractGuiMetadata | None [source]¶
Returns the metadata for the specified item
metadataId
. ReturnsNone
if a correspondingmetadataId
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 alayer
.This is only called for additions which result from GUI operations - i.e. it is not called for items added programmatically.
- Parameters:
metadataId (int)
item (Optional[QgsAnnotationItem])
layer (Optional[QgsAnnotationLayer])