KUnitConversion 5.109.0
Public Member Functions | Protected Member Functions | List of all members
KUnitConversion::Unit

Class to define a unit of measurement. More...

#include <unit.h>

Public Member Functions

 Unit ()
 Null constructor.
 
 Unit (const Unit &other)
 Copy constructor, copy other to this.
 
UnitCategory category () const
 
CategoryId categoryId () const
 
QString description () const
 
UnitId id () const
 
bool isNull () const
 
bool isValid () const
 
bool operator!= (const Unit &other) const
 
Unitoperator= (const Unit &other)
 Assignment operator, assign other to this.
 
bool operator== (const Unit &other) const
 
void swap (Unit &other)
 Swaps this Unit with other.
 
QString symbol () const
 
QString toString (qreal value, int fieldWidth=0, char format='g', int precision=-1, const QChar &fillChar=QLatin1Char(' ')) const
 
QString toSymbolString (qreal value, int fieldWidth=0, char format='g', int precision=-1, const QChar &fillChar=QLatin1Char(' ')) const
 

Protected Member Functions

qreal fromDefault (qreal value) const
 
qreal toDefault (qreal value) const
 

Detailed Description

Class to define a unit of measurement.

This is a class to define a unit of measurement.

See also
Converter, UnitCategory, Value
Author
Petri Damstén damu@.nosp@m.iki..nosp@m.fi
John Layt jlayt.nosp@m.@kde.nosp@m..org

Constructor & Destructor Documentation

◆ Unit() [1/2]

KUnitConversion::Unit::Unit ( )

Null constructor.

◆ Unit() [2/2]

KUnitConversion::Unit::Unit ( const Unit other)

Copy constructor, copy other to this.

Member Function Documentation

◆ category()

UnitCategory KUnitConversion::Unit::category ( ) const
Returns
unit category.

◆ categoryId()

CategoryId KUnitConversion::Unit::categoryId ( ) const
Returns
category id.

◆ description()

QString KUnitConversion::Unit::description ( ) const
Returns
translated name for unit.

◆ id()

UnitId KUnitConversion::Unit::id ( ) const
Returns
unit id.

◆ isNull()

bool KUnitConversion::Unit::isNull ( ) const
Returns
returns true if this Unit is null

◆ isValid()

bool KUnitConversion::Unit::isValid ( ) const
Returns
if unit is valid.

◆ operator!=()

bool KUnitConversion::Unit::operator!= ( const Unit other) const
Returns
true if this Unit is not equal to the other Unit.

◆ operator=()

Unit & KUnitConversion::Unit::operator= ( const Unit other)

Assignment operator, assign other to this.

◆ operator==()

bool KUnitConversion::Unit::operator== ( const Unit other) const
Returns
true if this Unit is equal to the other Unit.

◆ swap()

void KUnitConversion::Unit::swap ( Unit other)
inline

Swaps this Unit with other.

This function is very fast and never fails.

◆ symbol()

QString KUnitConversion::Unit::symbol ( ) const
Returns
symbol for the unit.

◆ toString()

QString KUnitConversion::Unit::toString ( qreal  value,
int  fieldWidth = 0,
char  format = 'g',
int  precision = -1,
const QChar &  fillChar = QLatin1Char(' ') 
) const
Parameters
valuenumber value
fieldWidthwidth of the formatted field, padded by spaces. Positive value aligns right, negative aligns left
formattype of floating point formatting, like in QString::arg
precisionnumber of digits after the decimal separator
fillCharthe character used to fill up the empty places when field width is greater than argument width
Returns
value + unit string

◆ toSymbolString()

QString KUnitConversion::Unit::toSymbolString ( qreal  value,
int  fieldWidth = 0,
char  format = 'g',
int  precision = -1,
const QChar &  fillChar = QLatin1Char(' ') 
) const
Parameters
valuenumber value
fieldWidthwidth of the formatted field, padded by spaces. Positive value aligns right, negative aligns left
formattype of floating point formatting, like in QString::arg
precisionnumber of digits after the decimal separator
fillCharthe character used to fill up the empty places when field width is greater than argument width
Returns
value + unit string