QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
32class CORE_EXPORT QgsBasicNumericFormat : public QgsNumericFormat
33{
34 public:
35
44
49
50 QString id() const override;
51 QString visibleName() const override;
52 int sortKey() override;
53 QString formatDouble( double value, const QgsNumericFormatContext &context ) const override;
54 QgsNumericFormat *clone() const override SIP_FACTORY;
55 QgsNumericFormat *create( const QVariantMap &configuration, const QgsReadWriteContext &context ) const override SIP_FACTORY;
56 QVariantMap configuration( const QgsReadWriteContext &context ) const override;
57
64 int numberDecimalPlaces() const;
65
72 virtual void setNumberDecimalPlaces( int places );
73
78 bool showThousandsSeparator() const;
79
84 void setShowThousandsSeparator( bool show );
85
90 bool showPlusSign() const;
91
96 void setShowPlusSign( bool show );
97
105 bool showTrailingZeros() const;
106
114 void setShowTrailingZeros( bool show );
115
121 RoundingType roundingType() const;
122
128 void setRoundingType( RoundingType type );
129
136 QChar thousandsSeparator() const;
137
144 void setThousandsSeparator( QChar character );
145
152 QChar decimalSeparator() const;
153
160 void setDecimalSeparator( QChar character );
161
162 protected:
163
167 virtual void setConfiguration( const QVariantMap &configuration, const QgsReadWriteContext &context );
168
169 bool mUseScientific = false;
170
171 private:
172
173 int mNumberDecimalPlaces = 6;
174 bool mShowThousandsSeparator = true;
175 bool mShowPlusSign = false;
176 bool mShowTrailingZeros = false;
177
178 RoundingType mRoundingType = DecimalPlaces;
179
180 QChar mThousandsSeparator;
181 QChar mDecimalSeparator;
182};
183
184#endif // QGSBASICNUMERICFORMAT_H
A numeric formatter which returns a simple text representation of a value.
RoundingType
Sets rounding type and behavior of the numberDecimalPlaces() setting.
@ DecimalPlaces
Maximum number of decimal places.
@ SignificantFigures
Maximum number of significant figures.
QgsBasicNumericFormat()
Default constructor.
A context for numeric formats.
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
virtual QString formatDouble(double value, const QgsNumericFormatContext &context) const =0
Returns a formatted string representation of a numeric double value.
virtual QgsNumericFormat * clone() const =0
Clones the format, returning a new object.
virtual int sortKey()
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
QgsNumericFormat()=default
virtual QString visibleName() const =0
Returns the translated, user-visible name for this format.
virtual QString id() const =0
Returns a unique id for this numeric format.
A container for the context for various read/write operations on objects.
#define SIP_FACTORY
Definition qgis_sip.h:84