Hi Klaas, Am Mittwoch, 6. Januar 2016, 10:06:48 schrieb Klaas Freitag: > On 06.01.2016 08:12, Friedrich W. H. Kossebau wrote: > > QUESTIONS > > > > How have developers of e.g. Skrooge & KMyMoney approached the issue of > > conversion of currency values to/from strings? > > The outcome of the KDE finance group so far is a lib called alkimia > which was set up by the KMyMoney people, which is awesome. There you > find a very powerful class AlkValue for financial numbers. And this one > has a constructor that parses a QString. Maybe that is already enough > for parsing?!
Ah, interesting, thanks for the pointer. Had a quick look, but seems the parsing does not handle any currency symbols/terms, so sadly not up for the requirements we have in Sheets and Plan (e.g. things like "15 EUR" and "€ 15.10" should be correctly parsed in German locale, perhaps even "DM" variants additionally. And bitcoin & co. and regional non-state currencies would be nice to see supported as well in some way). > About formatting, yes, QLocale is really limited, found that out during > my KF5 porting actions of Kraft as well. Not only for currency, but also > for dates. Calligra Plan I managed to port completely to QLocale's dates API, as using just the gregorian calendar was no regression. Well, modulo a few locale-dependent bugs the unit tests are showing on CI, it is anything but an easy port from KDateTime::Spec & Co. to Qt::TimeSpec... :) > > Do you know about any activities to improve QLocale here? > > > > 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 > > Yes, and I do not konw how to solve that yet. What you described above > might be the best option, but, as said, doesn't that apply to dates as > well? Only needed for dates if one deals with non-gregorian calendars, from what I understood. Not an expert though, only diving into this now. > On a site note, KDE4 Kraft can deal with two different Locales, the one > it was started with, and one for the specific document. That way you can > write a lets say dutch invoice on a german desktop. That is nice, but I > almost decided to drop that feature for KF5. Would be great if I could > keep it. One can create multiple QLocale instances and specify the locale for each, so I see nothing preventing such a thing :) Calligra apps do they same, the UI locale does not need to be the same as for the content. Whole documents can have a locale assigned, and then even subparts different ones again. Cheers Friedrich _______________________________________________ calligra-devel mailing list calligra-devel@kde.org https://mail.kde.org/mailman/listinfo/calligra-devel