8#include "temperature_p.h"
11#include <KLocalizedString>
13namespace KUnitConversion
15class CelsiusUnitPrivate :
public UnitPrivate
18 CelsiusUnitPrivate(CategoryId categoryId,
27 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
31 qreal toDefault(qreal value)
const override
33 return value + 273.15;
36 qreal fromDefault(qreal value)
const override
38 return value - 273.15;
42class FahrenheitUnitPrivate :
public UnitPrivate
45 FahrenheitUnitPrivate(CategoryId categoryId,
54 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
58 qreal toDefault(qreal value)
const override
60 return (value + 459.67) * 5.0 / 9.0;
63 qreal fromDefault(qreal value)
const override
65 return (value * 9.0 / 5.0) - 459.67;
69class DelisleUnitPrivate :
public UnitPrivate
72 DelisleUnitPrivate(CategoryId categoryId,
81 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
85 qreal toDefault(qreal value)
const override
87 return 373.15 - (value * 2.0 / 3.0);
90 qreal fromDefault(qreal value)
const override
92 return (373.15 - value) * 3.0 / 2.0;
96class NewtonUnitPrivate :
public UnitPrivate
99 NewtonUnitPrivate(CategoryId categoryId,
108 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
112 qreal toDefault(qreal value)
const override
114 return (value * 100.0 / 33.0) + 273.15;
117 qreal fromDefault(qreal value)
const override
119 return (value - 273.15) * 33.0 / 100.0;
123class ReaumurUnitPrivate :
public UnitPrivate
126 ReaumurUnitPrivate(CategoryId categoryId,
135 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
139 qreal toDefault(qreal value)
const override
141 return (value * 5.0 / 4.0) + 273.15;
144 qreal fromDefault(qreal value)
const override
146 return (value - 273.15) * 4.0 / 5.0;
150class RomerUnitPrivate :
public UnitPrivate
153 RomerUnitPrivate(CategoryId categoryId,
162 : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
166 qreal toDefault(qreal value)
const override
168 return (value - 7.5) * 40.0 / 21.0 + 273.15;
171 qreal fromDefault(qreal value)
const override
173 return (value - 273.15) * 21.0 / 40.0 + 7.5;
177UnitCategory Temperature::makeCategory()
179 auto c = UnitCategoryPrivate::makeCategory(TemperatureCategory,
i18n(
"Temperature"),
i18n(
"Temperature"));
180 auto d = UnitCategoryPrivate::get(c);
183 d->addDefaultUnit(UnitPrivate::makeUnit(TemperatureCategory,
186 i18nc(
"temperature unit symbol",
"K"),
187 i18nc(
"unit description in lists",
"kelvins"),
188 i18nc(
"unit synonyms for matching user input",
"kelvin;kelvins;K"),
190 ki18nc(
"amount in units (real)",
"%1 kelvins"),
191 ki18ncp(
"amount in units (integer)",
"%1 kelvin",
"%1 kelvins")));
193 d->addCommonUnit(UnitPrivate::makeUnit(
new CelsiusUnitPrivate(TemperatureCategory,
196 i18nc(
"temperature unit symbol",
"°C"),
197 i18nc(
"unit description in lists",
"Celsius"),
198 i18nc(
"unit synonyms for matching user input",
"Celsius;°C;C"),
200 ki18nc(
"amount in units (real)",
"%1 degrees Celsius"),
201 ki18ncp(
"amount in units (integer)",
"%1 degree Celsius",
"%1 degrees Celsius"))));
203 d->addCommonUnit(UnitPrivate::makeUnit(
new FahrenheitUnitPrivate(TemperatureCategory,
206 i18nc(
"temperature unit symbol",
"°F"),
207 i18nc(
"unit description in lists",
"Fahrenheit"),
208 i18nc(
"unit synonyms for matching user input",
"Fahrenheit;°F;F"),
210 ki18nc(
"amount in units (real)",
"%1 degrees Fahrenheit"),
211 ki18ncp(
"amount in units (integer)",
"%1 degree Fahrenheit",
"%1 degrees Fahrenheit"))));
213 d->addUnit(UnitPrivate::makeUnit(TemperatureCategory,
216 i18nc(
"temperature unit symbol",
"R"),
217 i18nc(
"unit description in lists",
"Rankine"),
218 i18nc(
"unit synonyms for matching user input",
"Rankine;°R;R;Ra"),
220 ki18nc(
"amount in units (real)",
"%1 Rankine"),
221 ki18ncp(
"amount in units (integer)",
"%1 Rankine",
"%1 Rankine")));
223 d->addUnit(UnitPrivate::makeUnit(
new DelisleUnitPrivate(TemperatureCategory,
226 i18nc(
"temperature unit symbol",
"°De"),
227 i18nc(
"unit description in lists",
"Delisle"),
228 i18nc(
"unit synonyms for matching user input",
"Delisle;°De;De"),
230 ki18nc(
"amount in units (real)",
"%1 degrees Delisle"),
231 ki18ncp(
"amount in units (integer)",
"%1 degree Delisle",
"%1 degrees Delisle"))));
233 d->addUnit(UnitPrivate::makeUnit(
new NewtonUnitPrivate(TemperatureCategory,
236 i18nc(
"temperature unit symbol",
"°N"),
237 i18nc(
"unit description in lists",
"Newton"),
238 i18nc(
"unit synonyms for matching user input",
"Newton;°N;N"),
240 ki18nc(
"amount in units (real)",
"%1 degrees Newton"),
241 ki18ncp(
"amount in units (integer)",
"%1 degree Newton",
"%1 degrees Newton"))));
243 d->addUnit(UnitPrivate::makeUnit(
new ReaumurUnitPrivate(TemperatureCategory,
246 i18nc(
"temperature unit symbol",
"°Ré"),
247 i18nc(
"unit description in lists",
"Réaumur"),
248 i18nc(
"unit synonyms for matching user input",
"Réaumur;°Ré;Ré;Reaumur;°Re;Re"),
250 ki18nc(
"amount in units (real)",
"%1 degrees Réaumur"),
251 ki18ncp(
"amount in units (integer)",
"%1 degree Réaumur",
"%1 degrees Réaumur"))));
253 d->addUnit(UnitPrivate::makeUnit(
new RomerUnitPrivate(TemperatureCategory,
256 i18nc(
"temperature unit symbol",
"°Rø"),
257 i18nc(
"unit description in lists",
"Rømer"),
258 i18nc(
"unit synonyms for matching user input",
"Rømer;°Rø;Rø;Romer;°Ro;Ro"),
260 ki18nc(
"amount in units (real)",
"%1 degrees Rømer"),
261 ki18ncp(
"amount in units (integer)",
"%1 degree Rømer",
"%1 degrees Rømer"))));
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
QString i18n(const char *text, const TYPE &arg...)