QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsreportsectionfieldgroup.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsreportsectionfieldgroup.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 QGSREPORTSECTIONFIELDGROUP_H
17#define QGSREPORTSECTIONFIELDGROUP_H
18
19#include "qgis_core.h"
21#include "qgsfeatureiterator.h"
22
23
25
26// This is not considered stable API - it is exposed to python bindings only for unit testing!
27
37class CORE_EXPORT QgsReportSectionFieldGroup : public QgsAbstractReportSection
38{
39 public:
40
44 enum SectionVisibility
45 {
46 IncludeWhenFeaturesFound,
47 AlwaysInclude
48 };
49
54 QgsReportSectionFieldGroup( QgsAbstractReportSection *parentSection = nullptr );
55
56 QString type() const override { return QStringLiteral( "SectionFieldGroup" ); }
57 QString description() const override;
58 QIcon icon() const override;
59
66 QgsLayout *body() { return mBody.get(); }
67
75 void setBody( QgsLayout *body SIP_TRANSFER ) { mBody.reset( body ); }
76
83 bool bodyEnabled() const { return mBodyEnabled; }
84
91 void setBodyEnabled( bool enabled ) { mBodyEnabled = enabled; }
92
93
98 QgsVectorLayer *layer() { return mCoverageLayer.get(); }
99
104 void setLayer( QgsVectorLayer *layer ) { mCoverageLayer = layer; }
105
110 QString field() const { return mField; }
111
116 void setField( const QString &field ) { mField = field; }
117
123 bool sortAscending() const;
124
130 void setSortAscending( bool sortAscending );
131
136 SectionVisibility headerVisibility() const { return mHeaderVisibility; }
137
142 void setHeaderVisibility( SectionVisibility visibility ) { mHeaderVisibility = visibility; }
143
148 SectionVisibility footerVisibility() const { return mFooterVisibility; }
149
154 void setFooterVisibility( SectionVisibility visibility ) { mFooterVisibility = visibility; }
155
156 QgsReportSectionFieldGroup *clone() const override SIP_FACTORY;
157 bool beginRender() override;
158 bool prepareHeader() override;
159 bool prepareFooter() override;
160 QgsLayout *nextBody( bool &ok ) override;
161 void reset() override;
162 void setParentSection( QgsAbstractReportSection *parentSection ) override;
163 void reloadSettings() override;
164
165 protected:
166
167 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
168 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
169
170 private:
171
172 QgsVectorLayerRef mCoverageLayer;
173 QString mField;
174 bool mSortAscending = true;
175 int mFieldIndex = -1;
176 QgsFeatureIterator mFeatures;
177 bool mSkipNextRequest = false;
178 bool mNoFeatures = false;
179 SectionVisibility mHeaderVisibility = IncludeWhenFeaturesFound;
180 SectionVisibility mFooterVisibility = IncludeWhenFeaturesFound;
181 QgsFeature mHeaderFeature;
182 QgsFeature mLastFeature;
183 QSet< QVariant > mEncounteredValues;
184
185 bool mBodyEnabled = false;
186 std::unique_ptr< QgsLayout > mBody;
187
188 QgsFeatureRequest buildFeatureRequest() const;
189
190 QgsFeature getNextFeature();
191 void updateChildContexts( const QgsFeature &feature );
192
193};
194
195
197
198#endif //QGSREPORTSECTIONFIELDGROUP_H
Wrapper for iterator of features from vector data provider or vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
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
The class is used as a container of context for various read/write operations on other objects.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76