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 Annotation" ),
 
  186    QgsAnnotationPolygonItemWidget *widget = 
new QgsAnnotationPolygonItemWidget( 
nullptr );
 
  187    widget->setItem( item );
 
  192    return new QgsCreatePolygonItemMapTool( canvas, cadDockWidget );
 
  196                                QObject::tr( 
"Line Annotation" ),
 
  200    QgsAnnotationLineItemWidget *widget = 
new QgsAnnotationLineItemWidget( 
nullptr );
 
  201    widget->setItem( item );
 
  206    return new QgsCreateLineItemMapTool( canvas, cadDockWidget );
 
  210                                QObject::tr( 
"Marker Annotation" ),
 
  214    QgsAnnotationMarkerItemWidget *widget = 
new QgsAnnotationMarkerItemWidget( 
nullptr );
 
  215    widget->setItem( item );
 
  220    return new QgsCreateMarkerItemMapTool( canvas, cadDockWidget );
 
  224                                QObject::tr( 
"Text Annotation at Point" ),
 
  228    QgsAnnotationPointTextItemWidget *widget = 
new QgsAnnotationPointTextItemWidget( 
nullptr );
 
  229    widget->setItem( item );
 
  234    return new QgsCreatePointTextItemMapTool( canvas, cadDockWidget );
 
  238                                QObject::tr( 
"Text Annotation along Line" ),
 
  242    QgsAnnotationLineTextItemWidget *widget = 
new QgsAnnotationLineTextItemWidget( 
nullptr );
 
  243    widget->setItem( item );
 
  248    return new QgsCreateLineTextItemMapTool( canvas, cadDockWidget );
 
 
QFlags< AnnotationItemGuiFlag > AnnotationItemGuiFlags
Annotation item GUI flags.
 
Stores GUI metadata about a group of annotation item classes.
 
QString id
Unique (untranslated) group ID string.
 
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.
 
QgsAnnotationItemAbstractGuiMetadata * itemMetadata(int metadataId) const
Returns the metadata for the specified item metadataId.
 
bool addAnnotationItemGuiMetadata(QgsAnnotationItemAbstractGuiMetadata *metadata)
Registers the gui metadata for a new annotation item type.
 
void addDefaultItems()
Populates the registry with default items.
 
QList< int > itemMetadataIds() const
Returns a list of available item metadata ids handled by the registry.
 
int metadataIdForItemType(const QString &type) const
Returns the GUI item metadata ID which corresponds to the specified annotation item type.
 
~QgsAnnotationItemGuiRegistry() override
 
const QgsAnnotationItemGuiGroup & itemGroup(const QString &id)
Returns a reference to the item group with matching id.
 
void typeAdded(int metadataId)
Emitted whenever a new item type is added to the registry, with the specified metadataId.
 
QgsAnnotationItem * createItem(int metadataId) const
Creates a new instance of an annotation item given the item metadata 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.
 
QgsAnnotationItemGuiRegistry(QObject *parent=nullptr)
Creates a new empty item GUI registry.
 
QgsAnnotationItem * createItem(const QString &type) const
Creates a new instance of a annotation item given the item type.
 
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
 
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.
 
Represents a map layer containing a set of georeferenced annotations, e.g.
 
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
Map canvas is a class for displaying all GIS data types on a canvas.