10#include "acceleration_p.h"
13#include "binary_data_p.h"
14#include "currency_p.h"
16#include "electrical_current_p.h"
17#include "electrical_resistance_p.h"
19#include "weight_per_area_p.h"
21#include "frequency_p.h"
22#include "fuel_efficiency_p.h"
25#include "permeability_p.h"
27#include "pressure_p.h"
28#include "temperature_p.h"
29#include "thermal_conductivity_p.h"
30#include "thermal_flux_p.h"
31#include "thermal_generation_p.h"
32#include "timeunit_p.h"
34#include "velocity_p.h"
38#include <KLocalizedString>
40namespace KUnitConversion
47 m_categories[LengthCategory] = Length::makeCategory();
48 m_categories[AreaCategory] = Area::makeCategory();
49 m_categories[VolumeCategory] = Volume::makeCategory();
50 m_categories[TemperatureCategory] = Temperature::makeCategory();
51 m_categories[VelocityCategory] = Velocity::makeCategory();
52 m_categories[MassCategory] = Mass::makeCategory();
53 m_categories[PressureCategory] = Pressure::makeCategory();
54 m_categories[EnergyCategory] = Energy::makeCategory();
55 m_categories[CurrencyCategory] = Currency::makeCategory();
56 m_categories[PowerCategory] = Power::makeCategory();
57 m_categories[TimeCategory] = Time::makeCategory();
58 m_categories[FuelEfficiencyCategory] = FuelEfficiency::makeCategory();
59 m_categories[DensityCategory] = Density::makeCategory();
60 m_categories[WeightPerAreaCategory] = WeightPerArea::makeCategory();
61 m_categories[AccelerationCategory] = Acceleration::makeCategory();
62 m_categories[ForceCategory] = Force::makeCategory();
63 m_categories[AngleCategory] = Angle::makeCategory();
64 m_categories[FrequencyCategory] = Frequency::makeCategory();
65 m_categories[ThermalConductivityCategory] = ThermalConductivity::makeCategory();
66 m_categories[ThermalFluxCategory] = ThermalFlux::makeCategory();
67 m_categories[ThermalGenerationCategory] = ThermalGeneration::makeCategory();
68 m_categories[VoltageCategory] = Voltage::makeCategory();
69 m_categories[ElectricalCurrentCategory] = ElectricalCurrent::makeCategory();
70 m_categories[ElectricalResistanceCategory] = ElectricalResistance::makeCategory();
71 m_categories[PermeabilityCategory] = Permeability::makeCategory();
72 m_categories[BinaryDataCategory] = BinaryData::makeCategory();
78class QConverterSingleton
82 : d(new ConverterPrivate())
88Q_GLOBAL_STATIC(QConverterSingleton, global_converter)
91 : d(global_converter->d)
134 if (d && toUnit.isValid() && value.unit().isValid()) {
135 return value.unit().category().convert(value, toUnit);
144 if (u.hasUnit(
unit)) {
155 Unit unitClass = u.unit(unitString);
167 Unit unitClass = u.unit(unitId);
189 if (d && d->m_categories.contains(categoryId)) {
190 return d->m_categories[categoryId];
199 return d->m_categories.values();
Class for converting values between units of measurement.
QList< UnitCategory > categories() const
Returns a list of all unit categories.
Value convert(const Value &value, const QString &toUnit=QString()) const
Convert value to another unit.
Converter & operator=(const Converter &other)
Assignment operator, assign other to this.
Converter()
Creates a Converter instance.
~Converter()
Destroys this Converter instance.
UnitCategory categoryForUnit(const QString &unit) const
Find unit category for unit.
Unit unit(const QString &unitString) const
Find unit for string unit.
UnitCategory category(const QString &category) const
Find unit category.
Class to define a category of units of measurement.
Value convert(const Value &value, const QString &toUnit=QString()) const
Convert value to another unit selected by string.
Class to define a unit of measurement.
UnitCategory category() const
Class to hold a value in a unit of measurement.
Unit unit() const
Unit part of the value.
void swap(QExplicitlySharedDataPointer< T > &other)