QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
|
A numeric formatter which returns a simple text representation of a value. More...
#include <qgsbasicnumericformat.h>
Public Types | |
enum | RoundingType { DecimalPlaces , SignificantFigures } |
Sets rounding type and behavior of the numberDecimalPlaces() setting. More... | |
Public Member Functions | |
QgsBasicNumericFormat () | |
Default constructor. | |
QgsNumericFormat * | clone () const override |
Clones the format, returning a new object. | |
QVariantMap | configuration (const QgsReadWriteContext &context) const override |
Returns the current configuration of the formatter. | |
QgsNumericFormat * | create (const QVariantMap &configuration, const QgsReadWriteContext &context) const override |
Creates a new copy of the format, using the supplied configuration. | |
QChar | decimalSeparator () const |
Returns any override for the decimal separator character. | |
QString | formatDouble (double value, const QgsNumericFormatContext &context) const override |
Returns a formatted string representation of a numeric double value. | |
QString | id () const override |
Returns a unique id for this numeric format. | |
int | numberDecimalPlaces () const |
Returns the maximum number of decimal places to show. | |
RoundingType | roundingType () const |
Returns the rounding type, which controls the behavior of the numberDecimalPlaces() setting. | |
void | setDecimalSeparator (QChar character) |
Sets an override character for the decimal separator character. | |
virtual void | setNumberDecimalPlaces (int places) |
Sets the maximum number of decimal places to show. | |
void | setRoundingType (RoundingType type) |
Sets the rounding type, which controls the behavior of the numberDecimalPlaces() setting. | |
void | setShowPlusSign (bool show) |
Sets whether a leading plus sign will be shown for positive values. | |
void | setShowThousandsSeparator (bool show) |
Sets whether the thousands grouping separator will be shown. | |
void | setShowTrailingZeros (bool show) |
Sets whether trailing zeros will be shown (up to the specified numberDecimalPlaces()). | |
void | setThousandsSeparator (QChar character) |
Sets an override character for the thousands separator character. | |
bool | showPlusSign () const |
Returns true if a leading plus sign will be shown for positive values. | |
bool | showThousandsSeparator () const |
Returns true if the thousands grouping separator will be shown. | |
bool | showTrailingZeros () const |
Returns true if trailing zeros will be shown (up to the specified numberDecimalPlaces()). | |
int | sortKey () override |
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists. | |
QChar | thousandsSeparator () const |
Returns any override for the thousands separator character. | |
QString | visibleName () const override |
Returns the translated, user-visible name for this format. | |
Public Member Functions inherited from QgsNumericFormat | |
QgsNumericFormat ()=default | |
Default constructor. | |
virtual | ~QgsNumericFormat ()=default |
bool | operator!= (const QgsNumericFormat &other) const |
bool | operator== (const QgsNumericFormat &other) const |
virtual double | suggestSampleValue () const |
Returns a suggested sample value which nicely represents the current format configuration. | |
void | writeXml (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const |
Writes the format to an XML element. | |
Protected Member Functions | |
virtual void | setConfiguration (const QVariantMap &configuration, const QgsReadWriteContext &context) |
Sets the format's configuration. | |
Protected Attributes | |
bool | mUseScientific = false |
Additional Inherited Members | |
Static Protected Attributes inherited from QgsNumericFormat | |
static constexpr int | DEFAULT_SORT_KEY = 100 |
A numeric formatter which returns a simple text representation of a value.
Definition at line 31 of file qgsbasicnumericformat.h.
Sets rounding type and behavior of the numberDecimalPlaces() setting.
Enumerator | |
---|---|
DecimalPlaces | Maximum number of decimal places. |
SignificantFigures | Maximum number of significant figures. |
Definition at line 38 of file qgsbasicnumericformat.h.
QgsBasicNumericFormat::QgsBasicNumericFormat | ( | ) |
Default constructor.
Definition at line 40 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Clones the format, returning a new object.
The caller takes ownership of the returned object.
Implements QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 138 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Returns the current configuration of the formatter.
This value can be used in a call to create() in order to recreate this formatter in its current state.
Implements QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 150 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Creates a new copy of the format, using the supplied configuration.
The caller takes ownership of the returned object.
Implements QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 143 of file qgsbasicnumericformat.cpp.
QChar QgsBasicNumericFormat::decimalSeparator | ( | ) | const |
Returns any override for the decimal separator character.
If an invalid QChar is returned, then the QGIS locale separator is used instead.
Definition at line 234 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Returns a formatted string representation of a numeric double value.
Implements QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 59 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Returns a unique id for this numeric format.
This id is used to identify this numeric format in the registry with QgsNumericFormatRegistry::format().
Implements QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 44 of file qgsbasicnumericformat.cpp.
int QgsBasicNumericFormat::numberDecimalPlaces | ( | ) | const |
Returns the maximum number of decimal places to show.
Definition at line 174 of file qgsbasicnumericformat.cpp.
QgsBasicNumericFormat::RoundingType QgsBasicNumericFormat::roundingType | ( | ) | const |
Returns the rounding type, which controls the behavior of the numberDecimalPlaces() setting.
Definition at line 214 of file qgsbasicnumericformat.cpp.
|
protectedvirtual |
Sets the format's configuration.
Reimplemented in QgsBearingNumericFormat, and QgsGeographicCoordinateNumericFormat.
Definition at line 163 of file qgsbasicnumericformat.cpp.
void QgsBasicNumericFormat::setDecimalSeparator | ( | QChar | character | ) |
Sets an override character for the decimal separator character.
If an invalid QChar is set, then the QGIS locale separator is used instead.
Definition at line 239 of file qgsbasicnumericformat.cpp.
|
virtual |
Sets the maximum number of decimal places to show.
Reimplemented in QgsScientificNumericFormat.
Definition at line 179 of file qgsbasicnumericformat.cpp.
void QgsBasicNumericFormat::setRoundingType | ( | QgsBasicNumericFormat::RoundingType | type | ) |
Sets the rounding type, which controls the behavior of the numberDecimalPlaces() setting.
Definition at line 219 of file qgsbasicnumericformat.cpp.
void QgsBasicNumericFormat::setShowPlusSign | ( | bool | show | ) |
Sets whether a leading plus sign will be shown for positive values.
Definition at line 199 of file qgsbasicnumericformat.cpp.
void QgsBasicNumericFormat::setShowThousandsSeparator | ( | bool | show | ) |
Sets whether the thousands grouping separator will be shown.
Definition at line 189 of file qgsbasicnumericformat.cpp.
void QgsBasicNumericFormat::setShowTrailingZeros | ( | bool | show | ) |
Sets whether trailing zeros will be shown (up to the specified numberDecimalPlaces()).
Definition at line 209 of file qgsbasicnumericformat.cpp.
void QgsBasicNumericFormat::setThousandsSeparator | ( | QChar | character | ) |
Sets an override character for the thousands separator character.
If an invalid QChar is set, then the QGIS locale separator is used instead.
Definition at line 229 of file qgsbasicnumericformat.cpp.
bool QgsBasicNumericFormat::showPlusSign | ( | ) | const |
Returns true
if a leading plus sign will be shown for positive values.
Definition at line 194 of file qgsbasicnumericformat.cpp.
bool QgsBasicNumericFormat::showThousandsSeparator | ( | ) | const |
Returns true
if the thousands grouping separator will be shown.
Definition at line 184 of file qgsbasicnumericformat.cpp.
bool QgsBasicNumericFormat::showTrailingZeros | ( | ) | const |
Returns true
if trailing zeros will be shown (up to the specified numberDecimalPlaces()).
Definition at line 204 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
Generally, subclasses should return QgsNumericFormat::sortKey() as their sorting key.
Reimplemented from QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 54 of file qgsbasicnumericformat.cpp.
QChar QgsBasicNumericFormat::thousandsSeparator | ( | ) | const |
Returns any override for the thousands separator character.
If an invalid QChar is returned, then the QGIS locale separator is used instead.
Definition at line 224 of file qgsbasicnumericformat.cpp.
|
overridevirtual |
Returns the translated, user-visible name for this format.
Implements QgsNumericFormat.
Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.
Definition at line 49 of file qgsbasicnumericformat.cpp.
|
protected |
Definition at line 168 of file qgsbasicnumericformat.h.