26 , mUuid( QUuid::createUuid().toString() )
35 element.setAttribute( QStringLiteral(
"uuid" ),
mUuid );
36 element.setAttribute( QStringLiteral(
"name" ),
mName );
37 element.setAttribute( QStringLiteral(
"show" ),
mEnabled );
44 mUuid = itemElem.attribute( QStringLiteral(
"uuid" ) );
45 mName = itemElem.attribute( QStringLiteral(
"name" ) );
46 mEnabled = ( itemElem.attribute( QStringLiteral(
"show" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
111 for (
int i =
mItems.size() - 1; i >= 0; --i )
113 if (
mItems.at( i )->id() == itemId )
115 delete mItems.takeAt( i );
129 int index =
mItems.indexOf( targetItem );
130 if ( index >=
mItems.size() - 1 )
134 mItems.swap( index, index + 1 );
145 int index =
mItems.indexOf( targetItem );
150 mItems.swap( index, index - 1 );
157 if (
item->
id() == itemId )
168 if ( index <
mItems.length() )
170 return mItems.at( index );
183 QList< QgsLayoutItemMapItem * > list;
184 list.reserve(
mItems.size() );
The class is used as a container of context for various read/write operations on other objects...
QString mName
Friendly display name.
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.
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...
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.
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
virtual ~QgsLayoutItemMapItemStack()
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
bool containsAdvancedEffects() const
Returns whether any items within the stack contain advanced effects, such as blending modes...
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
void removeItems()
Clears the item stack and deletes all QgsLayoutItemMapItems contained by the stack.
QgsLayoutItemMap * mMap
Associated map.
QgsLayoutItemMapItemStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
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...
bool mEnabled
True if item is to be displayed on map.
Layout graphical items for displaying a map.
QString id() const
Returns the unique id for the map item.
void setName(const QString &name)
Sets the friendly display name for the item.
void addItem(QgsLayoutItemMapItem *item)
Adds a new map item to the stack and takes ownership of the item.
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
void moveItemUp(const QString &itemId)
Moves an item which matching itemId up the stack, causing it to be rendered above other items...
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
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...
void setMap(QgsLayoutItemMap *map)
Sets the corresponding layout map for the item.
QString name() const
Returns the friendly display name for the item.
A base class for objects which belong to a layout.
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...
void drawItems(QPainter *painter)
Draws the items from the stack on a specified painter.
QList< QgsLayoutItemMapItem * > mItems
void setEnabled(bool enabled)
Controls whether the item will be drawn.
bool enabled() const
Returns whether the item will be drawn.