QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
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
82 QgsAbstractReportSection( const QgsAbstractReportSection &other ) = delete;
83
85 QgsAbstractReportSection &operator=( const QgsAbstractReportSection &other ) = delete;
86
90 virtual QString type() const = 0;
91
95 virtual QString description() const = 0;
96
100 virtual QIcon icon() const = 0;
101
109 virtual QgsAbstractReportSection *clone() const = 0 SIP_FACTORY;
110
114 QgsAbstractReportSection *parentSection() { return mParent; }
115
119 QgsProject *project();
120
121 // TODO - how to handle this?
122 int count() const override { return -1; }
123
124 QString filePath( const QString &baseFilePath, const QString &extension ) override;
125 QgsLayout *layout() override;
126 bool beginRender() override;
127 bool next() override;
128 bool endRender() override;
129
133 virtual void reset();
134
141 virtual bool prepareHeader();
142
149 virtual bool prepareFooter();
150
157 virtual QgsLayout *nextBody( bool &ok SIP_OUT ) { ok = false; return nullptr; }
158
165 bool headerEnabled() const { return mHeaderEnabled; }
166
173 void setHeaderEnabled( bool enabled ) { mHeaderEnabled = enabled; }
174
182 QgsLayout *header() { return mHeader.get(); }
183
192 void setHeader( QgsLayout *header SIP_TRANSFER );
193
200 bool footerEnabled() const { return mFooterEnabled; }
201
208 void setFooterEnabled( bool enabled ) { mFooterEnabled = enabled; }
209
217 QgsLayout *footer() { return mFooter.get(); }
218
227 void setFooter( QgsLayout *footer SIP_TRANSFER );
228
234 int childCount() const { return mChildren.count(); }
235
239 int row() const;
240
250 QList< QgsAbstractReportSection * > childSections() const { return mChildren; }
251
256 QgsAbstractReportSection *childSection( int index );
257
263 void appendChild( QgsAbstractReportSection *section SIP_TRANSFER );
264
270 void insertChild( int index, QgsAbstractReportSection *section SIP_TRANSFER );
271
276 void removeChild( QgsAbstractReportSection *section );
277
282 void removeChildAt( int index );
283
288 void setContext( const QgsReportSectionContext &context );
289
294 const QgsReportSectionContext &context() const { return mContext; }
295
300 bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
301
306 bool readXml( const QDomElement &sectionElement, const QDomDocument &document, const QgsReadWriteContext &context );
307
311 virtual void reloadSettings();
312
322 bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
323
324 protected:
325
327 enum SubSection
328 {
329 Header,
330 Body,
331 Children,
332 Footer,
333 End,
334 };
335
340 void copyCommonProperties( QgsAbstractReportSection *destination ) const;
341
345 virtual void setParentSection( QgsAbstractReportSection *parent ) { mParent = parent; }
346
352 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
353
359 virtual bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context );
360
361 private:
362
363 QgsAbstractReportSection *mParent = nullptr;
364
365 int mSectionNumber = 0;
366 SubSection mNextSection = Header;
367 int mNextChild = 0;
368 QgsLayout *mCurrentLayout = nullptr;
369
370 bool mHeaderEnabled = false;
371 bool mFooterEnabled = false;
372 std::unique_ptr< QgsLayout > mHeader;
373 std::unique_ptr< QgsLayout > mFooter;
374
375 QList< QgsAbstractReportSection * > mChildren;
376
377 QgsReportSectionContext mContext;
378
379#ifdef SIP_RUN
380 QgsAbstractReportSection( const QgsAbstractReportSection &other );
381#endif
382};
383
385
386#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:56
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