QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsabstractreportsection.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractreportsection.h
3 ---------------------------
4 begin : December 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSABSTRACTREPORTSECTION_H
17#define QGSABSTRACTREPORTSECTION_H
18
19#include "qgis_core.h"
22#include "qgsvectorlayerref.h"
23
24
26
27// This is not considered stable API - it is exposed to python bindings only for unit testing!
28
36class CORE_EXPORT QgsReportSectionContext
37{
38 public:
39
41 QgsFeature feature;
42
44 QgsVectorLayer *currentLayer = nullptr;
45
47 QVariantMap fieldFilters;
48};
49
57class CORE_EXPORT QgsAbstractReportSection : public QgsAbstractLayoutIterator
58{
59
60#ifdef SIP_RUN
62 if ( dynamic_cast< QgsReportSectionFieldGroup * >( sipCpp ) )
63 sipType = sipType_QgsReportSectionFieldGroup;
64 else if ( dynamic_cast< QgsReportSectionLayout * >( sipCpp ) )
65 sipType = sipType_QgsReportSectionLayout;
66 else
67 sipType = NULL;
69#endif
70
71 public:
72
77 QgsAbstractReportSection( QgsAbstractReportSection *parentSection = nullptr );
78
79 ~QgsAbstractReportSection() override;
80 QgsAbstractReportSection( const QgsAbstractReportSection &other ) = delete;
81 QgsAbstractReportSection &operator=( const QgsAbstractReportSection &other ) = delete;
82
86 virtual QString type() const = 0;
87
91 virtual QString description() const = 0;
92
96 virtual QIcon icon() const = 0;
97
105 virtual QgsAbstractReportSection *clone() const = 0 SIP_FACTORY;
106
110 QgsAbstractReportSection *parentSection() { return mParent; }
111
115 QgsProject *project();
116
117 // TODO - how to handle this?
118 int count() const override { return -1; }
119
120 QString filePath( const QString &baseFilePath, const QString &extension ) override;
121 QgsLayout *layout() override;
122 bool beginRender() override;
123 bool next() override;
124 bool endRender() override;
125
129 virtual void reset();
130
137 virtual bool prepareHeader();
138
145 virtual bool prepareFooter();
146
153 virtual QgsLayout *nextBody( bool &ok SIP_OUT ) { ok = false; return nullptr; }
154
161 bool headerEnabled() const { return mHeaderEnabled; }
162
169 void setHeaderEnabled( bool enabled ) { mHeaderEnabled = enabled; }
170
178 QgsLayout *header() { return mHeader.get(); }
179
188 void setHeader( QgsLayout *header SIP_TRANSFER );
189
196 bool footerEnabled() const { return mFooterEnabled; }
197
204 void setFooterEnabled( bool enabled ) { mFooterEnabled = enabled; }
205
213 QgsLayout *footer() { return mFooter.get(); }
214
223 void setFooter( QgsLayout *footer SIP_TRANSFER );
224
230 int childCount() const { return mChildren.count(); }
231
235 int row() const;
236
246 QList< QgsAbstractReportSection * > childSections() const { return mChildren; }
247
252 QgsAbstractReportSection *childSection( int index );
253
259 void appendChild( QgsAbstractReportSection *section SIP_TRANSFER );
260
266 void insertChild( int index, QgsAbstractReportSection *section SIP_TRANSFER );
267
272 void removeChild( QgsAbstractReportSection *section );
273
278 void removeChildAt( int index );
279
284 void setContext( const QgsReportSectionContext &context );
285
290 const QgsReportSectionContext &context() const { return mContext; }
291
296 bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
297
302 bool readXml( const QDomElement &sectionElement, const QDomDocument &document, const QgsReadWriteContext &context );
303
307 virtual void reloadSettings();
308
318 bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
319
320 protected:
321
323 enum SubSection
324 {
325 Header,
326 Body,
327 Children,
328 Footer,
329 End,
330 };
331
336 void copyCommonProperties( QgsAbstractReportSection *destination ) const;
337
341 virtual void setParentSection( QgsAbstractReportSection *parent ) { mParent = parent; }
342
348 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
349
355 virtual bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context );
356
357 private:
358
359 QgsAbstractReportSection *mParent = nullptr;
360
361 int mSectionNumber = 0;
362 SubSection mNextSection = Header;
363 int mNextChild = 0;
364 QgsLayout *mCurrentLayout = nullptr;
365
366 bool mHeaderEnabled = false;
367 bool mFooterEnabled = false;
368 std::unique_ptr< QgsLayout > mHeader;
369 std::unique_ptr< QgsLayout > mFooter;
370
371 QList< QgsAbstractReportSection * > mChildren;
372
373 QgsReportSectionContext mContext;
374
375#ifdef SIP_RUN
376 QgsAbstractReportSection( const QgsAbstractReportSection &other );
377#endif
378};
379
381
382#endif //QGSABSTRACTREPORTSECTION_H
An abstract base class for QgsLayout based classes which can be exported by QgsLayoutExporter.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
The class is used as a container of context for various read/write operations on other objects.
An interface for classes which can visit style entity (e.g.
Represents a vector layer which manages a vector based data sets.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208