27 , mUuid( QUuid::createUuid().toString() )
39 element.setAttribute( QStringLiteral(
"uuid" ),
mUuid );
40 element.setAttribute( QStringLiteral(
"name" ),
mName );
41 element.setAttribute( QStringLiteral(
"show" ),
mEnabled );
42 element.setAttribute( QStringLiteral(
"position" ), static_cast< int >(
mStackingPosition ) );
59 mUuid = itemElem.attribute( QStringLiteral(
"uuid" ) );
60 mName = itemElem.attribute( QStringLiteral(
"name" ) );
61 mEnabled = ( itemElem.attribute( QStringLiteral(
"show" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
64 const QString layerId = itemElem.attribute( QStringLiteral(
"stackingLayer" ) );
65 const QString layerName = itemElem.attribute( QStringLiteral(
"stackingLayerName" ) );
66 const QString layerSource = itemElem.attribute( QStringLiteral(
"stackingLayerSource" ) );
67 const QString layerProvider = itemElem.attribute( QStringLiteral(
"stackingLayerProvider" ) );
159 for (
int i =
mItems.size() - 1; i >= 0; --i )
161 if (
mItems.at( i )->id() == itemId )
163 delete mItems.takeAt( i );
177 int index =
mItems.indexOf( targetItem );
178 if ( index >=
mItems.size() - 1 )
182 mItems.swap( index, index + 1 );
193 int index =
mItems.indexOf( targetItem );
198 mItems.swap( index, index - 1 );
205 if (
item->
id() == itemId )
216 if ( index <
mItems.length() )
218 return mItems.at( index );
231 QList< QgsLayoutItemMapItem * > list;
232 list.reserve(
mItems.size() );
274 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.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the objects' current state.
_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...
bool readObjectPropertiesFromElement(const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
Sets object properties from a DOM element.
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()
An interface for classes which can visit style entity (e.g.
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.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
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
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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...
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
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 * item(int index) const
Returns a reference to the item at the specified index within the stack.
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...
bool hasEnabledItems() const
Returns true if the stack has any currently enabled items.
QList< QgsLayoutItemMapItem *> asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
bool writeObjectPropertiesToElement(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
Stores object properties within an XML DOM element.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
QgsMapLayerRef mStackingLayer
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
virtual 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.