QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
46 enum SectionVisibility
47 {
48 IncludeWhenFeaturesFound,
49 AlwaysInclude
50 };
51
56 QgsReportSectionFieldGroup( QgsAbstractReportSection *parentSection = nullptr );
57
58 QString type() const override { return u"SectionFieldGroup"_s; }
59 QString description() const override;
60 QIcon icon() const override;
61
68 QgsLayout *body() { return mBody.get(); }
69
77 void setBody( QgsLayout *body SIP_TRANSFER ) { mBody.reset( body ); }
78
85 bool bodyEnabled() const { return mBodyEnabled; }
86
93 void setBodyEnabled( bool enabled ) { mBodyEnabled = enabled; }
94
95
100 QgsVectorLayer *layer() { return mCoverageLayer.get(); }
101
106 void setLayer( QgsVectorLayer *layer ) { mCoverageLayer = layer; }
107
112 QString field() const { return mField; }
113
118 void setField( const QString &field ) { mField = field; }
119
125 bool sortAscending() const;
126
132 void setSortAscending( bool sortAscending );
133
138 SectionVisibility headerVisibility() const { return mHeaderVisibility; }
139
144 void setHeaderVisibility( SectionVisibility visibility ) { mHeaderVisibility = visibility; }
145
150 SectionVisibility footerVisibility() const { return mFooterVisibility; }
151
156 void setFooterVisibility( SectionVisibility visibility ) { mFooterVisibility = visibility; }
157
158 QgsReportSectionFieldGroup *clone() const override SIP_FACTORY;
159 bool beginRender() override;
160 bool prepareHeader() override;
161 bool prepareFooter() override;
162 QgsLayout *nextBody( bool &ok ) override;
163 void reset() override;
164 void setParentSection( QgsAbstractReportSection *parentSection ) override;
165 void reloadSettings() override;
166
167 protected:
168 bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
169 bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
170
171 private:
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
196
197#endif //QGSREPORTSECTIONFIELDGROUP_H
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
_LayerRef< QgsVectorLayer > QgsVectorLayerRef