QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgslayoutitemmapitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutitemmapitem.h
3  -------------------
4  begin : October 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSLAYOUTITEMMAPITEM_H
18 #define QGSLAYOUTITEMMAPITEM_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
22 #include "qgslayoutobject.h"
23 
24 class QgsLayoutItemMap;
25 
32 class CORE_EXPORT QgsLayoutItemMapItem : public QgsLayoutObject
33 {
34  Q_OBJECT
35 
36  public:
37 
43  QgsLayoutItemMapItem( const QString &name, QgsLayoutItemMap *map );
44 
48  virtual void draw( QPainter *painter ) = 0;
49 
55  virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
56 
62  virtual bool readXml( const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context );
63 
72  virtual void finalizeRestoreFromXml();
73 
78  void setMap( QgsLayoutItemMap *map );
79 
84  const QgsLayoutItemMap *map() const;
85 
89  QString id() const { return mUuid; }
90 
95  void setName( const QString &name );
96 
101  QString name() const;
102 
107  void setEnabled( bool enabled );
108 
113  bool enabled() const;
114 
118  virtual bool usesAdvancedEffects() const;
119 
120  protected:
121 
123  QString mName;
124 
126  QgsLayoutItemMap *mMap = nullptr;
127 
129  QString mUuid;
130 
132  bool mEnabled;
133 
134 };
135 
136 
137 
147 class CORE_EXPORT QgsLayoutItemMapItemStack
148 {
149  public:
150 
156 
157  virtual ~QgsLayoutItemMapItemStack();
158 
162  int size() const { return mItems.size(); }
163 
169  virtual bool writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) const;
170 
176  virtual bool readXml( const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context ) = 0;
177 
186  virtual void finalizeRestoreFromXml();
187 
191  void drawItems( QPainter *painter );
192 
197  bool containsAdvancedEffects() const;
198 
199  protected:
200 
209  void addItem( QgsLayoutItemMapItem *item SIP_TRANSFER );
210 
217  void removeItem( const QString &itemId );
218 
225  void moveItemUp( const QString &itemId );
226 
233  void moveItemDown( const QString &itemId );
234 
238  QgsLayoutItemMapItem *item( const QString &itemId ) const;
239 
243  QgsLayoutItemMapItem *item( int index ) const;
244 
250  QgsLayoutItemMapItem &operator[]( int index ) SIP_SKIP;
251 
255  QList< QgsLayoutItemMapItem * > asList() const;
256 
257  protected:
258 
259  QList< QgsLayoutItemMapItem * > mItems;
260 
261  QgsLayoutItemMap *mMap = nullptr;
262 
267  void removeItems();
268 };
269 
270 #endif //QGSLAYOUTITEMMAPITEM_H
271 
The class is used as a container of context for various read/write operations on other objects...
QString mName
Friendly display name.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
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.
#define SIP_SKIP
Definition: qgis_sip.h:119
#define SIP_TRANSFER
Definition: qgis_sip.h:36
int size() const
Returns the number of items in the stack.
A base class for objects which belong to a layout.
QList< QgsLayoutItemMapItem * > mItems
QString mUuid
Unique id.