QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Member Functions | Static Protected Attributes | List of all members
QgsNumericFormat Class Referenceabstract

A numeric formatter allows for formatting a numeric value for display, using a variety of different formatting techniques (e.g. More...

#include <qgsnumericformat.h>

Inheritance diagram for QgsNumericFormat:
Inheritance graph
[legend]

Public Member Functions

 QgsNumericFormat ()=default
 Default constructor. More...
 
virtual ~QgsNumericFormat ()=default
 
virtual QgsNumericFormatclone () const =0
 Clones the format, returning a new object. More...
 
virtual QVariantMap configuration (const QgsReadWriteContext &context) const =0
 Returns the current configuration of the formatter. More...
 
virtual QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const =0
 Creates a new copy of the format, using the supplied configuration. More...
 
virtual QString formatDouble (double value, const QgsNumericFormatContext &context) const =0
 Returns a formatted string representation of a numeric double value. More...
 
virtual QString id () const =0
 Returns a unique id for this numeric format. More...
 
bool operator!= (const QgsNumericFormat &other) const
 
bool operator== (const QgsNumericFormat &other) const
 
virtual int sortKey ()
 Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists. More...
 
virtual double suggestSampleValue () const
 Returns a suggested sample value which nicely represents the current format configuration. More...
 
virtual QString visibleName () const =0
 Returns the translated, user-visible name for this format. More...
 
void writeXml (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
 Writes the format to an XML element. More...
 

Static Protected Attributes

static constexpr int DEFAULT_SORT_KEY = 100
 

Detailed Description

A numeric formatter allows for formatting a numeric value for display, using a variety of different formatting techniques (e.g.

as scientific notation, currency values, percentage values, etc)

This is an abstract base class and will always need to be subclassed.

Since
QGIS 3.12

Definition at line 259 of file qgsnumericformat.h.

Constructor & Destructor Documentation

◆ QgsNumericFormat()

QgsNumericFormat::QgsNumericFormat ( )
default

Default constructor.

◆ ~QgsNumericFormat()

virtual QgsNumericFormat::~QgsNumericFormat ( )
virtualdefault

Member Function Documentation

◆ clone()

virtual QgsNumericFormat * QgsNumericFormat::clone ( ) const
pure virtual

◆ configuration()

virtual QVariantMap QgsNumericFormat::configuration ( const QgsReadWriteContext context) const
pure virtual

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.

Implemented in QgsBasicNumericFormat, QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsFallbackNumericFormat, QgsFractionNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.

◆ create()

virtual QgsNumericFormat * QgsNumericFormat::create ( const QVariantMap &  configuration,
const QgsReadWriteContext context 
) const
pure virtual

Creates a new copy of the format, using the supplied configuration.

The caller takes ownership of the returned object.

Implemented in QgsBasicNumericFormat, QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsFallbackNumericFormat, QgsFractionNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.

◆ formatDouble()

virtual QString QgsNumericFormat::formatDouble ( double  value,
const QgsNumericFormatContext context 
) const
pure virtual

◆ id()

virtual QString QgsNumericFormat::id ( ) const
pure virtual

◆ operator!=()

bool QgsNumericFormat::operator!= ( const QgsNumericFormat other) const

Definition at line 71 of file qgsnumericformat.cpp.

◆ operator==()

bool QgsNumericFormat::operator== ( const QgsNumericFormat other) const

Definition at line 66 of file qgsnumericformat.cpp.

◆ sortKey()

int QgsNumericFormat::sortKey ( )
virtual

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 in QgsBasicNumericFormat, QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsFallbackNumericFormat, QgsFractionNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.

Definition at line 48 of file qgsnumericformat.cpp.

◆ suggestSampleValue()

double QgsNumericFormat::suggestSampleValue ( ) const
virtual

Returns a suggested sample value which nicely represents the current format configuration.

Reimplemented in QgsBearingNumericFormat, QgsGeographicCoordinateNumericFormat, QgsCurrencyNumericFormat, QgsFractionNumericFormat, and QgsPercentageNumericFormat.

Definition at line 53 of file qgsnumericformat.cpp.

◆ visibleName()

virtual QString QgsNumericFormat::visibleName ( ) const
pure virtual

◆ writeXml()

void QgsNumericFormat::writeXml ( QDomElement &  element,
QDomDocument &  document,
const QgsReadWriteContext context 
) const

Writes the format to an XML element.

See also
QgsNumericFormatRegistry::createFromXml()

Definition at line 58 of file qgsnumericformat.cpp.

Member Data Documentation

◆ DEFAULT_SORT_KEY

constexpr int QgsNumericFormat::DEFAULT_SORT_KEY = 100
staticconstexprprotected

Definition at line 354 of file qgsnumericformat.h.


The documentation for this class was generated from the following files: