27 , mUuid( QUuid::createUuid().toString() )
36 element.setAttribute( QStringLiteral(
"uuid" ),
mUuid );
37 element.setAttribute( QStringLiteral(
"name" ),
mName );
38 element.setAttribute( QStringLiteral(
"show" ),
mEnabled );
39 element.setAttribute( QStringLiteral(
"position" ), static_cast< int >(
mStackingPosition ) );
55 mUuid = itemElem.attribute( QStringLiteral(
"uuid" ) );
56 mName = itemElem.attribute( QStringLiteral(
"name" ) );
57 mEnabled = ( itemElem.attribute( QStringLiteral(
"show" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
60 const QString layerId = itemElem.attribute( QStringLiteral(
"stackingLayer" ) );
61 const QString layerName = itemElem.attribute( QStringLiteral(
"stackingLayerName" ) );
62 const QString layerSource = itemElem.attribute( QStringLiteral(
"stackingLayerSource" ) );
63 const QString layerProvider = itemElem.attribute( QStringLiteral(
"stackingLayerProvider" ) );
142 for (
int i =
mItems.size() - 1; i >= 0; --i )
144 if (
mItems.at( i )->id() == itemId )
146 delete mItems.takeAt( i );
160 int index =
mItems.indexOf( targetItem );
161 if ( index >=
mItems.size() - 1 )
165 mItems.swap( index, index + 1 );
176 int index =
mItems.indexOf( targetItem );
181 mItems.swap( index, index - 1 );
188 if (
item->
id() == itemId )
199 if ( index <
mItems.length() )
201 return mItems.at( index );
214 QList< QgsLayoutItemMapItem * > list;
215 list.reserve(
mItems.size() );
257 if ( !ignoreStacking )
The class is used as a container of context for various read/write operations on other objects...
Base class for all map layer types.
QString mName
Friendly display name.
_LayerRef< QgsMapLayer > QgsMapLayerRef
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
QgsLayoutItemMapItem(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItem, attached to the specified map.
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered...
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
TYPE * resolveWeakly(const QgsProject *project)
Resolves the map layer by attempting to find a matching layer in a project using a weak match...
Render above a specific map layer (see stackingLayer())
virtual ~QgsLayoutItemMapItemStack()
Render below a specific map layer (see stackingLayer())
void removeItems()
Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
Render above all map layers, but below map labels.
QgsLayoutItemMap * mMap
Associated map.
QgsLayoutItemMapItemStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
bool mEnabled
True if item is to be displayed on map.
Layout graphical items for displaying a map.
QString provider
Weak reference to layer provider.
QString layerId
Original layer ID.
const QgsLayout * layout() const
Returns the layout the object is attached to.
void setName(const QString &name)
Sets the friendly display name for the item.
StackingPosition mStackingPosition
void addItem(QgsLayoutItemMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
QString name
Weak reference to layer name.
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
bool enabled() const
Returns whether the item will be drawn.
QgsMapLayer * stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be re...
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString source
Weak reference to layer public source.
void moveItemUp(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items...
void setStackingLayer(QgsMapLayer *layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rende...
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
bool containsAdvancedEffects() const
Returns whether any items within the stack contain advanced effects, such as blending modes...
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'Layout...
QList< QgsLayoutItemMapItem *> asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
QgsMapLayerRef mStackingLayer
QgsLayoutItemMapItem * item(const QString &itemId) const
Returns a reference to an item which matching itemId within the stack.
virtual bool writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) const
Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a...
void setMap(QgsLayoutItemMap *map)
Sets the corresponding layout map for the item.
QgsProject * project() const
The project associated with the layout.
QString id() const
Returns the unique id for the map item.
A base class for objects which belong to a layout.
void drawItems(QPainter *painter, bool ignoreStacking=true)
Draws the items from the stack on a specified painter.
void removeItem(const QString &itemId)
Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapIt...
void moveItemDown(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items...
QList< QgsLayoutItemMapItem *> mItems
void setEnabled(bool enabled)
Controls whether the item will be drawn.
TYPE * get() const
Returns a pointer to the layer, or nullptr if the reference has not yet been matched to a layer...
QString name() const
Returns the friendly display name for the item.
Render above all map layers and labels.
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMa...
Render below all map layers.