QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsdatetimestatisticalsummary.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatetimestatisticalsummary.h
3 -------------------------------
4 Date : May 2016
5 Copyright : (C) 2016 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSDATETIMESTATISTICALSUMMARY_H
17#define QGSDATETIMESTATISTICALSUMMARY_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsinterval.h"
22#include <QSet>
23#include <QDateTime>
24#include <QVariantList>
25
26/***************************************************************************
27 * This class is considered CRITICAL and any change MUST be accompanied with
28 * full unit tests in test_qgsdatetimestatisticalsummary.py.
29 * See details in QEP #17
30 ****************************************************************************/
31
45{
46 public:
47
53
59 Qgis::DateTimeStatistics statistics() const { return mStatistics; }
60
67 void setStatistics( Qgis::DateTimeStatistics stats ) { mStatistics = stats; }
68
72 void reset();
73
80 void calculate( const QVariantList &values );
81
95 void addValue( const QVariant &value );
96
102 void finalize();
103
109 QVariant statistic( Qgis::DateTimeStatistic stat ) const;
110
114 int count() const { return mCount; }
115
119 int countDistinct() const { return mValues.count(); }
120
124 QSet< QDateTime > distinctValues() const { return mValues; }
125
129 int countMissing() const { return mCountMissing; }
130
134 QDateTime min() const { return mMin; }
135
139 QDateTime max() const { return mMax; }
140
144 QgsInterval range() const;
145
150 static QString displayName( Qgis::DateTimeStatistic statistic );
151
152 private:
153
154 Qgis::DateTimeStatistics mStatistics;
155
156 int mCount;
157 QSet< QDateTime > mValues;
158 int mCountMissing;
159 QDateTime mMin;
160 QDateTime mMax;
161 bool mIsTimes;
162
163 void testDateTime( const QDateTime &dateTime, bool isNull );
164};
165
166#endif // QGSDATETIMESTATISTICALSUMMARY_H
QFlags< DateTimeStatistic > DateTimeStatistics
Statistics to be calculated for date/time values.
Definition: qgis.h:4800
DateTimeStatistic
Available date/time statistics.
Definition: qgis.h:4784
@ All
All statistics.
Calculator for summary statistics and aggregates for a list of datetimes.
QDateTime min() const
Returns the minimum (earliest) non-null datetime value.
Qgis::DateTimeStatistics statistics() const
Returns flags which specify which statistics will be calculated.
int count() const
Returns the calculated count of values.
int countMissing() const
Returns the number of missing (null) datetime values.
int countDistinct() const
Returns the number of distinct datetime values.
void setStatistics(Qgis::DateTimeStatistics stats)
Sets flags which specify which statistics will be calculated.
QSet< QDateTime > distinctValues() const
Returns the set of distinct datetime values.
QDateTime max() const
Returns the maximum (latest) non-null datetime value.
A representation of the interval between two datetime values.
Definition: qgsinterval.h:46