QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Public Member Functions | 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...
 

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 217 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

Clones the format, returning a new object.

The caller takes ownership of the returned object.

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

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

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

◆ formatDouble()

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

◆ id()

virtual QString QgsNumericFormat::id ( ) const
pure virtual

Returns a unique id for this numeric format.

This id is used to identify this numeric format in the registry with QgsNumericFormatRegistry::format().

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

◆ operator!=()

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

Definition at line 58 of file qgsnumericformat.cpp.

◆ operator==()

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

Definition at line 53 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 QgsScientificNumericFormat, QgsPercentageNumericFormat, QgsFractionNumericFormat, QgsFallbackNumericFormat, QgsCurrencyNumericFormat, QgsBearingNumericFormat, and QgsBasicNumericFormat.

Definition at line 35 of file qgsnumericformat.cpp.

◆ suggestSampleValue()

double QgsNumericFormat::suggestSampleValue ( ) const
virtual

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

Reimplemented in QgsPercentageNumericFormat, QgsFractionNumericFormat, QgsCurrencyNumericFormat, and QgsBearingNumericFormat.

Definition at line 40 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 45 of file qgsnumericformat.cpp.


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