QgsLayoutItemGuiRegistry class

Registry of available layout item GUI behavior.

QgsLayoutItemGuiRegistry is not usually directly created, but rather accessed through QgsGui::layoutItemGuiRegistry().

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

Constructors, destructors, conversion operators

QgsLayoutItemGuiRegistry(QObject* parent = nullptr)
Creates a new empty item GUI registry.
QgsLayoutItemGuiRegistry(const QgsLayoutItemGuiRegistry& rh) deleted
QgsLayoutItemGuiRegistry cannot be copied.

Public functions

auto addItemGroup(const QgsLayoutItemGuiGroup& group) -> bool
Registers a new item group with the registry.
auto addLayoutItemGuiMetadata(QgsLayoutItemAbstractGuiMetadata* metadata) -> bool
Registers the gui metadata for a new layout item type.
auto createItem(int metadataId, QgsLayout* layout) const -> QgsLayoutItem*
Creates a new instance of a layout item given the item metadata metadataId, target layout.
auto createItemRubberBand(int metadataId, QgsLayoutView* view) const -> QgsLayoutViewRubberBand*
Creates a new rubber band item for the specified item metadataId and destination view.
auto createItemWidget(QgsLayoutItem* item) const -> QgsLayoutItemBaseWidget*
Creates a new instance of a layout item configuration widget for the specified item.
auto createNodeItemRubberBand(int metadataId, QgsLayoutView* view) -> QAbstractGraphicsShapeItem*
Creates a rubber band for the specified item metadataId and destination view.
auto itemGroup(const QString& id) -> const QgsLayoutItemGuiGroup&
Returns a reference to the item group with matching id.
auto itemMetadata(int metadataId) const -> QgsLayoutItemAbstractGuiMetadata*
Returns the metadata for the specified item metadataId.
auto itemMetadataIds() const -> QList<int>
Returns a list of available item metadata ids handled by the registry.
void newItemAddedToLayout(int metadataId, QgsLayoutItem* item)
Called when a newly created item of the associated metadata metadataId has been added to a layout.
auto operator=(const QgsLayoutItemGuiRegistry& rh) -> QgsLayoutItemGuiRegistry& deleted
QgsLayoutItemGuiRegistry cannot be copied.

Signals

void typeAdded(int metadataId)
Emitted whenever a new item type is added to the registry, with the specified metadataId.

Function documentation

QgsLayoutItemGuiRegistry::QgsLayoutItemGuiRegistry(QObject* parent = nullptr)

Creates a new empty item GUI registry.

QgsLayoutItemGuiRegistry is not usually directly created, but rather accessed through QgsGui::layoutItemGuiRegistry().

bool QgsLayoutItemGuiRegistry::addItemGroup(const QgsLayoutItemGuiGroup& group)

Registers a new item group with the registry.

This must be done before calling addLayoutItemGuiMetadata() 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).

bool QgsLayoutItemGuiRegistry::addLayoutItemGuiMetadata(QgsLayoutItemAbstractGuiMetadata* metadata)

Registers the gui metadata for a new layout item type.

Takes ownership of the metadata instance.

QgsLayoutViewRubberBand* QgsLayoutItemGuiRegistry::createItemRubberBand(int metadataId, QgsLayoutView* view) const

Creates a new rubber band item for the specified item metadataId and destination view.

QAbstractGraphicsShapeItem* QgsLayoutItemGuiRegistry::createNodeItemRubberBand(int metadataId, QgsLayoutView* view)

Creates a rubber band for the specified item metadataId and destination view.

Can return nullptr if no node based rubber band should be created or is applicable for the item.

const QgsLayoutItemGuiGroup& QgsLayoutItemGuiRegistry::itemGroup(const QString& id)

Returns a reference to the item group with matching id.

QgsLayoutItemAbstractGuiMetadata* QgsLayoutItemGuiRegistry::itemMetadata(int metadataId) const

Returns the metadata for the specified item metadataId.

Returns nullptr if a corresponding metadataId was not found in the registry.

void QgsLayoutItemGuiRegistry::newItemAddedToLayout(int metadataId, QgsLayoutItem* item)

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

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