Question about currencies
john at layt.net
Tue May 6 11:29:13 BST 2014
On 5 May 2014 23:03, Alvaro Soliverez <asoliverez at kde.org> wrote:
> Hi all,
> I have a question about the currency features. In KLocale, you can get
> KCurrencyCode for the current locale, which is fine.
> Now, for KMyMoney we need to get the list of all currencies for all
> countries (since a user usually deals with multiple currencies).
> I haven't found an API for this, only the KLocale one for current
> locale. Is there any other way to access the list of currencies?
Yes there is api, you need the static method
KCurrencyCode::allCurrencyCodesList() which by default returns *all*
currency codes available regardless of status, but you can pass in the
status you require, e.g. usually just ActiveStatus. Other
KCurrencyCode static methods are isValid() to check if a given string
code is supported, and currencyCodeToName() to get the currency name
for any valid code in any KDE supported language.
Note you can also get a list of preferred currencies for a given
locale using KLocale::currencyCodeList().
As Aleix and Alex note, KCurrencyCode will be deprecated for KF5 as it
is too tightly bound with KLocale, but a very similar API will be
implemented in a new tier 1 framework KStandards that will support all
sorts of standard ISO codes like Currency, Country, Language, etc
using json data files. Formatting and parsing will be done using
QLocale, with KStandards adding all the extra features that Qt is
unwilling to provide.
More information about the kde-core-devel