22 #include "config-kunitconversion.h"
25 #include <QtCore/QFileInfo>
26 #include <QtCore/QDateTime>
27 #include <QtCore/QMutex>
28 #include <QtXml/QDomDocument>
32 #include <kstandarddirs.h>
34 #ifndef KUNITCONVERSION_NO_SOLID
35 #include <solid/networking.h>
38 #ifdef KUNITCONVERSION_NO_KIO
39 #include <QtNetwork/QNetworkAccessManager>
40 #include <QtNetwork/QNetworkReply>
41 #include <QtNetwork/QNetworkRequest>
44 #include <kcurrencycode.h>
46 using namespace KUnitConversion;
48 static const char URL[] =
"http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
54 setUrl(KUrl(
"http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html"));
60 KCurrencyCode::currencyCodeToName(
"EUR"),
61 i18nc(
"EUR Euro - unit synonyms for matching user input",
"euro;euros") +
62 ";EUR;" + QString::fromUtf8(
"€") +
';' + KCurrencyCode::currencyCodeToName(
"EUR"),
63 ki18nc(
"amount in units (real)",
"%1 euros"),
64 ki18ncp(
"amount in units (integer)",
"%1 euro",
"%1 euros")
68 KCurrencyCode::currencyCodeToName(
"ATS"),
69 i18nc(
"ATS Austrian Schilling - unit synonyms for matching user input",
70 "schilling;schillings") +
";ATS;" + KGlobal::locale()->countryCodeToName(
"at") +
';' +
71 KCurrencyCode::currencyCodeToName(
"ATS"),
72 ki18nc(
"amount in units (real)",
"%1 schillings"),
73 ki18ncp(
"amount in units (integer)",
"%1 schilling",
"%1 schillings")
77 KCurrencyCode::currencyCodeToName(
"BEF"),
78 i18nc(
"BEF Belgian Franc - unit synonyms for matching user input",
"franc;francs") +
79 ";BEF;" + KGlobal::locale()->countryCodeToName(
"be") +
';' +
80 KCurrencyCode::currencyCodeToName(
"BEF"),
81 ki18nc(
"amount in units (real)",
"%1 Belgian francs"),
82 ki18ncp(
"amount in units (integer)",
"%1 Belgian franc",
"%1 Belgian francs")
86 KCurrencyCode::currencyCodeToName(
"NLG"),
87 i18nc(
"NLG Netherlands Guilder - unit synonyms for matching user input",
"guilder;guilders") +
88 ";NLG;" + KGlobal::locale()->countryCodeToName(
"nl") +
';' +
89 KCurrencyCode::currencyCodeToName(
"NLG"),
90 ki18nc(
"amount in units (real)",
"%1 guilders"),
91 ki18ncp(
"amount in units (integer)",
"%1 guilder",
"%1 guilders")
95 KCurrencyCode::currencyCodeToName(
"FIM"),
96 i18nc(
"FIM Finnish Markka - unit synonyms for matching user input",
97 "markka;markkas;markkaa") +
";FIM;" +
98 KGlobal::locale()->countryCodeToName(
"fi") +
';' +
99 KCurrencyCode::currencyCodeToName(
"FIM"),
100 ki18nc(
"amount in units (real)",
"%1 markkas"),
101 ki18ncp(
"amount in units (integer)",
"%1 markka",
"%1 markkas")
105 KCurrencyCode::currencyCodeToName(
"FRF"),
106 i18nc(
"FRF French Franc - unit synonyms for matching user input",
"franc;francs") +
";FRF;" +
107 KGlobal::locale()->countryCodeToName(
"fr") +
';' +
108 KCurrencyCode::currencyCodeToName(
"FRF"),
109 ki18nc(
"amount in units (real)",
"%1 French francs"),
110 ki18ncp(
"amount in units (integer)",
"%1 French franc",
"%1 French francs")
114 KCurrencyCode::currencyCodeToName(
"DEM"),
115 i18nc(
"DEM German Mark - unit synonyms for matching user input",
"mark;marks") +
";DEM;" +
116 KGlobal::locale()->countryCodeToName(
"de") +
';' +
117 KCurrencyCode::currencyCodeToName(
"DEM"),
118 ki18nc(
"amount in units (real)",
"%1 marks"),
119 ki18ncp(
"amount in units (integer)",
"%1 mark",
"%1 marks")
123 KCurrencyCode::currencyCodeToName(
"IEP"),
124 i18nc(
"IEP Irish Pound - unit synonyms for matching user input",
"Irish pound;Irish pounds") +
125 ";IEP;" + KGlobal::locale()->countryCodeToName(
"ie") +
';' +
126 KCurrencyCode::currencyCodeToName(
"IEP"),
127 ki18nc(
"amount in units (real)",
"%1 Irish pounds"),
128 ki18ncp(
"amount in units (integer)",
"%1 Irish pound",
"%1 Irish pounds")
132 KCurrencyCode::currencyCodeToName(
"ITL"),
133 i18nc(
"ITL Italian Lira - unit synonyms for matching user input",
"lira;liras") +
";ITL;" +
134 KGlobal::locale()->countryCodeToName(
"it") +
';' +
135 KCurrencyCode::currencyCodeToName(
"ITL"),
136 ki18nc(
"amount in units (real)",
"%1 Italian lira"),
137 ki18ncp(
"amount in units (integer)",
"%1 Italian lira",
"%1 Italian lira")
141 KCurrencyCode::currencyCodeToName(
"LUF"),
142 i18nc(
"LUF Luxembourgish Franc - unit synonyms for matching user input",
"franc;francs") +
143 ";LUF;" + KGlobal::locale()->countryCodeToName(
"lu") +
';' +
144 KCurrencyCode::currencyCodeToName(
"LUF"),
145 ki18nc(
"amount in units (real)",
"%1 Luxembourgish francs"),
146 ki18ncp(
"amount in units (integer)",
"%1 Luxembourgish franc",
"%1 Luxembourgish francs")
150 KCurrencyCode::currencyCodeToName(
"PTE"),
151 i18nc(
"PTE Portugeuse Escudo - unit synonyms for matching user input",
"escudo;escudos") +
152 ";PTE;" + KGlobal::locale()->countryCodeToName(
"pt") +
';' +
153 KCurrencyCode::currencyCodeToName(
"PTE"),
154 ki18nc(
"amount in units (real)",
"%1 escudos"),
155 ki18ncp(
"amount in units (integer)",
"%1 escudo",
"%1 escudos")
159 KCurrencyCode::currencyCodeToName(
"ESP"),
160 i18nc(
"ESP Spanish Pesetas - unit synonyms for matching user input",
"peseta;pesetas") +
161 ";ESP;" + KGlobal::locale()->countryCodeToName(
"es") +
';' +
162 KCurrencyCode::currencyCodeToName(
"ESP"),
163 ki18nc(
"amount in units (real)",
"%1 pesetas"),
164 ki18ncp(
"amount in units (integer)",
"%1 peseta",
"%1 pesetas")
168 KCurrencyCode::currencyCodeToName(
"GRD"),
169 i18nc(
"GRD Greek Drachma - unit synonyms for matching user input",
"drachma;drachmas") +
170 ";GRD;" + KGlobal::locale()->countryCodeToName(
"gr") +
';' +
171 KCurrencyCode::currencyCodeToName(
"GRD"),
172 ki18nc(
"amount in units (real)",
"%1 drachmas"),
173 ki18ncp(
"amount in units (integer)",
"%1 drachma",
"%1 drachmas")
177 KCurrencyCode::currencyCodeToName(
"SIT"),
178 i18nc(
"SIT Slovenian Tolar - unit synonyms for matching user input",
"tolar;tolars;tolarjev") +
";SIT;" +
179 KGlobal::locale()->countryCodeToName(
"si") +
';' + KCurrencyCode::currencyCodeToName(
"SIT"),
180 ki18nc(
"amount in units (real)",
"%1 tolars"),
181 ki18ncp(
"amount in units (integer)",
"%1 tolar",
"%1 tolars")
185 KCurrencyCode::currencyCodeToName(
"CYP"),
186 i18nc(
"CYP Cypriot Pound - unit synonyms for matching user input",
187 "Cypriot pound;Cypriot pounds") +
";CYP;" +
188 KGlobal::locale()->countryCodeToName(
"cy") +
';' +
189 KCurrencyCode::currencyCodeToName(
"CYP"),
190 ki18nc(
"amount in units (real)",
"%1 Cypriot pounds"),
191 ki18ncp(
"amount in units (integer)",
"%1 Cypriot pound",
"%1 Cypriot pounds")
195 KCurrencyCode::currencyCodeToName(
"MTL"),
196 i18nc(
"MTL Maltese Lira - unit synonyms for matching user input",
"Maltese lira") +
";MTL;" +
197 KGlobal::locale()->countryCodeToName(
"mt") +
';' + KCurrencyCode::currencyCodeToName(
"MTL"),
198 ki18nc(
"amount in units (real)",
"%1 Maltese lira"),
199 ki18ncp(
"amount in units (integer)",
"%1 Maltese lira",
"%1 Maltese lira")
203 KCurrencyCode::currencyCodeToName(
"SKK"),
204 i18nc(
"SKK Slovak Koruna - unit synonyms for matching user input",
205 "koruna;korunas;koruny;korun") +
";SKK;" +
206 KGlobal::locale()->countryCodeToName(
"sk") +
';' +
207 KCurrencyCode::currencyCodeToName(
"SKK"),
208 ki18nc(
"amount in units (real)",
"%1 Slovak korunas"),
209 ki18ncp(
"amount in units (integer)",
"%1 Slovak koruna",
"%1 Slovak korunas")
215 KCurrencyCode::currencyCodeToName(
"USD"),
216 i18nc(
"USD United States Dollars - unit synonyms for matching user input",
"dollar;dollars") +
217 ";USD;$;" + KGlobal::locale()->countryCodeToName(
"us") +
';' +
218 KCurrencyCode::currencyCodeToName(
"USD"),
219 ki18nc(
"amount in units (real)",
"%1 United States dollars"),
220 ki18ncp(
"amount in units (integer)",
"%1 United States dollar",
"%1 United States dollars")
224 KCurrencyCode::currencyCodeToName(
"JPY"),
225 i18nc(
"JPY Japanese Yen - unit synonyms for matching user input",
"yen") +
226 ";JPY;" + QString::fromUtf8(
"¥") +
';' +
227 KGlobal::locale()->countryCodeToName(
"jp") +
';' + KCurrencyCode::currencyCodeToName(
"JPY"),
228 ki18nc(
"amount in units (real)",
"%1 yen"),
229 ki18ncp(
"amount in units (integer)",
"%1 yen",
"%1 yen")
233 KCurrencyCode::currencyCodeToName(
"BGN"),
234 i18nc(
"BGN Bulgarian Lev - unit synonyms for matching user input",
"lev;leva") +
";BGN;" +
235 KGlobal::locale()->countryCodeToName(
"bg") +
';' + KCurrencyCode::currencyCodeToName(
"BGN"),
236 ki18nc(
"amount in units (real)",
"%1 leva"),
237 ki18ncp(
"amount in units (integer)",
"%1 lev",
"%1 leva")
241 KCurrencyCode::currencyCodeToName(
"CZK"),
242 i18nc(
"CZK Czech Koruna - unit synonyms for matching user input",
"koruna;korunas") +
243 ";CZK;" + KGlobal::locale()->countryCodeToName(
"cz") +
';' +
244 KCurrencyCode::currencyCodeToName(
"CZK"),
245 ki18nc(
"amount in units (real)",
"%1 Czech korunas"),
247 ki18ncp(
"amount in units (integer)",
"%1 Czech koruna",
"%1 Czech korunas")
251 KCurrencyCode::currencyCodeToName(
"DKK"),
252 i18nc(
"DKK Danish Krone - unit synonyms for matching user input",
253 "Danish krone;Danish kroner") +
";DKK;" +
254 KGlobal::locale()->countryCodeToName(
"dk") +
';' +
255 KCurrencyCode::currencyCodeToName(
"DKK"),
256 ki18nc(
"amount in units (real)",
"%1 Danish kroner"),
257 ki18ncp(
"amount in units (integer)",
"%1 Danish krone",
"%1 Danish kroner")
261 KCurrencyCode::currencyCodeToName(
"EEK"),
262 i18nc(
"EEK Estonian Kroon - unit synonyms for matching user input",
"kroon;kroons;krooni") +
263 ";EEK;" + KGlobal::locale()->countryCodeToName(
"ee") +
';' +
264 KCurrencyCode::currencyCodeToName(
"EEK"),
265 ki18nc(
"amount in units (real)",
"%1 kroons"),
266 ki18ncp(
"amount in units (integer)",
"%1 kroon",
"%1 kroons")
270 KCurrencyCode::currencyCodeToName(
"GBP"),
271 i18nc(
"GBP British Pound - unit synonyms for matching user input",
272 "pound;pounds;pound sterling;pounds sterling") +
273 ";GBP;" + QString::fromUtf8(
"£") +
';' +
274 KGlobal::locale()->countryCodeToName(
"gb") +
';' +
275 KCurrencyCode::currencyCodeToName(
"GBP"),
276 ki18nc(
"amount in units (real)",
"%1 pounds sterling"),
277 ki18ncp(
"amount in units (integer)",
"%1 pound sterling",
"%1 pounds sterling")
281 KCurrencyCode::currencyCodeToName(
"HUF"),
282 i18nc(
"HUF hungarian Forint - unit synonyms for matching user input",
"forint") +
";HUF;" +
283 KGlobal::locale()->countryCodeToName(
"hu") +
';' +
284 KCurrencyCode::currencyCodeToName(
"HUF"),
285 ki18nc(
"amount in units (real)",
"%1 forint"),
286 ki18ncp(
"amount in units (integer)",
"%1 forint",
"%1 forint")
290 KCurrencyCode::currencyCodeToName(
"LTL"),
291 i18nc(
"LTL Lithuanian Litas - unit synonyms for matching user input",
"litas;litai;litu") +
292 ";LTL;" + KGlobal::locale()->countryCodeToName(
"lt") +
';' +
293 KCurrencyCode::currencyCodeToName(
"LTL"),
294 ki18nc(
"amount in units (real)",
"%1 litas"),
295 ki18ncp(
"amount in units (integer)",
"%1 litas",
"%1 litai")
299 KCurrencyCode::currencyCodeToName(
"LVL"),
300 i18nc(
"LVL Latvian Lats - unit synonyms for matching user input",
"lats;lati") +
";LVL;" +
301 KGlobal::locale()->countryCodeToName(
"lv") +
';' + KCurrencyCode::currencyCodeToName(
"LVL"),
302 ki18nc(
"amount in units (real)",
"%1 lati"),
303 ki18ncp(
"amount in units (integer)",
"%1 lats",
"%1 lati")
307 KCurrencyCode::currencyCodeToName(
"PLN"),
308 i18nc(
"PLN Polish Zloty - unit synonyms for matching user input",
"zloty;zlotys;zloties") +
309 ";PLN;" + KGlobal::locale()->countryCodeToName(
"pl") +
';' +
310 KCurrencyCode::currencyCodeToName(
"PLN"),
311 ki18nc(
"amount in units (real)",
"%1 zlotys"),
312 ki18ncp(
"amount in units (integer)",
"%1 zloty",
"%1 zlotys")
316 KCurrencyCode::currencyCodeToName(
"RON"),
317 i18nc(
"RON Roumanian Leu - unit synonyms for matching user input",
"leu;lei") +
";RON;" +
318 KGlobal::locale()->countryCodeToName(
"ro") +
';' +
319 KCurrencyCode::currencyCodeToName(
"RON"),
320 ki18nc(
"amount in units (real)",
"%1 lei"),
321 ki18ncp(
"amount in units (integer)",
"%1 leu",
"%1 lei")
325 KCurrencyCode::currencyCodeToName(
"SEK"),
326 i18nc(
"SEK Swedish Krona - unit synonyms for matching user input",
"krona;kronor") +
";SEK;" +
327 KGlobal::locale()->countryCodeToName(
"se") +
';' +
328 KCurrencyCode::currencyCodeToName(
"SEK"),
329 ki18nc(
"amount in units (real)",
"%1 kronor"),
330 ki18ncp(
"amount in units (integer)",
"%1 krona",
"%1 kronor")
334 KCurrencyCode::currencyCodeToName(
"CHF"),
335 i18nc(
"CHF Swiss Francs - unit synonyms for matching user input",
"franc;francs") +
";CHF;" +
336 KGlobal::locale()->countryCodeToName(
"ch") +
';' +
337 KCurrencyCode::currencyCodeToName(
"CHF"),
338 ki18nc(
"amount in units (real)",
"%1 Swiss francs"),
339 ki18ncp(
"amount in units (integer)",
"%1 Swiss franc",
"%1 Swiss francs")
343 KCurrencyCode::currencyCodeToName(
"NOK"),
344 i18nc(
"Norwegian Krone - unit synonyms for matching user input",
345 "Norwegian krone;Norwegian kroner") +
";NOK;" +
346 KGlobal::locale()->countryCodeToName(
"no") +
';' +
347 KCurrencyCode::currencyCodeToName(
"NOK"),
348 ki18nc(
"amount in units (real)",
"%1 Norwegian kroner"),
349 ki18ncp(
"amount in units (integer)",
"%1 Norwegian krone",
"%1 Norwegian kroner")
353 KCurrencyCode::currencyCodeToName(
"HRK"),
354 i18nc(
"HRK Croatian Kuna - unit synonyms for matching user input",
"kuna;kune") +
";HRK;" +
355 KGlobal::locale()->countryCodeToName(
"hr") +
';' +
356 KCurrencyCode::currencyCodeToName(
"HRK"),
357 ki18nc(
"amount in units (real)",
"%1 kune"),
358 ki18ncp(
"amount in units (integer)",
"%1 kuna",
"%1 kune")
362 KCurrencyCode::currencyCodeToName(
"RUB"),
363 i18nc(
"RUB Russsian Ruble - unit synonyms for matching user input",
364 "ruble;rubles;rouble;roubles") +
";RUB;" +
365 KGlobal::locale()->countryCodeToName(
"ru") +
';' +
366 KCurrencyCode::currencyCodeToName(
"RUB"),
367 ki18nc(
"amount in units (real)",
"%1 rubles"),
368 ki18ncp(
"amount in units (integer)",
"%1 ruble",
"%1 rubles")
372 KCurrencyCode::currencyCodeToName(
"TRY"),
373 i18nc(
"TRY Turkish Lira - unit synonyms for matching user input",
"lira") +
";TRY;" +
374 KGlobal::locale()->countryCodeToName(
"tr") +
';' +
375 KCurrencyCode::currencyCodeToName(
"TRY"),
376 ki18nc(
"amount in units (real)",
"%1 Turkish lira"),
377 ki18ncp(
"amount in units (integer)",
"%1 Turkish lira",
"%1 Turkish lira")
381 KCurrencyCode::currencyCodeToName(
"AUD"),
382 i18nc(
"AUD Australian Dollar - unit synonyms for matching user input",
383 "Australian dollar;Australian dollars") +
";AUD;" +
384 KGlobal::locale()->countryCodeToName(
"au") +
';' +
385 KCurrencyCode::currencyCodeToName(
"AUD"),
386 ki18nc(
"amount in units (real)",
"%1 Australian dollars"),
387 ki18ncp(
"amount in units (integer)",
"%1 Australian dollar",
"%1 Australian dollars")
391 KCurrencyCode::currencyCodeToName(
"BRL"),
392 i18nc(
"BRL Brazillian Real - unit synonyms for matching user input",
"real;reais") +
393 ";BRL;" + KGlobal::locale()->countryCodeToName(
"br") +
';' +
394 KCurrencyCode::currencyCodeToName(
"BRL"),
395 ki18nc(
"amount in units (real)",
"%1 reais"),
396 ki18ncp(
"amount in units (integer)",
"%1 real",
"%1 reais")
400 KCurrencyCode::currencyCodeToName(
"CAD"),
401 i18nc(
"Canadian Dollar - unit synonyms for matching user input",
402 "Canadian dollar;Canadian dollars") +
";CAD;" +
403 KGlobal::locale()->countryCodeToName(
"ca") +
';' +
404 KCurrencyCode::currencyCodeToName(
"CAD"),
405 ki18nc(
"amount in units (real)",
"%1 Canadian dollars"),
406 ki18ncp(
"amount in units (integer)",
"%1 Canadian dollar",
"%1 Canadian dollars")
410 KCurrencyCode::currencyCodeToName(
"CNY"),
411 i18nc(
"Chinese Yuan - unit synonyms for matching user input",
"yuan") +
";CNY;" +
412 KGlobal::locale()->countryCodeToName(
"cn") +
';' +
413 KCurrencyCode::currencyCodeToName(
"CNY"),
414 ki18nc(
"amount in units (real)",
"%1 yuan"),
415 ki18ncp(
"amount in units (integer)",
"%1 yuan",
"%1 yuan")
419 KCurrencyCode::currencyCodeToName(
"HKD"),
420 i18nc(
"Hong Kong Dollar - unit synonyms for matching user input",
421 "Hong Kong dollar;Hong Kong dollars") +
";HKD;" +
422 KGlobal::locale()->countryCodeToName(
"hk") +
';' +
423 KCurrencyCode::currencyCodeToName(
"HKD"),
424 ki18nc(
"amount in units (real)",
"%1 Hong Kong dollars"),
425 ki18ncp(
"amount in units (integer)",
"%1 Hong Kong dollar",
"%1 Hong Kong dollars")
429 KCurrencyCode::currencyCodeToName(
"IDR"),
430 i18nc(
"IDR Indonesian Rupiah - unit synonyms for matching user input",
"rupiah;rupiahs") +
431 ";IDR;" + KGlobal::locale()->countryCodeToName(
"id") +
';' +
432 KCurrencyCode::currencyCodeToName(
"IDR"),
433 ki18nc(
"amount in units (real)",
"%1 rupiahs"),
434 ki18ncp(
"amount in units (integer)",
"%1 rupiah",
"%1 rupiahs")
438 KCurrencyCode::currencyCodeToName(
"INR"),
439 i18nc(
"INR Indian Rupee - unit synonyms for matching user input",
"rupee;rupees") +
";INR;" +
440 KGlobal::locale()->countryCodeToName(
"in") +
';' +
441 KCurrencyCode::currencyCodeToName(
"INR"),
442 ki18nc(
"amount in units (real)",
"%1 rupees"),
443 ki18ncp(
"amount in units (integer)",
"%1 rupee",
"%1 rupees")
447 KCurrencyCode::currencyCodeToName(
"KRW"),
448 i18nc(
"KRW Korean Won - unit synonyms for matching user input",
"won") +
";KRW;" +
449 KGlobal::locale()->countryCodeToName(
"kr") +
';' +
450 KCurrencyCode::currencyCodeToName(
"KRW"),
451 ki18nc(
"amount in units (real)",
"%1 won"),
452 ki18ncp(
"amount in units (integer)",
"%1 won",
"%1 won")
456 KCurrencyCode::currencyCodeToName(
"MXN"),
457 i18nc(
"MXN Mexican Peso - unit synonyms for matching user input",
458 "Mexican peso;Mexican pesos") +
";MXN;" +
459 KGlobal::locale()->countryCodeToName(
"mx") +
';' +
460 KCurrencyCode::currencyCodeToName(
"MXN"),
461 ki18nc(
"amount in units (real)",
"%1 Mexican pesos"),
462 ki18ncp(
"amount in units (integer)",
"%1 Mexican peso",
"%1 Mexican pesos")
466 KCurrencyCode::currencyCodeToName(
"MYR"),
467 i18nc(
"MYR Malasian Ringgit - unit synonyms for matching user input",
"ringgit;ringgits") +
468 ";MYR;" + KGlobal::locale()->countryCodeToName(
"my") +
';' +
469 KCurrencyCode::currencyCodeToName(
"MYR"),
470 ki18nc(
"amount in units (real)",
"%1 ringgit"),
471 ki18ncp(
"amount in units (integer)",
"%1 ringgit",
"%1 ringgit")
475 KCurrencyCode::currencyCodeToName(
"NZD"),
476 i18nc(
"NZD New Zealand Dollar - unit synonyms for matching user input",
477 "New Zealand dollar;New Zealand dollars") +
";NZD;" +
478 KGlobal::locale()->countryCodeToName(
"nz") +
';' +
479 KCurrencyCode::currencyCodeToName(
"NZD"),
480 ki18nc(
"amount in units (real)",
"%1 New Zealand dollars"),
481 ki18ncp(
"amount in units (integer)",
"%1 New Zealand dollar",
"%1 New Zealand dollars")
485 KCurrencyCode::currencyCodeToName(
"PHP"),
486 i18nc(
"PHP Philippine Peso - unit synonyms for matching user input",
487 "Philippine peso;Philippine pesos") +
";PHP;" +
488 KGlobal::locale()->countryCodeToName(
"ph") +
';' +
489 KCurrencyCode::currencyCodeToName(
"PHP"),
490 ki18nc(
"amount in units (real)",
"%1 Philippine pesos"),
491 ki18ncp(
"amount in units (integer)",
"%1 Philippine peso",
"%1 Philippine pesos")
495 KCurrencyCode::currencyCodeToName(
"SGD"),
496 i18nc(
"SGD Singapore Dollar - unit synonyms for matching user input",
497 "Singapore dollar;Singapore dollars") +
";SGD;" +
498 KGlobal::locale()->countryCodeToName(
"sg") +
';' +
499 KCurrencyCode::currencyCodeToName(
"SGD"),
500 ki18nc(
"amount in units (real)",
"%1 Singapore dollars"),
501 ki18ncp(
"amount in units (integer)",
"%1 Singapore dollar",
"%1 Singapore dollars")
505 KCurrencyCode::currencyCodeToName(
"THB"),
506 i18nc(
"THB Thai Baht - unit synonyms for matching user input",
"baht") +
";THB;" +
507 KGlobal::locale()->countryCodeToName(
"th") +
';' +
508 KCurrencyCode::currencyCodeToName(
"THB"),
509 ki18nc(
"amount in units (real)",
"%1 baht"),
510 ki18ncp(
"amount in units (integer)",
"%1 baht",
"%1 baht")
514 KCurrencyCode::currencyCodeToName(
"ZAR"),
515 i18nc(
"South African Rand - unit synonyms for matching user input",
"rand") +
";ZAR;" +
516 KGlobal::locale()->countryCodeToName(
"za") +
';' +
517 KCurrencyCode::currencyCodeToName(
"ZAR"),
518 ki18nc(
"amount in units (real)",
"%1 rand"),
519 ki18ncp(
"amount in units (integer)",
"%1 rand",
"%1 rand")
524 m_cache = KStandardDirs::locateLocal(
"data",
"libkunitconversion/currency.xml");
533 QFileInfo info(m_cache);
534 if (!info.exists() || info.lastModified().secsTo(QDateTime::currentDateTime()) > 86400) {
535 #ifndef KUNITCONVERSION_NO_SOLID
536 Solid::Networking::Status status = Solid::Networking::status();
537 if (status == Solid::Networking::Connected || status == Solid::Networking::Unknown ) {
541 kDebug() <<
"Getting currency info from net:" <<
URL;
551 kDebug() <<
"Removed previous cache:" << QFile::remove(m_cache);
552 #ifndef KUNITCONVERSION_NO_KIO
553 if (KProcess::execute(QStringList() <<
"kioclient" <<
"copy" <<
"--noninteractive" <<
URL << m_cache) == 0) {
557 QNetworkAccessManager manager;
558 QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(
URL)));
559 QFile cacheFile(m_cache);
560 cacheFile.open(QFile::WriteOnly);
561 while (!reply->error() && !reply->atEnd()) {
562 if (reply->bytesAvailable()>0
563 || reply->waitForReadyRead(500)) {
564 cacheFile.write(reply->readAll());
575 if (file.open(QIODevice::ReadOnly)) {
577 if (doc.setContent(&file,
false) ) {
578 QDomNodeList list = doc.elementsByTagName(
"Cube");
579 for (
int i = 0; i < list.count(); ++i) {
580 const QDomElement e = list.item(i).toElement();
581 if (e.hasAttribute(
"currency")) {
584 u->setMultiplier(1.0 / e.attribute(
"rate").toDouble());
592 Value v = UnitCategory::convert(value, to);
void setMostCommonUnits(const QList< int > &units)
void setName(const QString &name)
void setDescription(const QString &desc)
#define UP(id, m, s, d, sy, r, i)
virtual KUnitConversion::Value convert(const KUnitConversion::Value &value, KUnitConversion::UnitPtr to)
void setDefaultUnit(UnitPtr defaultUnit)
KSharedPtr< Unit > UnitPtr
UnitPtr unit(const QString &s) const
Return unit for string.
void setUrl(const KUrl &url)
void setSymbolStringFormat(const KLocalizedString &symbolStringFormat)
#define U(id, m, s, d, sy, r, i)