1 | /* |
2 | * SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi> |
3 | * SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org> |
4 | * |
5 | * SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #include "energy_p.h" |
9 | #include "unit_p.h" |
10 | |
11 | #include <KLocalizedString> |
12 | |
13 | namespace KUnitConversion |
14 | { |
15 | class PhotoUnitPrivate : public UnitPrivate |
16 | { |
17 | public: |
18 | PhotoUnitPrivate(CategoryId categoryId, |
19 | UnitId id, |
20 | qreal multiplier, |
21 | const QString &symbol, |
22 | const QString &description, |
23 | const QString &matchString, |
24 | const KLocalizedString &symbolString, |
25 | const KLocalizedString &realString, |
26 | const KLocalizedString &integerString) |
27 | : UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString) |
28 | { |
29 | } |
30 | |
31 | qreal toDefault(qreal value) const override |
32 | { |
33 | return (2.99792458e+08 * 6.62606896e-34) / (value * 1e-09); |
34 | } |
35 | |
36 | qreal fromDefault(qreal value) const override |
37 | { |
38 | return ((2.99792458e+08 * 6.62606896e-34) / value) / 1e-09; |
39 | } |
40 | }; |
41 | |
42 | UnitCategory Energy::makeCategory() |
43 | { |
44 | auto c = UnitCategoryPrivate::makeCategory(id: EnergyCategory, i18n("Energy" ), i18n("Energy" )); |
45 | auto d = UnitCategoryPrivate::get(category: c); |
46 | KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (energy)" , "%1 %2" ); |
47 | |
48 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
49 | id: Yottajoule, |
50 | multiplier: 1e+24, |
51 | i18nc("energy unit symbol" , "YJ" ), |
52 | i18nc("unit description in lists" , "yottajoules" ), |
53 | i18nc("unit synonyms for matching user input" , "yottajoule;yottajoules;YJ" ), |
54 | symbolString, |
55 | ki18nc("amount in units (real)" , "%1 yottajoules" ), |
56 | ki18ncp("amount in units (integer)" , "%1 yottajoule" , "%1 yottajoules" ))); |
57 | |
58 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
59 | id: Zettajoule, |
60 | multiplier: 1e+21, |
61 | i18nc("energy unit symbol" , "ZJ" ), |
62 | i18nc("unit description in lists" , "zettajoules" ), |
63 | i18nc("unit synonyms for matching user input" , "zettajoule;zettajoules;ZJ" ), |
64 | symbolString, |
65 | ki18nc("amount in units (real)" , "%1 zettajoules" ), |
66 | ki18ncp("amount in units (integer)" , "%1 zettajoule" , "%1 zettajoules" ))); |
67 | |
68 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
69 | id: Exajoule, |
70 | multiplier: 1e+18, |
71 | i18nc("energy unit symbol" , "EJ" ), |
72 | i18nc("unit description in lists" , "exajoules" ), |
73 | i18nc("unit synonyms for matching user input" , "exajoule;exajoules;EJ" ), |
74 | symbolString, |
75 | ki18nc("amount in units (real)" , "%1 exajoules" ), |
76 | ki18ncp("amount in units (integer)" , "%1 exajoule" , "%1 exajoules" ))); |
77 | |
78 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
79 | id: Petajoule, |
80 | multiplier: 1e+15, |
81 | i18nc("energy unit symbol" , "PJ" ), |
82 | i18nc("unit description in lists" , "petajoules" ), |
83 | i18nc("unit synonyms for matching user input" , "petajoule;petajoules;PJ" ), |
84 | symbolString, |
85 | ki18nc("amount in units (real)" , "%1 petajoules" ), |
86 | ki18ncp("amount in units (integer)" , "%1 petajoule" , "%1 petajoules" ))); |
87 | |
88 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
89 | id: Terajoule, |
90 | multiplier: 1e+12, |
91 | i18nc("energy unit symbol" , "TJ" ), |
92 | i18nc("unit description in lists" , "terajoules" ), |
93 | i18nc("unit synonyms for matching user input" , "terajoule;terajoules;TJ" ), |
94 | symbolString, |
95 | ki18nc("amount in units (real)" , "%1 terajoules" ), |
96 | ki18ncp("amount in units (integer)" , "%1 terajoule" , "%1 terajoules" ))); |
97 | |
98 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
99 | id: Gigajoule, |
100 | multiplier: 1e+09, |
101 | i18nc("energy unit symbol" , "GJ" ), |
102 | i18nc("unit description in lists" , "gigajoules" ), |
103 | i18nc("unit synonyms for matching user input" , "gigajoule;gigajoules;GJ" ), |
104 | symbolString, |
105 | ki18nc("amount in units (real)" , "%1 gigajoules" ), |
106 | ki18ncp("amount in units (integer)" , "%1 gigajoule" , "%1 gigajoules" ))); |
107 | |
108 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
109 | id: Megajoule, |
110 | multiplier: 1e+06, |
111 | i18nc("energy unit symbol" , "MJ" ), |
112 | i18nc("unit description in lists" , "megajoules" ), |
113 | i18nc("unit synonyms for matching user input" , "megajoule;megajoules;MJ" ), |
114 | symbolString, |
115 | ki18nc("amount in units (real)" , "%1 megajoules" ), |
116 | ki18ncp("amount in units (integer)" , "%1 megajoule" , "%1 megajoules" ))); |
117 | |
118 | d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
119 | id: Kilojoule, |
120 | multiplier: 1000, |
121 | i18nc("energy unit symbol" , "kJ" ), |
122 | i18nc("unit description in lists" , "kilojoules" ), |
123 | i18nc("unit synonyms for matching user input" , "kilojoule;kilojoules;kJ" ), |
124 | symbolString, |
125 | ki18nc("amount in units (real)" , "%1 kilojoules" ), |
126 | ki18ncp("amount in units (integer)" , "%1 kilojoule" , "%1 kilojoules" ))); |
127 | |
128 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
129 | id: Hectojoule, |
130 | multiplier: 100, |
131 | i18nc("energy unit symbol" , "hJ" ), |
132 | i18nc("unit description in lists" , "hectojoules" ), |
133 | i18nc("unit synonyms for matching user input" , "hectojoule;hectojoules;hJ" ), |
134 | symbolString, |
135 | ki18nc("amount in units (real)" , "%1 hectojoules" ), |
136 | ki18ncp("amount in units (integer)" , "%1 hectojoule" , "%1 hectojoules" ))); |
137 | |
138 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
139 | id: Decajoule, |
140 | multiplier: 10, |
141 | i18nc("energy unit symbol" , "daJ" ), |
142 | i18nc("unit description in lists" , "decajoules" ), |
143 | i18nc("unit synonyms for matching user input" , "decajoule;decajoules;daJ" ), |
144 | symbolString, |
145 | ki18nc("amount in units (real)" , "%1 decajoules" ), |
146 | ki18ncp("amount in units (integer)" , "%1 decajoule" , "%1 decajoules" ))); |
147 | |
148 | d->addDefaultUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
149 | id: Joule, |
150 | multiplier: 1, |
151 | i18nc("energy unit symbol" , "J" ), |
152 | i18nc("unit description in lists" , "joules" ), |
153 | i18nc("unit synonyms for matching user input" , "joule;joules;J" ), |
154 | symbolString, |
155 | ki18nc("amount in units (real)" , "%1 joules" ), |
156 | ki18ncp("amount in units (integer)" , "%1 joule" , "%1 joules" ))); |
157 | |
158 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
159 | id: Decijoule, |
160 | multiplier: 0.1, |
161 | i18nc("energy unit symbol" , "dJ" ), |
162 | i18nc("unit description in lists" , "decijoules" ), |
163 | i18nc("unit synonyms for matching user input" , "decijoule;decijoules;dJ" ), |
164 | symbolString, |
165 | ki18nc("amount in units (real)" , "%1 decijoules" ), |
166 | ki18ncp("amount in units (integer)" , "%1 decijoule" , "%1 decijoules" ))); |
167 | |
168 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
169 | id: Centijoule, |
170 | multiplier: 0.01, |
171 | i18nc("energy unit symbol" , "cJ" ), |
172 | i18nc("unit description in lists" , "centijoules" ), |
173 | i18nc("unit synonyms for matching user input" , "centijoule;centijoules;cJ" ), |
174 | symbolString, |
175 | ki18nc("amount in units (real)" , "%1 centijoules" ), |
176 | ki18ncp("amount in units (integer)" , "%1 centijoule" , "%1 centijoules" ))); |
177 | |
178 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
179 | id: Millijoule, |
180 | multiplier: 0.001, |
181 | i18nc("energy unit symbol" , "mJ" ), |
182 | i18nc("unit description in lists" , "millijoules" ), |
183 | i18nc("unit synonyms for matching user input" , "millijoule;millijoules;mJ" ), |
184 | symbolString, |
185 | ki18nc("amount in units (real)" , "%1 millijoules" ), |
186 | ki18ncp("amount in units (integer)" , "%1 millijoule" , "%1 millijoules" ))); |
187 | |
188 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
189 | id: Microjoule, |
190 | multiplier: 1e-06, |
191 | i18nc("energy unit symbol" , "µJ" ), |
192 | i18nc("unit description in lists" , "microjoules" ), |
193 | i18nc("unit synonyms for matching user input" , "microjoule;microjoules;µJ;uJ" ), |
194 | symbolString, |
195 | ki18nc("amount in units (real)" , "%1 microjoules" ), |
196 | ki18ncp("amount in units (integer)" , "%1 microjoule" , "%1 microjoules" ))); |
197 | |
198 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
199 | id: Nanojoule, |
200 | multiplier: 1e-09, |
201 | i18nc("energy unit symbol" , "nJ" ), |
202 | i18nc("unit description in lists" , "nanojoules" ), |
203 | i18nc("unit synonyms for matching user input" , "nanojoule;nanojoules;nJ" ), |
204 | symbolString, |
205 | ki18nc("amount in units (real)" , "%1 nanojoules" ), |
206 | ki18ncp("amount in units (integer)" , "%1 nanojoule" , "%1 nanojoules" ))); |
207 | |
208 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
209 | id: Picojoule, |
210 | multiplier: 1e-12, |
211 | i18nc("energy unit symbol" , "pJ" ), |
212 | i18nc("unit description in lists" , "picojoules" ), |
213 | i18nc("unit synonyms for matching user input" , "picojoule;picojoules;pJ" ), |
214 | symbolString, |
215 | ki18nc("amount in units (real)" , "%1 picojoules" ), |
216 | ki18ncp("amount in units (integer)" , "%1 picojoule" , "%1 picojoules" ))); |
217 | |
218 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
219 | id: Femtojoule, |
220 | multiplier: 1e-15, |
221 | i18nc("energy unit symbol" , "fJ" ), |
222 | i18nc("unit description in lists" , "femtojoules" ), |
223 | i18nc("unit synonyms for matching user input" , "femtojoule;femtojoules;fJ" ), |
224 | symbolString, |
225 | ki18nc("amount in units (real)" , "%1 femtojoules" ), |
226 | ki18ncp("amount in units (integer)" , "%1 femtojoule" , "%1 femtojoules" ))); |
227 | |
228 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
229 | id: Attojoule, |
230 | multiplier: 1e-18, |
231 | i18nc("energy unit symbol" , "aJ" ), |
232 | i18nc("unit description in lists" , "attojoules" ), |
233 | i18nc("unit synonyms for matching user input" , "attojoule;attojoules;aJ" ), |
234 | symbolString, |
235 | ki18nc("amount in units (real)" , "%1 attojoules" ), |
236 | ki18ncp("amount in units (integer)" , "%1 attojoule" , "%1 attojoules" ))); |
237 | |
238 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
239 | id: Zeptojoule, |
240 | multiplier: 1e-21, |
241 | i18nc("energy unit symbol" , "zJ" ), |
242 | i18nc("unit description in lists" , "zeptojoules" ), |
243 | i18nc("unit synonyms for matching user input" , "zeptojoule;zeptojoules;zJ" ), |
244 | symbolString, |
245 | ki18nc("amount in units (real)" , "%1 zeptojoules" ), |
246 | ki18ncp("amount in units (integer)" , "%1 zeptojoule" , "%1 zeptojoules" ))); |
247 | |
248 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
249 | id: Yoctojoule, |
250 | multiplier: 1e-24, |
251 | i18nc("energy unit symbol" , "yJ" ), |
252 | i18nc("unit description in lists" , "yoctojoules" ), |
253 | i18nc("unit synonyms for matching user input" , "yoctojoule;yoctojoules;yJ" ), |
254 | symbolString, |
255 | ki18nc("amount in units (real)" , "%1 yoctojoules" ), |
256 | ki18ncp("amount in units (integer)" , "%1 yoctojoule" , "%1 yoctojoules" ))); |
257 | |
258 | d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
259 | id: GuidelineDailyAmount, |
260 | multiplier: 8.3736e+06, |
261 | i18nc("energy unit symbol" , "GDA" ), |
262 | i18nc("unit description in lists" , "guideline daily amount" ), |
263 | i18nc("unit synonyms for matching user input" , "guideline daily amount;guideline daily amount;GDA" ), |
264 | symbolString, |
265 | ki18nc("amount in units (real)" , "%1 guideline daily amount" ), |
266 | ki18ncp("amount in units (integer)" , "%1 guideline daily amount" , "%1 guideline daily amount" ))); |
267 | |
268 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
269 | id: Electronvolt, |
270 | multiplier: 1.60218e-19, |
271 | i18nc("energy unit symbol" , "eV" ), |
272 | i18nc("unit description in lists" , "electronvolts" ), |
273 | i18nc("unit synonyms for matching user input" , "electronvolt;electronvolts;eV" ), |
274 | symbolString, |
275 | ki18nc("amount in units (real)" , "%1 electronvolts" ), |
276 | ki18ncp("amount in units (integer)" , "%1 electronvolt" , "%1 electronvolts" ))); |
277 | |
278 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
279 | id: JoulePerMole, |
280 | multiplier: 1.66054238581e-24, |
281 | i18nc("energy unit symbol" , "J/mol" ), |
282 | i18nc("unit description in lists" , "joule per mole" ), |
283 | i18nc("unit synonyms for matching user input" , "joule per mole;joulepermole;joulemol;jmol;j/mol" ), |
284 | symbolString, |
285 | ki18nc("amount in units (real)" , "%1 joules per mole" ), |
286 | ki18ncp("amount in units (integer)" , "%1 joule per mole" , "%1 joules per mole" ))); |
287 | |
288 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
289 | id: KiloJoulePerMole, |
290 | multiplier: 1.66054238581e-21, |
291 | i18nc("energy unit symbol" , "kJ/mol" ), |
292 | i18nc("unit description in lists" , "kilojoule per mole" ), |
293 | i18nc("unit synonyms for matching user input" , "kilojoule per mole;kilojoulepermole;kilojoule per mole;kilojoulemol;kjmol;kj/mol" ), |
294 | symbolString, |
295 | ki18nc("amount in units (real)" , "%1 kilojoules per mole" ), |
296 | ki18ncp("amount in units (integer)" , "%1 kilojoule per mole" , "%1 kilojoules per mole" ))); |
297 | |
298 | d->addUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
299 | id: Rydberg, |
300 | multiplier: 2.17987e-18, |
301 | i18nc("energy unit symbol" , "Ry" ), |
302 | i18nc("unit description in lists" , "rydbergs" ), |
303 | i18nc("unit synonyms for matching user input" , "rydberg;rydbergs;Ry" ), |
304 | symbolString, |
305 | ki18nc("amount in units (real)" , "%1 rydbergs" ), |
306 | ki18ncp("amount in units (integer)" , "%1 rydberg" , "%1 rydbergs" ))); |
307 | |
308 | d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
309 | id: Kilocalorie, |
310 | multiplier: 4186.8, |
311 | i18nc("energy unit symbol" , "kcal" ), |
312 | i18nc("unit description in lists" , "kilocalories" ), |
313 | i18nc("unit synonyms for matching user input" , "kilocalorie;kilocalories;kcal" ), |
314 | symbolString, |
315 | ki18nc("amount in units (real)" , "%1 kilocalories" ), |
316 | ki18ncp("amount in units (integer)" , "%1 kilocalorie" , "%1 kilocalories" ))); |
317 | |
318 | d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
319 | id: Btu, |
320 | multiplier: 1055.05585, |
321 | i18nc("energy unit symbol" , "BTU" ), |
322 | i18nc("unit description in lists" , "British Thermal Unit" ), |
323 | i18nc("unit synonyms for matching user input" , "Btu;BTU;Btus;BTUs" ), |
324 | symbolString, |
325 | ki18nc("amount in units (real)" , "%1 BTU" ), |
326 | ki18ncp("amount in units (integer)" , "%1 BTU" , "%1 BTU" ))); |
327 | |
328 | d->addCommonUnit(unit: UnitPrivate::makeUnit(categoryId: EnergyCategory, |
329 | id: Erg, |
330 | multiplier: 1.0e-7, |
331 | i18nc("energy unit symbol" , "Erg" ), |
332 | i18nc("unit description in lists" , "ergs" ), |
333 | i18nc("unit synonyms for matching user input" , "Erg;erg;Ergs;ergs" ), |
334 | symbolString, |
335 | ki18nc("amount in units (real)" , "%1 ergs" ), |
336 | ki18ncp("amount in units (integer)" , "%1 erg" , "%1 erg" ))); |
337 | |
338 | d->addUnit(unit: UnitPrivate::makeUnit(dd: new PhotoUnitPrivate(EnergyCategory, |
339 | PhotonWavelength, |
340 | 1.0, |
341 | i18nc("energy unit symbol" , "nm" ), |
342 | i18nc("unit description in lists" , "photon wavelength in nanometers" ), |
343 | i18nc("unit synonyms for matching user input" , "nm;photon wavelength" ), |
344 | symbolString, |
345 | ki18nc("amount in units (real)" , "%1 nanometers" ), |
346 | ki18ncp("amount in units (integer)" , "%1 nanometer" , "%1 nanometers" )))); |
347 | |
348 | return c; |
349 | } |
350 | |
351 | } // KUnitConversion namespace |
352 | |