Class to define a category of units of measurement.
More...
#include <unitcategory.h>
|
QExplicitlySharedDataPointer< UnitCategoryPrivate > | d |
|
Class to define a category of units of measurement.
This is a class to define a category of units of measurement.
- See also
- Converter, Unit, Value
- Author
- Petri Damstén damu@.nosp@m.iki..nosp@m.fi
-
John Layt jlayt.nosp@m.@kde.nosp@m..org
◆ UnitCategory() [1/2]
KUnitConversion::UnitCategory::UnitCategory |
( |
| ) |
|
◆ UnitCategory() [2/2]
KUnitConversion::UnitCategory::UnitCategory |
( |
const UnitCategory & |
other | ) |
|
Copy constructor, copy other
to this.
◆ allUnits()
QStringList KUnitConversion::UnitCategory::allUnits |
( |
| ) |
const |
Return all unit names, short names and unit synonyms in this category.
- Returns
- list of units.
◆ convert() [1/3]
Value KUnitConversion::UnitCategory::convert |
( |
const Value & |
value, |
|
|
const QString & |
toUnit = QString() |
|
) |
| |
Convert value to another unit selected by string.
- Parameters
-
value | value to convert |
toUnit | unit to convert to. If empty default unit is used. |
- Returns
- converted value
◆ convert() [2/3]
virtual Value KUnitConversion::UnitCategory::convert |
( |
const Value & |
value, |
|
|
const Unit & |
toUnit |
|
) |
| |
|
virtual |
Convert value to another unit.
- Parameters
-
value | value to convert |
toUnit | unit to be used for conversion |
- Returns
- converted value
◆ convert() [3/3]
Value KUnitConversion::UnitCategory::convert |
( |
const Value & |
value, |
|
|
UnitId |
toUnit |
|
) |
| |
Convert value to another unit selected by enum.
- Parameters
-
value | value to convert |
toUnit | unit to convert to. |
- Returns
- converted value
◆ defaultUnit()
Unit KUnitConversion::UnitCategory::defaultUnit |
( |
| ) |
const |
Returns default unit.
- Returns
- default unit.
◆ description()
QString KUnitConversion::UnitCategory::description |
( |
| ) |
const |
- Returns
- unit category description
◆ hasOnlineConversionTable()
bool KUnitConversion::UnitCategory::hasOnlineConversionTable |
( |
| ) |
const |
- Returns
- true if category has conversion table that needs to be updated via online access, otherwise false
◆ hasUnit()
bool KUnitConversion::UnitCategory::hasUnit |
( |
const QString & |
unit | ) |
const |
Check if unit category has a unit.
- Returns
- True if unit is found
◆ id()
CategoryId KUnitConversion::UnitCategory::id |
( |
| ) |
const |
◆ isNull()
bool KUnitConversion::UnitCategory::isNull |
( |
| ) |
const |
◆ mostCommonUnits()
QList< Unit > KUnitConversion::UnitCategory::mostCommonUnits |
( |
| ) |
const |
Return most common units in this category.
- Returns
- list of units.
◆ name()
QString KUnitConversion::UnitCategory::name |
( |
| ) |
const |
Returns name for the unit category.
- Returns
- Translated name for category.
◆ operator!=()
bool KUnitConversion::UnitCategory::operator!= |
( |
const UnitCategory & |
other | ) |
const |
◆ operator=()
Assignment operator, assign other
to this.
◆ operator==()
bool KUnitConversion::UnitCategory::operator== |
( |
const UnitCategory & |
other | ) |
const |
◆ swap()
void KUnitConversion::UnitCategory::swap |
( |
UnitCategory & |
other | ) |
|
|
inline |
Swaps this UnitCategory with other
.
This function is very fast and never fails.
◆ syncConversionTable()
void KUnitConversion::UnitCategory::syncConversionTable |
( |
std::chrono::seconds |
updateSkipPeriod | ) |
|
Explicit request to sync conversion table when it is older than updateSkipPeriod
.
This method is supposed to be called at a convenient time at application startup. Yet it is safe to already do unit conversions that require an up-to-date conversion table (like currency). Those conversions yet block internally until the table is up-to-date.
◆ unit() [1/2]
Unit KUnitConversion::UnitCategory::unit |
( |
const QString & |
s | ) |
const |
Return unit for string.
- Returns
- Pointer to unit class.
◆ unit() [2/2]
Unit KUnitConversion::UnitCategory::unit |
( |
UnitId |
unitId | ) |
const |
Return unit for unit enum.
- Returns
- Pointer to unit class.
◆ units()
QList< Unit > KUnitConversion::UnitCategory::units |
( |
| ) |
const |
Return units in this category.
- Returns
- list of units.