/
qgspercentagenumericformat.h
73 lines (62 loc) · 2.57 KB
/
qgspercentagenumericformat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/***************************************************************************
qgspercentagenumericformat.h
----------------------------
begin : January 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPERCENTAGENUMERICFORMAT_H
#define QGSPERCENTAGENUMERICFORMAT_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsbasicnumericformat.h"
/**
* \ingroup core
* A numeric formatter which returns a text representation of a percentage value.
*
* \since QGIS 3.12
*/
class CORE_EXPORT QgsPercentageNumericFormat : public QgsBasicNumericFormat
{
public:
//! Input value format, which specifies the format of the incoming values
enum InputValues
{
ValuesArePercentage, //!< Incoming values are percentage values (e.g. 50 for 50%)
ValuesAreFractions, //!< Incoming values are numeric fractions (e.g. 0.5 for 50%)
};
/**
* Default constructor
*/
QgsPercentageNumericFormat();
QString id() const override;
QString visibleName() const override;
int sortKey() override;
double suggestSampleValue() const override;
QString formatDouble( double value, const QgsNumericFormatContext &context ) const override;
QgsNumericFormat *clone() const override SIP_FACTORY;
QgsNumericFormat *create( const QVariantMap &configuration, const QgsReadWriteContext &context ) const override SIP_FACTORY;
QVariantMap configuration( const QgsReadWriteContext &context ) const override;
/**
* Returns the format of the incoming values.
*
* \see setInputValues()
*/
InputValues inputValues() const;
/**
* Sets the \a format of the incoming values.
*
* \see inputValues()
*/
void setInputValues( const InputValues &format );
private:
InputValues mInputValues = ValuesArePercentage;
};
#endif // QGSPERCENTAGENUMERICFORMAT_H