[Kde-finance-apps] Porting KLocale::formatMoney()/readMoney() to Qt5/KF5, best practise?
Thomas Baumgart
thb at net-bembel.de
Thu Jan 7 08:14:10 UTC 2016
Hi Friedrich et al.
On Wednesday 06 January 2016 08:12:49 Friedrich W. H. Kossebau wrote:
> Hi developers of finance apps & Calligra Sheets & Calligra Plan,
which includes me (from the KMyMoney side).
Sorry for answering a bit late, but I am currently swamped with work work and
wanted to get some details into this answer.
> (please keep cross-posting to both ml for now)
>
> I (not only with my Calligra developer hat on) would like to collect
> experiences and ideas for conversion of curreny values to and from
> strings when using Qt5/KF5, especially when porting from kdelibs4's
> KLocale.
>
>
> PROBLEM
>
> QLocale is rather limited (as of Qt 5.5):
> - no currency string parsing method
> - string formatting method toCurrencyString() does not allow
> to control precision
>
> KLocale and its currency related methods seem the last blocker to get
> rid of kdelibs4support in Calligra in the Qt5/KF5 port. Plan uses them
> for handling the costs of resources, and Sheets for the currency
> formatted cells. And both limitations are a blocker.
>
>
> APPROACHES
>
> Long term ideally QLocale gets support in its API for that. So we
> developers of currency data handling software should organize and
> draft an API.
>
> First and short term though, until some released & wide-spread Qt
> version has the improved QLocale, I am looking for a solution
> independent of QLocale.
> Most obvious might be to duplicate all currency things from KLocale,
> which would also include duplicating the database with all currency
> formatting data. This is what I would plan to do if there is no better
> idea.
> Especially the database duplication is painful though, I would like to
> avoid at least that if possible.
>
>
> QUESTIONS
>
> How have developers of e.g. Skrooge & KMyMoney approached the issue of
> conversion of currency values to/from strings?
Formatting is done in KMyMoney as part of the MyMoneyMoney class (which is in
fact the father of AlkValue and now is derived from it since we have the
Alkmia library). It provides setters to control the format to some extent
which are used by the application (which in fact gets the resp. values from
KGlobal::locale() in KDE4 land).
The list of currencies is part of KMyMoney. See
https://lxr.kde.org/source/extragear/office/kmymoney/kmymoney/views/kmymoneyview.cpp#1490
and
https://lxr.kde.org/source/extragear/office/kmymoney/kmymoney/views/kmymoneyview.cpp#1686
KMyMoney also handles conversion rates between currencies, which are variable
by their nature. The ancient currencies (e.g. DM, FF, etc.) which are replaced
by new ones (EUR in this example) have a fixed conversion rate.
As one can see in
https://lxr.kde.org/source/extragear/office/kmymoney/kmymoney/views/kmymoneyview.cpp#1510
artificial currencies are no problem with this setup.
> Do you know about any activities to improve QLocale here?
Not that I know of, but would certainly be interested.
For KMyMoney (as well as for Skrooge) it is important to display values in
different currencies (text and symbol form) simultaneously to provide multi-
currency support. I am not sure if there is a need to have different number
formats (as in negative numbers as -xxx and (xxx) ) at the same time. The same
applies for date and time information.
The conversion from a string to a value is AFAICT somewhat not related to
currencies within KMyMoney, as the currency is tied to the account object
where the value is imported.
Date formats OTOH is very important for imports, since we receive all kinds of
formats simultaneously from various sources using online banking and exchange
rate services.
Hope that helps.
> Seems that Calligra apps Plan & Sheets are the only KDE apps using
> KLocale::readMoney() ?
> https://lxr.kde.org/ident?v=stable-qt4&_i=readMoney&_remember=1
>
> But KLocale::formatMoney() might be used by KMyMoney, Skrooge, Kraft &
> others (did not check though if not custom code):
> https://lxr.kde.org/ident?v=stable-qt4&_i=formatMoney&_remember=1
>
> Cheers
> Friedrich
> _______________________________________________
> Kde-finance-apps mailing list
> Kde-finance-apps at kde.org
> https://mail.kde.org/mailman/listinfo/kde-finance-apps
--
Regards
Thomas Baumgart
GPG-FP: E55E D592 F45F 116B 8429 4F99 9C59 DB40 B75D D3BA
-------------------------------------------------------------
Linux - Life is too short for reboots
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 225 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-finance-apps/attachments/20160107/201c4783/attachment.sig>
More information about the Kde-finance-apps
mailing list