QgsLayoutItemMapItemStack class
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
Contents
The item stack controls which items are drawn and the order they are drawn in.
Derived classes
- class QgsLayoutItemMapGridStack
- A collection of grids which is drawn above the map content in a QgsLayoutItemMap.
- class QgsLayoutItemMapOverviewStack
- A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
Constructors, destructors, conversion operators
- QgsLayoutItemMapItemStack(QgsLayoutItemMap* map)
- Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
Public functions
- auto containsAdvancedEffects() const -> bool
- Returns whether any items within the stack contain advanced effects, such as blending modes.
- void drawItems(QPainter* painter, bool ignoreStacking = true)
- Draws the items from the stack on a specified painter.
- void finalizeRestoreFromXml() virtual
- Called after all pending items have been restored from XML.
- auto readXml(const QDomElement& element, const QDomDocument& doc, const QgsReadWriteContext& context) -> bool pure virtual
- Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'LayoutMap' tag.
- auto size() const -> int
- Returns the number of items in the stack.
- auto writeXml(QDomElement& element, QDomDocument& doc, const QgsReadWriteContext& context) const -> bool virtual
- Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a 'LayoutMap' tag.
Protected functions
- void addItem(QgsLayoutItemMapItem* item)
- Adds a new map item to the stack and takes ownership of the item.
- auto asList() const -> QList<QgsLayoutItemMapItem*>
- Returns a list of QgsLayoutItemMapItems contained by the stack.
- auto item(const QString& itemId) const -> QgsLayoutItemMapItem*
- Returns a reference to an item which matching itemId within the stack.
- auto item(int index) const -> QgsLayoutItemMapItem*
- Returns a reference to the item at the specified index within the stack.
- void moveItemDown(const QString& itemId)
- Moves an item which matching itemId up the stack, causing it to be rendered above other items.
- void moveItemUp(const QString& itemId)
- Moves an item which matching itemId up the stack, causing it to be rendered above other items.
- auto operator[](int index) -> QgsLayoutItemMapItem&
- Returns a reference to an item at the specified index within the stack.
- void removeItem(const QString& itemId)
- Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapItem.
- void removeItems()
- Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
Function documentation
void QgsLayoutItemMapItemStack:: drawItems(QPainter* painter,
bool ignoreStacking = true)
Draws the items from the stack on a specified painter.
If ignoreStacking is true, then all items will be drawn, regardless of their actual stacking position settings. If it is false, only items which are set to stack above the map item will be drawn.
void QgsLayoutItemMapItemStack:: finalizeRestoreFromXml() virtual
Called after all pending items have been restored from XML.
Map item stacks can use this method to run steps which must take place after all items have been restored to the layout, such as connecting to signals emitted by other items, which may not have existed in the layout at the time readXml() was called. E.g. an overview can use this to connect to its linked map item after restoration from XML.
bool QgsLayoutItemMapItemStack:: readXml(const QDomElement& element,
const QDomDocument& doc,
const QgsReadWriteContext& context) pure virtual
Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'LayoutMap' tag.
Returns true if read was successful.
bool QgsLayoutItemMapItemStack:: writeXml(QDomElement& element,
QDomDocument& doc,
const QgsReadWriteContext& context) const virtual
Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a 'LayoutMap' tag.
Returns true if write was successful.
void QgsLayoutItemMapItemStack:: addItem(QgsLayoutItemMapItem* item) protected
Adds a new map item to the stack and takes ownership of the item.
The item will be added to the end of the stack, and rendered above any existing map items already present in the stack.
void QgsLayoutItemMapItemStack:: moveItemDown(const QString& itemId) protected
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
void QgsLayoutItemMapItemStack:: moveItemUp(const QString& itemId) protected
Moves an item which matching itemId up the stack, causing it to be rendered above other items.
QgsLayoutItemMapItem& QgsLayoutItemMapItemStack:: operator[](int index) protected
Returns a reference to an item at the specified index within the stack.
void QgsLayoutItemMapItemStack:: removeItem(const QString& itemId) protected
Removes an item which matching itemId from the stack and deletes the corresponding QgsLayoutItemMapItem.