QGIS API Documentation 3.41.0-Master (3291e9ff48b)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsExpressionBasedNumericFormat Class Reference

A numeric formatter which uses a QgsExpression to calculate the text representation of a value. More...

#include <qgsexpressionbasednumericformat.h>

Inheritance diagram for QgsExpressionBasedNumericFormat:
Inheritance graph
[legend]

Public Member Functions

 QgsExpressionBasedNumericFormat ()
 
QgsNumericFormatclone () const override
 Clones the format, returning a new object.
 
QVariantMap configuration (const QgsReadWriteContext &context) const override
 Returns the current configuration of the formatter.
 
QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const override
 Creates a new copy of the format, using the supplied configuration.
 
QString expression () const
 Returns the expression used to calculate the text representation of a value.
 
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.
 
void setExpression (const QString &expression)
 Sets the expression used to calculate the text representation of a value.
 
int sortKey () override
 Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
 
QString visibleName () const override
 Returns the translated, user-visible name for this format.
 
- Public Member Functions inherited from QgsNumericFormat
 QgsNumericFormat ()=default
 
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.
 

Additional Inherited Members

- Static Protected Attributes inherited from QgsNumericFormat
static constexpr int DEFAULT_SORT_KEY = 100
 

Detailed Description

A numeric formatter which uses a QgsExpression to calculate the text representation of a value.

Since
QGIS 3.40

Definition at line 29 of file qgsexpressionbasednumericformat.h.

Constructor & Destructor Documentation

◆ QgsExpressionBasedNumericFormat()

QgsExpressionBasedNumericFormat::QgsExpressionBasedNumericFormat ( )

Definition at line 19 of file qgsexpressionbasednumericformat.cpp.

Member Function Documentation

◆ clone()

QgsNumericFormat * QgsExpressionBasedNumericFormat::clone ( ) const
overridevirtual

Clones the format, returning a new object.

The caller takes ownership of the returned object.

Implements QgsNumericFormat.

Definition at line 47 of file qgsexpressionbasednumericformat.cpp.

◆ configuration()

QVariantMap QgsExpressionBasedNumericFormat::configuration ( const QgsReadWriteContext context) const
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.

Definition at line 59 of file qgsexpressionbasednumericformat.cpp.

◆ create()

QgsNumericFormat * QgsExpressionBasedNumericFormat::create ( const QVariantMap &  configuration,
const QgsReadWriteContext context 
) const
overridevirtual

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

The caller takes ownership of the returned object.

Implements QgsNumericFormat.

Definition at line 52 of file qgsexpressionbasednumericformat.cpp.

◆ expression()

QString QgsExpressionBasedNumericFormat::expression ( ) const
inline

Returns the expression used to calculate the text representation of a value.

See also
setExpression()

Definition at line 57 of file qgsexpressionbasednumericformat.h.

◆ formatDouble()

QString QgsExpressionBasedNumericFormat::formatDouble ( double  value,
const QgsNumericFormatContext context 
) const
overridevirtual

Returns a formatted string representation of a numeric double value.

Implements QgsNumericFormat.

Definition at line 39 of file qgsexpressionbasednumericformat.cpp.

◆ id()

QString QgsExpressionBasedNumericFormat::id ( ) const
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.

Definition at line 24 of file qgsexpressionbasednumericformat.cpp.

◆ setExpression()

void QgsExpressionBasedNumericFormat::setExpression ( const QString &  expression)

Sets the expression used to calculate the text representation of a value.

The expression can utilize @value to retrieve the numeric value to represent.

See also
expression()

Definition at line 66 of file qgsexpressionbasednumericformat.cpp.

◆ sortKey()

int QgsExpressionBasedNumericFormat::sortKey ( )
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.

Definition at line 34 of file qgsexpressionbasednumericformat.cpp.

◆ visibleName()

QString QgsExpressionBasedNumericFormat::visibleName ( ) const
overridevirtual

Returns the translated, user-visible name for this format.

Implements QgsNumericFormat.

Definition at line 29 of file qgsexpressionbasednumericformat.cpp.


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