8#ifndef KUNITCONVERSION_UNITCATEGORY_H
9#define KUNITCONVERSION_UNITCATEGORY_H
11#include "kunitconversion/kunitconversion_export.h"
14#include <QExplicitlySharedDataPointer>
19namespace KUnitConversion
21class UnitCategoryPrivate;
56#ifdef Q_COMPILER_RVALUE_REFS
95 CategoryId
id()
const;
204 void addDefaultUnit(
const Unit &unit);
205 void addCommonUnit(
const Unit &unit);
206 void addUnit(
const Unit &unit);
210 friend class UnitCategoryPrivate;
212 KUNITCONVERSION_NO_EXPORT
explicit UnitCategory(UnitCategoryPrivate *dd);
215 QExplicitlySharedDataPointer<UnitCategoryPrivate> d;
Class to define a category of units of measurement.
Definition unitcategory.h:35
QStringList allUnits() const
Return all unit names, short names and unit synonyms in this category.
UnitCategory()
Null constructor.
bool operator!=(const UnitCategory &other) const
virtual Value convert(const Value &value, const Unit &toUnit)
Convert value to another unit.
bool hasOnlineConversionTable() const
QList< Unit > units() const
Return units in this category.
bool operator==(const UnitCategory &other) const
Unit unit(UnitId unitId) const
Return unit for unit enum.
Unit unit(const QString &s) const
Return unit for string.
Unit defaultUnit() const
Returns default unit.
Value convert(const Value &value, UnitId toUnit)
Convert value to another unit selected by enum.
QString name() const
Returns name for the unit category.
void syncConversionTable(std::chrono::seconds updateSkipPeriod)
Explicit request to sync conversion table when it is older than updateSkipPeriod.
Value convert(const Value &value, const QString &toUnit=QString())
Convert value to another unit selected by string.
UnitCategory & operator=(const UnitCategory &other)
Assignment operator, assign other to this.
UnitCategory(const UnitCategory &other)
Copy constructor, copy other to this.
void swap(UnitCategory &other)
Swaps this UnitCategory with other.
Definition unitcategory.h:72
QString description() const
QList< Unit > mostCommonUnits() const
Return most common units in this category.
bool hasUnit(const QString &unit) const
Check if unit category has a unit.
Class to define a unit of measurement.
Definition unit.h:758
Class to hold a value in a unit of measurement.
Definition value.h:36