QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
numericformats
qgsbasicnumericformat.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsbasicnumericformat.h
3
--------------------------
4
begin : January 2020
5
copyright : (C) 2020 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
#ifndef QGSBASICNUMERICFORMAT_H
16
#define QGSBASICNUMERICFORMAT_H
17
18
#include <iostream>
19
#include <memory>
20
#include <sstream>
21
22
#include "qgis_core.h"
23
#include "
qgis_sip.h
"
24
#include "
qgsnumericformat.h
"
25
32
class
CORE_EXPORT
QgsBasicNumericFormat
:
public
QgsNumericFormat
33
{
34
public
:
38
enum
RoundingType
39
{
40
DecimalPlaces
,
41
SignificantFigures
,
42
};
43
47
QgsBasicNumericFormat
();
48
49
QString
id
()
const override
;
50
QString
visibleName
()
const override
;
51
int
sortKey
()
override
;
52
QString
formatDouble
(
double
value,
const
QgsNumericFormatContext
&context )
const override
;
53
QgsNumericFormat
*
clone
() const override
SIP_FACTORY
;
54
QgsNumericFormat
*create( const QVariantMap &configuration, const
QgsReadWriteContext
&context ) const override
SIP_FACTORY
;
55
QVariantMap configuration( const
QgsReadWriteContext
&context ) const override;
56
63
int
numberDecimalPlaces() const;
64
71
virtual
void
setNumberDecimalPlaces(
int
places );
72
77
bool
showThousandsSeparator() const;
78
83
void
setShowThousandsSeparator(
bool
show );
84
89
bool
showPlusSign() const;
90
95
void
setShowPlusSign(
bool
show );
96
104
bool
showTrailingZeros() const;
105
113
void
setShowTrailingZeros(
bool
show );
114
120
RoundingType roundingType() const;
121
127
void
setRoundingType( RoundingType type );
128
135
QChar thousandsSeparator() const;
136
143
void
setThousandsSeparator( QChar character );
144
151
QChar decimalSeparator() const;
152
159
void
setDecimalSeparator( QChar character );
160
161
protected:
165
virtual
void
setConfiguration( const QVariantMap &configuration, const
QgsReadWriteContext
&context );
166
167
bool
mUseScientific
= false;
168
169
private:
170
int
mNumberDecimalPlaces = 6;
171
bool
mShowThousandsSeparator = true;
172
bool
mShowPlusSign = false;
173
bool
mShowTrailingZeros = false;
174
175
RoundingType
mRoundingType =
DecimalPlaces
;
176
177
QChar mThousandsSeparator;
178
QChar mDecimalSeparator;
179
};
180
181
#endif
// QGSBASICNUMERICFORMAT_H
QgsBasicNumericFormat
A numeric formatter which returns a simple text representation of a value.
Definition
qgsbasicnumericformat.h:33
QgsBasicNumericFormat::RoundingType
RoundingType
Sets rounding type and behavior of the numberDecimalPlaces() setting.
Definition
qgsbasicnumericformat.h:39
QgsBasicNumericFormat::DecimalPlaces
@ DecimalPlaces
Maximum number of decimal places.
Definition
qgsbasicnumericformat.h:40
QgsBasicNumericFormat::SignificantFigures
@ SignificantFigures
Maximum number of significant figures.
Definition
qgsbasicnumericformat.h:41
QgsBasicNumericFormat::QgsBasicNumericFormat
QgsBasicNumericFormat()
Default constructor.
Definition
qgsbasicnumericformat.cpp:49
QgsBasicNumericFormat::mUseScientific
bool mUseScientific
Definition
qgsbasicnumericformat.h:167
QgsNumericFormatContext
A context for numeric formats.
Definition
qgsnumericformat.h:35
QgsNumericFormat
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
Definition
qgsnumericformat.h:232
QgsNumericFormat::formatDouble
virtual QString formatDouble(double value, const QgsNumericFormatContext &context) const =0
Returns a formatted string representation of a numeric double value.
QgsNumericFormat::clone
virtual QgsNumericFormat * clone() const =0
Clones the format, returning a new object.
QgsNumericFormat::sortKey
virtual int sortKey()
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
Definition
qgsnumericformat.cpp:54
QgsNumericFormat::QgsNumericFormat
QgsNumericFormat()=default
QgsNumericFormat::visibleName
virtual QString visibleName() const =0
Returns the translated, user-visible name for this format.
QgsNumericFormat::id
virtual QString id() const =0
Returns a unique id for this numeric format.
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
qgis_sip.h
SIP_FACTORY
#define SIP_FACTORY
Definition
qgis_sip.h:83
qgsnumericformat.h
Generated on
for QGIS API Documentation by
1.17.0