Refactor KoUnit

Authored by tymond on Mar 5 2019, 10:31 AM.


Group Reviewers
R37:9d5baac8ad84: Refactor KoUnit

This commit fixes two problems in KoUnit:
(1) two functions named differently while doing
nearly exactly the same thing (ptToUnit, toUserValue)
and the difference in the name or arguments of functions
not showing the difference in the results,
(2) repeated constant values in functions
called to[Unit] (i.e. toMillimeters).
This commit is not to cause any difference in behaviour
(including in particular converting and rounding values)
and contains unit tests to test that.

Test Plan
  • created unit test to test the difference in conversions

(should not none).

  • all the places where the difference in functions naming

caused changes in files other than [Test]KoUnit.h/.cpp

Diff Detail

R37 Krita
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
tymond created this revision.Mar 5 2019, 10:31 AM
Restricted Application added a reviewer: Krita. · View Herald TranscriptMar 5 2019, 10:31 AM
Restricted Application added a project: Krita. · View Herald Transcript
tymond requested review of this revision.Mar 5 2019, 10:31 AM

I removed all to[Unit] functions altogether, so now every time you want a conversion you need to create a KoUnit. I can change it though so the to[Unit] functions would use toUserValue functions.

If you have any comments about coding style or anything, please tell me, I'll change it and keep in mind for the future. While I can see that things I said in the commit message were a "bad" coding style (a bit error-prone), I can't be sure I know all nuances, especially if Krita code aims for a specific coding style that isn't achieved just yet so I can't even follow the code that already exists there.

rempt accepted this revision.Mar 5 2019, 3:20 PM
rempt added a subscriber: rempt.

Apart from very minor niggles, I think that this a very nice improvement on the ancient code.


I prefer spaces around arithmetic operators


Okay, space between if and ( and always use curly braces. The style guide is here:

This revision is now accepted and ready to land.Mar 5 2019, 3:20 PM
tymond updated this revision to Diff 53221.Mar 5 2019, 5:12 PM

Fix coding style in KoUnit

It contains only coding style fixes
in the KoUnit refactored code.

This revision was automatically updated to reflect the committed changes.