Review Request 114187: KFormat - Add new KFormat class

John Layt jlayt at kde.org
Thu Nov 28 20:00:58 UTC 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/114187/
-----------------------------------------------------------

Review request for KDE Frameworks, Albert Astals Cid, David Faure, and Kevin Ottens.


Repository: kdelibs


Description
-------

KFormat - Add new KFormat class

KLocale offers a number of extra formatting options not yet available
in Qt.  The KFormat class adds these options to KCoreAddons:

* formatByteSize()
* formatDuration()
* formatDecimalDuration()
* formatSpelloutDuration()
* formatRelativeDate()
* formatRelativeDateTime()

The KFormat class can be initialised with any QLocale to use in the
date and number formatting, or the default locale can be easily
accessed via KFormat():

  QString result = KFormat().formatDuration(1000);

----------------------------------------

There's a few things that need looking at here.  The main one is the translation stuff because I had to convert from using ki18n to tr and it may have lost something in the process.  In particular it looks like we'll actually need an en_US translation done to get the plurals right?  If we can't make tr() work for these we'll have to move the class into  k18n.  The second is to look at the formatting options provided and decide if they are actually useful to have.  The third is to confirm that the design is OK, I did think about making these simple static methods with an extra parm for QLocale, but I think this approach offers more future flexibility, and writing KFormat().formatDuration() is just as convenient as KFormat::formatDuration().


Diffs
-----

  tier1/kcoreaddons/autotests/CMakeLists.txt c8043576181e7d06663195d017be930d0bdcbde9 
  tier1/kcoreaddons/autotests/kformattest.h PRE-CREATION 
  tier1/kcoreaddons/autotests/kformattest.cpp PRE-CREATION 
  tier1/kcoreaddons/src/lib/CMakeLists.txt 638525f7b719bcd0bc1dfdf94debd51296521334 
  tier1/kcoreaddons/src/lib/util/kformat.h PRE-CREATION 
  tier1/kcoreaddons/src/lib/util/kformat.cpp PRE-CREATION 
  tier1/kcoreaddons/src/lib/util/kformatprivate.cpp PRE-CREATION 
  tier1/kcoreaddons/src/lib/util/kformatprivate_p.h PRE-CREATION 

Diff: http://git.reviewboard.kde.org/r/114187/diff/


Testing
-------

Autotests copied from KLocale tests and improved.


Thanks,

John Layt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20131128/3f884cdd/attachment.html>


More information about the Kde-frameworks-devel mailing list