QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
24
25// This is not considered stable API - it is exposed to python bindings only for unit testing!
26
36class CORE_EXPORT QgsReportSectionFieldGroup : public QgsAbstractReportSection
37{
38 public:
39
43 enum SectionVisibility
44 {
45 IncludeWhenFeaturesFound,
46 AlwaysInclude
47 };
48
53 QgsReportSectionFieldGroup( QgsAbstractReportSection *parentSection = nullptr );
54
55 QString type() const override { return QStringLiteral( "SectionFieldGroup" ); }
56 QString description() const override;
57 QIcon icon() const override;
58
65 QgsLayout *body() { return mBody.get(); }
66
74 void setBody( QgsLayout *body SIP_TRANSFER ) { mBody.reset( body ); }
75
82 bool bodyEnabled() const { return mBodyEnabled; }
83
90 void setBodyEnabled( bool enabled ) { mBodyEnabled = enabled; }
91
92
97 QgsVectorLayer *layer() { return mCoverageLayer.get(); }
98
103 void setLayer( QgsVectorLayer *layer ) { mCoverageLayer = layer; }
104
109 QString field() const { return mField; }
110
115 void setField( const QString &field ) { mField = field; }
116
122 bool sortAscending() const;
123
129 void setSortAscending( bool sortAscending );
130
135 SectionVisibility headerVisibility() const { return mHeaderVisibility; }
136
141 void setHeaderVisibility( SectionVisibility visibility ) { mHeaderVisibility = visibility; }
142
147 SectionVisibility footerVisibility() const { return mFooterVisibility; }
148
153 void setFooterVisibility( SectionVisibility visibility ) { mFooterVisibility = visibility; }
154
155 QgsReportSectionFieldGroup *clone() const override SIP_FACTORY;
156 bool beginRender() override;
157 bool prepareHeader() override;
158 bool prepareFooter() override;
159 QgsLayout *nextBody( bool &ok ) override;
160 void reset() override;
161 void setParentSection( QgsAbstractReportSection *parentSection ) override;
162 void reloadSettings() override;
163
164 protected:
165
166 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
167 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
168
169 private:
170
171 QgsVectorLayerRef mCoverageLayer;
172 QString mField;
173 bool mSortAscending = true;
174 int mFieldIndex = -1;
175 QgsFeatureIterator mFeatures;
176 bool mSkipNextRequest = false;
177 bool mNoFeatures = false;
178 SectionVisibility mHeaderVisibility = IncludeWhenFeaturesFound;
179 SectionVisibility mFooterVisibility = IncludeWhenFeaturesFound;
180 QgsFeature mHeaderFeature;
181 QgsFeature mLastFeature;
182 QSet< QVariant > mEncounteredValues;
183
184 bool mBodyEnabled = false;
185 std::unique_ptr< QgsLayout > mBody;
186
187 QgsFeatureRequest buildFeatureRequest() const;
188
189 QgsFeature getNextFeature();
190 void updateChildContexts( const QgsFeature &feature );
191
192};
193
194
196
197#endif //QGSREPORTSECTIONFIELDGROUP_H
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84
_LayerRef< QgsVectorLayer > QgsVectorLayerRef