KUnitConversion::Value

Search for usage in LXR

KUnitConversion::Value Class Reference

#include <value.h>

Public Member Functions

 Value ()
 
 Value (const QVariant &number, const QString &unitString)
 
 Value (const Value &other)
 
 Value (qreal number, const QString &unitString)
 
 Value (qreal number, const Unit &unit)
 
 Value (qreal number, UnitId unitId)
 
 ~Value ()
 
Value convertTo (const QString &unit) const
 
Value convertTo (const Unit &unit) const
 
Value convertTo (UnitId unit) const
 
bool isNull () const
 
bool isValid () const
 
qreal number () const
 
bool operator!= (const Value &other) const
 
Valueoperator= (const Value &other)
 
bool operator== (const Value &other) const
 
Valueround (uint decimals)
 
void swap (Value &other)
 
QString toString (int fieldWidth=0, char format='g', int precision=-1, const QChar &fillChar=QLatin1Char(' ')) const
 
QString toSymbolString (int fieldWidth=0, char format='g', int precision=-1, const QChar &fillChar=QLatin1Char(' ')) const
 
Unit unit () const
 

Detailed Description

Class to hold a value in a unit of measurement.

This is a class to hold a value in a unit of measurement.

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

Definition at line 35 of file value.h.

Constructor & Destructor Documentation

◆ Value() [1/6]

KUnitConversion::Value::Value ( )

Creates a null value.

Definition at line 80 of file value.cpp.

◆ Value() [2/6]

KUnitConversion::Value::Value ( qreal number,
const Unit & unit )

Creates a value with a unit instance.

Definition at line 90 of file value.cpp.

◆ Value() [3/6]

KUnitConversion::Value::Value ( qreal number,
const QString & unitString )

Creates a value with a unit (as a string).

Definition at line 95 of file value.cpp.

◆ Value() [4/6]

KUnitConversion::Value::Value ( qreal number,
UnitId unitId )

Creates a value with a unit (as a enum value).

Definition at line 100 of file value.cpp.

◆ Value() [5/6]

KUnitConversion::Value::Value ( const QVariant & number,
const QString & unitString )

Creates a value based on a QVariant (calling toReal() on it) with a unit (as a string).

Definition at line 105 of file value.cpp.

◆ Value() [6/6]

KUnitConversion::Value::Value ( const Value & other)

Copy constructor, copy other to this.

Definition at line 85 of file value.cpp.

◆ ~Value()

KUnitConversion::Value::~Value ( )

Destroys this Value instance.

Definition at line 110 of file value.cpp.

Member Function Documentation

◆ convertTo() [1/3]

Value KUnitConversion::Value::convertTo ( const QString & unit) const

convert to another unit

Definition at line 209 of file value.cpp.

◆ convertTo() [2/3]

Value KUnitConversion::Value::convertTo ( const Unit & unit) const

convert to another unit

Definition at line 193 of file value.cpp.

◆ convertTo() [3/3]

Value KUnitConversion::Value::convertTo ( UnitId unit) const

convert to another unit

Definition at line 201 of file value.cpp.

◆ isNull()

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

Definition at line 138 of file value.cpp.

◆ isValid()

bool KUnitConversion::Value::isValid ( ) const

Check if value is valid.

Returns
True if value is valid

Definition at line 143 of file value.cpp.

◆ number()

qreal KUnitConversion::Value::number ( ) const

Number part of the value.

Definition at line 148 of file value.cpp.

◆ operator!=()

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

Definition at line 129 of file value.cpp.

◆ operator=()

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

Assignment operator, assign other to this.

Definition at line 114 of file value.cpp.

◆ operator==()

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

Definition at line 120 of file value.cpp.

◆ round()

Value & KUnitConversion::Value::round ( uint decimals)

rounds value to decimal count

Parameters
decimalsdecimal count.

Definition at line 180 of file value.cpp.

◆ swap()

void KUnitConversion::Value::swap ( Value & other)
inline

Swaps this Value with other.

This function is very fast and never fails.

Definition at line 89 of file value.h.

◆ toString()

QString KUnitConversion::Value::toString ( int fieldWidth = 0,
char format = 'g',
int precision = -1,
const QChar & fillChar = QLatin1Char(' ') ) const

Convert value to a string.

Parameters
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 as a string

Definition at line 164 of file value.cpp.

◆ toSymbolString()

QString KUnitConversion::Value::toSymbolString ( int fieldWidth = 0,
char format = 'g',
int precision = -1,
const QChar & fillChar = QLatin1Char(' ') ) const

Convert value to a string with symbol.

Parameters
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 as a string

Definition at line 172 of file value.cpp.

◆ unit()

Unit KUnitConversion::Value::unit ( ) const

Unit part of the value.

Definition at line 156 of file value.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.