QGIS API Documentation  3.13.0-Master (13337b20cd)
Public Types | Public Member Functions | List of all members
QgsPercentageNumericFormat Class Reference

A numeric formatter which returns a text representation of a percentage value. More...

#include <qgspercentagenumericformat.h>

Inheritance diagram for QgsPercentageNumericFormat:
Inheritance graph
[legend]

Public Types

enum  InputValues { ValuesArePercentage, ValuesAreFractions }
 Input value format, which specifies the format of the incoming values. More...
 
- Public Types inherited from QgsBasicNumericFormat
enum  RoundingType { DecimalPlaces, SignificantFigures }
 Sets rounding type and behavior of the numberDecimalPlaces() setting. More...
 

Public Member Functions

 QgsPercentageNumericFormat ()
 Default constructor. More...
 
QgsNumericFormatclone () const override
 Clones the format, returning a new object. More...
 
QVariantMap configuration (const QgsReadWriteContext &context) const override
 Returns the current configuration of the formatter. More...
 
QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const override
 Creates a new copy of the format, using the supplied configuration. More...
 
QString formatDouble (double value, const QgsNumericFormatContext &context) const override
 Returns a formatted string representation of a numeric double value. More...
 
QString id () const override
 Returns a unique id for this numeric format. More...
 
InputValues inputValues () const
 Returns the format of the incoming values. More...
 
void setInputValues (InputValues format)
 Sets the format of the incoming values. More...
 
int sortKey () override
 Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists. More...
 
double suggestSampleValue () const override
 Returns a suggested sample value which nicely represents the current format configuration. More...
 
QString visibleName () const override
 Returns the translated, user-visible name for this format. More...
 
- Public Member Functions inherited from QgsBasicNumericFormat
 QgsBasicNumericFormat ()
 Default constructor. More...
 
QChar decimalSeparator () const
 Returns any override for the decimal separator character. More...
 
int numberDecimalPlaces () const
 Returns the maximum number of decimal places to show. More...
 
RoundingType roundingType () const
 Returns the rounding type, which controls the behavior of the numberDecimalPlaces() setting. More...
 
void setDecimalSeparator (QChar character)
 Sets an override character for the decimal separator character. More...
 
virtual void setNumberDecimalPlaces (int places)
 Sets the maximum number of decimal places to show. More...
 
void setRoundingType (RoundingType type)
 Sets the rounding type, which controls the behavior of the numberDecimalPlaces() setting. More...
 
void setShowPlusSign (bool show)
 Sets whether a leading plus sign will be shown for positive values. More...
 
void setShowThousandsSeparator (bool show)
 Sets whether the thousands grouping separator will be shown. More...
 
void setShowTrailingZeros (bool show)
 Sets whether trailing zeros will be shown (up to the specified numberDecimalPlaces()). More...
 
void setThousandsSeparator (QChar character)
 Sets an override character for the thousands separator character. More...
 
bool showPlusSign () const
 Returns true if a leading plus sign will be shown for positive values. More...
 
bool showThousandsSeparator () const
 Returns true if the thousands grouping separator will be shown. More...
 
bool showTrailingZeros () const
 Returns true if trailing zeros will be shown (up to the specified numberDecimalPlaces()). More...
 
QChar thousandsSeparator () const
 Returns any override for the thousands separator character. More...
 
- Public Member Functions inherited from QgsNumericFormat
 QgsNumericFormat ()=default
 Default constructor. More...
 
virtual ~QgsNumericFormat ()=default
 
bool operator!= (const QgsNumericFormat &other) const
 
bool operator== (const QgsNumericFormat &other) const
 
void writeXml (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
 Writes the format to an XML element. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QgsBasicNumericFormat
virtual void setConfiguration (const QVariantMap &configuration, const QgsReadWriteContext &context)
 Sets the format's configuration. More...
 
- Protected Attributes inherited from QgsBasicNumericFormat
bool mUseScientific = false
 

Detailed Description

A numeric formatter which returns a text representation of a percentage value.

Since
QGIS 3.12

Definition at line 28 of file qgspercentagenumericformat.h.

Member Enumeration Documentation

◆ InputValues

Input value format, which specifies the format of the incoming values.

Enumerator
ValuesArePercentage 

Incoming values are percentage values (e.g. 50 for 50%)

ValuesAreFractions 

Incoming values are numeric fractions (e.g. 0.5 for 50%)

Definition at line 33 of file qgspercentagenumericformat.h.

Constructor & Destructor Documentation

◆ QgsPercentageNumericFormat()

QgsPercentageNumericFormat::QgsPercentageNumericFormat ( )

Default constructor.

Definition at line 21 of file qgspercentagenumericformat.cpp.

Member Function Documentation

◆ clone()

QgsNumericFormat * QgsPercentageNumericFormat::clone ( ) const
overridevirtual

Clones the format, returning a new object.

The caller takes ownership of the returned object.

Reimplemented from QgsBasicNumericFormat.

Definition at line 68 of file qgspercentagenumericformat.cpp.

◆ configuration()

QVariantMap QgsPercentageNumericFormat::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.

Reimplemented from QgsBasicNumericFormat.

Definition at line 82 of file qgspercentagenumericformat.cpp.

◆ create()

QgsNumericFormat * QgsPercentageNumericFormat::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.

Reimplemented from QgsBasicNumericFormat.

Definition at line 73 of file qgspercentagenumericformat.cpp.

◆ formatDouble()

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

Returns a formatted string representation of a numeric double value.

Reimplemented from QgsBasicNumericFormat.

Definition at line 53 of file qgspercentagenumericformat.cpp.

◆ id()

QString QgsPercentageNumericFormat::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().

Reimplemented from QgsBasicNumericFormat.

Definition at line 25 of file qgspercentagenumericformat.cpp.

◆ inputValues()

QgsPercentageNumericFormat::InputValues QgsPercentageNumericFormat::inputValues ( ) const

Returns the format of the incoming values.

See also
setInputValues()

Definition at line 89 of file qgspercentagenumericformat.cpp.

◆ setInputValues()

void QgsPercentageNumericFormat::setInputValues ( InputValues  format)

Sets the format of the incoming values.

See also
inputValues()

Definition at line 94 of file qgspercentagenumericformat.cpp.

◆ sortKey()

int QgsPercentageNumericFormat::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 QgsBasicNumericFormat.

Definition at line 35 of file qgspercentagenumericformat.cpp.

◆ suggestSampleValue()

double QgsPercentageNumericFormat::suggestSampleValue ( ) const
overridevirtual

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

Reimplemented from QgsNumericFormat.

Definition at line 40 of file qgspercentagenumericformat.cpp.

◆ visibleName()

QString QgsPercentageNumericFormat::visibleName ( ) const
overridevirtual

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

Reimplemented from QgsBasicNumericFormat.

Definition at line 30 of file qgspercentagenumericformat.cpp.


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