QGIS API Documentation  3.0.2-Girona (307d082)
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 
22 
24 
25 // This is not considered stable API - it is exposed to python bindings only for unit testing!
26 
37 class 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
The class is used as a container of context for various read/write operations on other objects...
Wrapper for iterator of features from vector data provider or vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:74
#define SIP_TRANSFER
Definition: qgis_sip.h:36
This class wraps a request for features to a vector layer (or directly its vector data provider)...
#define SIP_FACTORY
Definition: qgis_sip.h:69
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
Represents a vector layer which manages a vector based data sets.