26#include "moc_qgslayoutitemguiregistry.cpp"
65 qDeleteAll( mMetadata );
70 return mMetadata.value( metadataId );
75 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
77 if ( it.value()->type() == type )
88 const int id = mMetadata.count();
89 mMetadata[id] = metadata;
97 auto it = mMetadata.find( metadataId );
98 if ( it == mMetadata.end() )
100 mMetadata.erase( it );
114 if ( mItemGroups.contains( group.
id ) )
117 mItemGroups.insert( group.
id, group );
123 return mItemGroups[id];
128 auto it = mItemGroups.find(
id );
129 if ( it == mItemGroups.end() )
132 mItemGroups.erase( it );
139 auto it = mMetadata.constFind( metadataId );
140 if ( it == mMetadata.constEnd() )
143 std::unique_ptr<QgsLayoutItem> item( it.value()->createItem( layout ) );
145 return item.release();
147 const int type = it.value()->type();
153 auto it = mMetadata.constFind( metadataId );
154 if ( it == mMetadata.constEnd() )
159 metadata->newItemAddedToLayout( item, properties );
163 it.value()->newItemAddedToLayout( item );
172 int type = item->
type();
177 type = multiFrame->
type();
179 for (
auto it = mMetadata.constBegin(); it != mMetadata.constEnd(); ++it )
181 if ( it.value()->type() == type )
182 return it.value()->createItemWidget( item );
190 auto it = mMetadata.constFind( metadataId );
191 if ( it == mMetadata.constEnd() )
194 return it.value()->createRubberBand( view );
199 auto it = mMetadata.constFind( metadataId );
200 if ( it == mMetadata.constEnd() )
203 return it.value()->createNodeRubberBand( view );
208 return mMetadata.keys();
MouseHandlesAction
Action to be performed by the mouse handles.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
Stores GUI metadata about a group of layout item classes.
QString id
Unique (untranslated) group ID string.
bool removeItemGroup(const QString &id)
Unregisters an item group from the registry.
QgsLayoutItemBaseWidget * createItemWidget(QgsLayoutItem *item) const
Creates a new instance of a layout item configuration widget for the specified item.
bool removeLayoutItemGuiMetadata(int type)
Unregisters the GUI metadata for a layout item type.
void newItemAddedToLayout(int metadataId, QgsLayoutItem *item, const QVariantMap &properties=QVariantMap())
Called when a newly created item of the associated metadata metadataId has been added to a layout.
bool addItemGroup(const QgsLayoutItemGuiGroup &group)
Registers a new item group with the registry.
~QgsLayoutItemGuiRegistry() override
const QgsLayoutItemGuiGroup & itemGroup(const QString &id)
Returns a reference to the item group with matching id.
int metadataIdForItemType(int type) const
Returns the GUI item metadata ID which corresponds to the specified layout item type.
QgsLayoutItemGuiRegistry(QObject *parent=nullptr)
Creates a new empty item GUI registry.
QList< int > itemMetadataIds() const
Returns a list of available item metadata ids handled by the registry.
bool addLayoutItemGuiMetadata(QgsLayoutItemAbstractGuiMetadata *metadata)
Registers the GUI metadata for a new layout item type.
void typeRemoved(int metadataId)
Emitted whenever an item type is removed from the registry, with the specified metadataId.
void groupRemoved(QString groupId)
Emitted whenever an item group is removed from the registry.
QgsLayoutViewRubberBand * createItemRubberBand(int metadataId, QgsLayoutView *view) const
Creates a new rubber band item for the specified item metadataId and destination view.
QGraphicsItem * createNodeItemRubberBand(int metadataId, QgsLayoutView *view)
Creates a rubber band for the specified item metadataId and destination view.
QgsLayoutItem * createItem(int metadataId, QgsLayout *layout) const
Creates a new instance of a layout item given the item metadata metadataId, target layout.
QgsLayoutItemAbstractGuiMetadata * itemMetadata(int metadataId) const
Returns the metadata for the specified item metadataId.
void typeAdded(int metadataId)
Emitted whenever a new item type is added to the registry, with the specified metadataId.
@ LayoutFrame
Frame item, part of a QgsLayoutMultiFrame object.
QgsLayoutItem * createItem(int type, QgsLayout *layout) const
Creates a new instance of a layout item given the item type, and target layout.
Base class for graphical items within a QgsLayout.
int type() const override
Returns a unique graphics item type identifier.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
virtual int type() const =0
Returns unique multiframe type id.
A rectangular rubber band for use within QgsLayoutView widgets.
An abstract base class for temporary rubber band items in various shapes, for use within QgsLayoutVie...
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.