QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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" ) );
164 for (
int i =
mItems.size() - 1; i >= 0; --i )
166 if (
mItems.at( i )->id() == itemId )
168 delete mItems.takeAt( i );
182 int index =
mItems.indexOf( targetItem );
183 if ( index >=
mItems.size() - 1 )
187 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
188 mItems.swap( index, index + 1 );
190 mItems.swapItemsAt( index, index + 1 );
202 int index =
mItems.indexOf( targetItem );
207 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
208 mItems.swap( index, index - 1 );
210 mItems.swapItemsAt( index, index - 1 );
218 if (
item->
id() == itemId )
229 if ( index <
mItems.length() )
231 return mItems.at( index );
244 QList< QgsLayoutItemMapItem * > list;
245 list.reserve(
mItems.size() );
287 if ( !ignoreStacking )
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn.
const QgsLayout * layout() const
Returns the layout the object is attached to.
@ StackAboveMapLayer
Render above a specific map layer (see stackingLayer())
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
void setMap(QgsLayoutItemMap *map)
Sets the corresponding layout map for the item.
@ StackBelowMapLayer
Render below a specific map layer (see stackingLayer())
TYPE * resolveWeakly(const QgsProject *project, MatchType matchType=MatchType::All)
Resolves the map layer by attempting to find a matching layer in a project using a weak match.
The class is used as a container of context for various read/write operations on other objects.
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
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...
QString mName
Friendly display name.
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
void setName(const QString &name)
Sets the friendly display name for the item.
An interface for classes which can visit style entity (e.g.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QString id() const
Returns the unique id for the map item.
_LayerRef< QgsMapLayer > QgsMapLayerRef
void removeItems()
Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
@ StackBelowMap
Render below all map layers.
QString layerId
Original layer ID.
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
bool mEnabled
True if item is to be displayed on map.
QgsMapLayer * stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be re...
QgsLayoutItemMapItem(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItem, attached to the specified map.
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString provider
Weak reference to layer provider.
bool hasEnabledItems() const
Returns true if the stack has any currently enabled items.
QgsLayoutItemMap * mMap
Associated map.
void removeItem(const QString &itemId)
Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapIt...
QgsLayoutItemMapItemStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
QString name
Weak reference to layer name.
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...
virtual QgsMapLayer * mapLayer()
Returns the internal map layer used by this item, if available.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
bool containsAdvancedEffects() const
Returns whether any items within the stack contain advanced effects, such as blending modes.
@ StackBelowMapLabels
Render above all map layers, but below map labels.
void drawItems(QPainter *painter, bool ignoreStacking=true)
Draws the items from the stack on a specified painter.
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
void moveItemDown(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the objects' current state.
Layout graphical items for displaying a map.
QList< QgsLayoutItemMapItem * > mItems
virtual ~QgsLayoutItemMapItemStack()
bool readObjectPropertiesFromElement(const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
Sets object properties from a DOM element.
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
@ StackAboveMapLabels
Render above all map layers and labels.
QString source
Weak reference to layer public source.
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered.
Base class for all map layer types.
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...
StackingPosition mStackingPosition
QgsMapLayerRef mStackingLayer
void moveItemUp(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
QgsLayoutItemMapItem * item(int index) const
Returns a reference to the item at the specified index within the stack.
QString name() const
Returns the friendly display name for the item.
QgsProject * project() const
The project associated with the layout.
void addItem(QgsLayoutItemMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
void setStackingLayer(QgsMapLayer *layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rende...
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
bool writeObjectPropertiesToElement(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
Stores object properties within an XML DOM element.
bool enabled() const
Returns whether the item will be drawn.
A base class for objects which belong to a layout.
TYPE * get() const
Returns a pointer to the layer, or nullptr if the reference has not yet been matched to a layer.