QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
23#include <QDateTime>
24#include <QSet>
25#include <QVariantList>
26
27/***************************************************************************
28 * This class is considered CRITICAL and any change MUST be accompanied with
29 * full unit tests in test_qgsdatetimestatisticalsummary.py.
30 * See details in QEP #17
31 ****************************************************************************/
32
44
46{
47 public:
48
54
60 Qgis::DateTimeStatistics statistics() const { return mStatistics; }
61
68 void setStatistics( Qgis::DateTimeStatistics stats ) { mStatistics = stats; }
69
73 void reset();
74
81 void calculate( const QVariantList &values );
82
96 void addValue( const QVariant &value );
97
103 void finalize();
104
110 QVariant statistic( Qgis::DateTimeStatistic stat ) const;
111
115 int count() const { return mCount; }
116
120 int countDistinct() const { return mValues.count(); }
121
125 QSet< QDateTime > distinctValues() const { return mValues; }
126
130 int countMissing() const { return mCountMissing; }
131
135 QDateTime min() const { return mMin; }
136
140 QDateTime max() const { return mMax; }
141
145 QgsInterval range() const;
146
151 static QString displayName( Qgis::DateTimeStatistic statistic );
152
153 private:
154
155 Qgis::DateTimeStatistics mStatistics;
156
157 int mCount;
158 QSet< QDateTime > mValues;
159 int mCountMissing;
160 QDateTime mMin;
161 QDateTime mMax;
162 bool mIsTimes;
163
164 void testDateTime( const QDateTime &dateTime, bool isNull );
165};
166
167#endif // QGSDATETIMESTATISTICALSUMMARY_H
QFlags< DateTimeStatistic > DateTimeStatistics
Statistics to be calculated for date/time values.
Definition qgis.h:5901
DateTimeStatistic
Available date/time statistics.
Definition qgis.h:5885
@ All
All statistics.
Definition qgis.h:5892
QgsDateTimeStatisticalSummary(Qgis::DateTimeStatistics stats=Qgis::DateTimeStatistic::All)
Constructor for QgsDateTimeStatisticalSummary.
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:47