Class to hold a value in a unit of measurement.
More...
#include <value.h>
|
| Value () |
| Creates a null 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).
|
|
| Value (const Value &other) |
| Copy constructor, copy other to this.
|
|
| Value (qreal number, const QString &unitString) |
| Creates a value with a unit (as a string).
|
|
| Value (qreal number, const Unit &unit) |
| Creates a value with a unit instance.
|
|
| Value (qreal number, UnitId unitId) |
| Creates a value with a unit (as a enum value).
|
|
| ~Value () |
| Destroys this Value instance.
|
|
Value | convertTo (const QString &unit) const |
| convert to another unit
|
|
Value | convertTo (const Unit &unit) const |
| convert to another unit
|
|
Value | convertTo (UnitId unit) const |
| convert to another unit
|
|
bool | isNull () const |
|
bool | isValid () const |
| Check if value is valid.
|
|
qreal | number () const |
| Number part of the value.
|
|
bool | operator!= (const Value &other) const |
|
Value & | operator= (const Value &other) |
| Assignment operator, assign other to this.
|
|
bool | operator== (const Value &other) const |
|
Value & | round (uint decimals) |
| rounds value to decimal count
|
|
void | swap (Value &other) |
| Swaps this Value with other .
|
|
QString | toString (int fieldWidth=0, char format='g', int precision=-1, const QChar &fillChar=QLatin1Char(' ')) const |
| Convert value to a string.
|
|
QString | toSymbolString (int fieldWidth=0, char format='g', int precision=-1, const QChar &fillChar=QLatin1Char(' ')) const |
| Convert value to a string with symbol.
|
|
Unit | unit () const |
| Unit part of the value.
|
|
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
◆ Value() [1/6]
KUnitConversion::Value::Value |
( |
| ) |
|
◆ Value() [2/6]
KUnitConversion::Value::Value |
( |
qreal |
number, |
|
|
const Unit & |
unit |
|
) |
| |
Creates a value with a unit instance.
◆ Value() [3/6]
KUnitConversion::Value::Value |
( |
qreal |
number, |
|
|
const QString & |
unitString |
|
) |
| |
Creates a value with a unit (as a string).
◆ Value() [4/6]
KUnitConversion::Value::Value |
( |
qreal |
number, |
|
|
UnitId |
unitId |
|
) |
| |
Creates a value with a unit (as a enum value).
◆ 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).
◆ Value() [6/6]
KUnitConversion::Value::Value |
( |
const Value & |
other | ) |
|
Copy constructor, copy other
to this.
◆ ~Value()
KUnitConversion::Value::~Value |
( |
| ) |
|
Destroys this Value instance.
◆ convertTo() [1/3]
Value KUnitConversion::Value::convertTo |
( |
const QString & |
unit | ) |
const |
◆ convertTo() [2/3]
Value KUnitConversion::Value::convertTo |
( |
const Unit & |
unit | ) |
const |
◆ convertTo() [3/3]
Value KUnitConversion::Value::convertTo |
( |
UnitId |
unit | ) |
const |
◆ isNull()
bool KUnitConversion::Value::isNull |
( |
| ) |
const |
- Returns
- returns true if this Value is null
◆ isValid()
bool KUnitConversion::Value::isValid |
( |
| ) |
const |
Check if value is valid.
- Returns
- True if value is valid
◆ number()
qreal KUnitConversion::Value::number |
( |
| ) |
const |
Number part of the value.
◆ operator!=()
bool KUnitConversion::Value::operator!= |
( |
const Value & |
other | ) |
const |
- Returns
true
if this Value is not equal to the other
Value.
◆ operator=()
Value & KUnitConversion::Value::operator= |
( |
const Value & |
other | ) |
|
Assignment operator, assign other
to this.
◆ operator==()
bool KUnitConversion::Value::operator== |
( |
const Value & |
other | ) |
const |
- Returns
true
if this Value is equal to the other
Value.
◆ round()
Value & KUnitConversion::Value::round |
( |
uint |
decimals | ) |
|
rounds value to decimal count
- Parameters
-
◆ swap()
void KUnitConversion::Value::swap |
( |
Value & |
other | ) |
|
|
inline |
Swaps this Value with other
.
This function is very fast and never fails.
◆ 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
-
fieldWidth | width of the formatted field, padded by spaces. Positive value aligns right, negative aligns left |
format | type of floating point formatting, like in QString::arg |
precision | number of digits after the decimal separator |
fillChar | the character used to fill up the empty places when field width is greater than argument width |
- Returns
- value as a string
◆ 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
-
fieldWidth | width of the formatted field, padded by spaces. Positive value aligns right, negative aligns left |
format | type of floating point formatting, like in QString::arg |
precision | number of digits after the decimal separator |
fillChar | the character used to fill up the empty places when field width is greater than argument width |
- Returns
- value as a string
◆ unit()
Unit KUnitConversion::Value::unit |
( |
| ) |
const |