QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
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 Qgis::DateTimeStatistics mStatistics;
154
155 int mCount;
156 QSet< QDateTime > mValues;
157 int mCountMissing;
158 QDateTime mMin;
159 QDateTime mMax;
160 bool mIsTimes;
161
162 void testDateTime( const QDateTime &dateTime, bool isNull );
163};
164
165#endif // QGSDATETIMESTATISTICALSUMMARY_H
QFlags< DateTimeStatistic > DateTimeStatistics
Statistics to be calculated for date/time values.
Definition qgis.h:6259
DateTimeStatistic
Available date/time statistics.
Definition qgis.h:6243
@ All
All statistics.
Definition qgis.h:6250
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:52