QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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
 
virtual ~QgsNumericFormat ()=default
 
virtual QgsNumericFormatclone () const =0
 Clones the format, returning a new object.
 
virtual QVariantMap configuration (const QgsReadWriteContext &context) const =0
 Returns the current configuration of the formatter.
 
virtual QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const =0
 Creates a new copy of the format, using the supplied configuration.
 
virtual QString formatDouble (double value, const QgsNumericFormatContext &context) const =0
 Returns a formatted string representation of a numeric double value.
 
virtual QString id () const =0
 Returns a unique id for this numeric format.
 
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.
 
virtual double suggestSampleValue () const
 Returns a suggested sample value which nicely represents the current format configuration.
 
virtual QString visibleName () const =0
 Returns the translated, user-visible name for this format.
 
void writeXml (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
 Writes the format to an XML element.
 

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 278 of file qgsnumericformat.h.

Constructor & Destructor Documentation

◆ QgsNumericFormat()

QgsNumericFormat::QgsNumericFormat ( )
default

◆ ~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, QgsExpressionBasedNumericFormat, 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, QgsExpressionBasedNumericFormat, 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 82 of file qgsnumericformat.cpp.

◆ operator==()

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

Definition at line 77 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, QgsExpressionBasedNumericFormat, QgsFallbackNumericFormat, QgsFractionNumericFormat, QgsPercentageNumericFormat, and QgsScientificNumericFormat.

Definition at line 59 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 64 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 69 of file qgsnumericformat.cpp.

Member Data Documentation

◆ DEFAULT_SORT_KEY

constexpr int QgsNumericFormat::DEFAULT_SORT_KEY = 100
staticconstexprprotected

Definition at line 372 of file qgsnumericformat.h.


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