QGIS API Documentation 3.99.0-Master (09f76ad7019)
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#include <QString>
24
25using namespace Qt::StringLiterals;
26
28
29// This is not considered stable API - it is exposed to python bindings only for unit testing!
30
40class CORE_EXPORT QgsReportSectionFieldGroup : public QgsAbstractReportSection
41{
42 public:
43
47 enum SectionVisibility
48 {
49 IncludeWhenFeaturesFound,
50 AlwaysInclude
51 };
52
57 QgsReportSectionFieldGroup( QgsAbstractReportSection *parentSection = nullptr );
58
59 QString type() const override { return u"SectionFieldGroup"_s; }
60 QString description() const override;
61 QIcon icon() const override;
62
69 QgsLayout *body() { return mBody.get(); }
70
78 void setBody( QgsLayout *body SIP_TRANSFER ) { mBody.reset( body ); }
79
86 bool bodyEnabled() const { return mBodyEnabled; }
87
94 void setBodyEnabled( bool enabled ) { mBodyEnabled = enabled; }
95
96
101 QgsVectorLayer *layer() { return mCoverageLayer.get(); }
102
107 void setLayer( QgsVectorLayer *layer ) { mCoverageLayer = layer; }
108
113 QString field() const { return mField; }
114
119 void setField( const QString &field ) { mField = field; }
120
126 bool sortAscending() const;
127
133 void setSortAscending( bool sortAscending );
134
139 SectionVisibility headerVisibility() const { return mHeaderVisibility; }
140
145 void setHeaderVisibility( SectionVisibility visibility ) { mHeaderVisibility = visibility; }
146
151 SectionVisibility footerVisibility() const { return mFooterVisibility; }
152
157 void setFooterVisibility( SectionVisibility visibility ) { mFooterVisibility = visibility; }
158
159 QgsReportSectionFieldGroup *clone() const override SIP_FACTORY;
160 bool beginRender() override;
161 bool prepareHeader() override;
162 bool prepareFooter() override;
163 QgsLayout *nextBody( bool &ok ) override;
164 void reset() override;
165 void setParentSection( QgsAbstractReportSection *parentSection ) override;
166 void reloadSettings() override;
167
168 protected:
169
170 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
171 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
172
173 private:
174
175 QgsVectorLayerRef mCoverageLayer;
176 QString mField;
177 bool mSortAscending = true;
178 int mFieldIndex = -1;
179 QgsFeatureIterator mFeatures;
180 bool mSkipNextRequest = false;
181 bool mNoFeatures = false;
182 SectionVisibility mHeaderVisibility = IncludeWhenFeaturesFound;
183 SectionVisibility mFooterVisibility = IncludeWhenFeaturesFound;
184 QgsFeature mHeaderFeature;
185 QgsFeature mLastFeature;
186 QSet< QVariant > mEncounteredValues;
187
188 bool mBodyEnabled = false;
189 std::unique_ptr< QgsLayout > mBody;
190
191 QgsFeatureRequest buildFeatureRequest() const;
192
193 QgsFeature getNextFeature();
194 void updateChildContexts( const QgsFeature &feature );
195
196};
197
198
200
201#endif //QGSREPORTSECTIONFIELDGROUP_H
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84
_LayerRef< QgsVectorLayer > QgsVectorLayerRef