18 #include <QStringList> 21 #include <QVariantList> 31 : mStatistics( stats )
51 Q_FOREACH (
const QString&
string, values )
65 if ( value.
type() == QVariant::String )
82 Q_FOREACH (
const QVariant& variant, values )
84 if ( variant.
type() == QVariant::String )
91 void QgsStringStatisticalSummary::testString(
const QString&
string )
95 if (
string.isEmpty() )
102 if ( mStatistics &
Min )
104 if ( !mMin.
isEmpty() && !
string.isEmpty() )
106 mMin = qMin( mMin,
string );
108 else if ( mMin.
isEmpty() && !
string.isEmpty() )
113 if ( mStatistics &
Max )
115 if ( !mMax.
isEmpty() && !
string.isEmpty() )
117 mMax = qMax( mMax,
string );
119 else if ( mMax.
isEmpty() && !
string.isEmpty() )
124 mMinLength = qMin( mMinLength,
string.length() );
125 mMaxLength = qMax( mMaxLength,
string.length() );
135 return mValues.
count();
137 return mCountMissing;
QVariant statistic(Statistic stat) const
Returns the value of a specified statistic.
Statistic
Enumeration of flags that specify statistics to be calculated.
Number of distinct string values.
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsStringStatisticalSummary(const QgsStringStatisticalSummary::Statistics &stats=All)
Constructor for QgsStringStatistics.
Number of missing (null) values.
static QString displayName(Statistic statistic)
Returns the friendly display name for a statistic.
void addValue(const QVariant &value)
Adds a single variant to the statistics calculation.
Maximum length of string.
void addString(const QString &string)
Adds a single string to the statistics calculation.
void calculateFromVariants(const QVariantList &values)
Calculates summary statistics for an entire list of variants at once.
Minimum length of string.
void finalize()
Must be called after adding all strings with addString() and before retrieving any calculated string ...
void calculate(const QStringList &values)
Calculates summary statistics for an entire list of strings at once.
void reset()
Resets the calculated values.