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.
Details
- Reviewers
rempt - Group Reviewers
Krita - Commits
- R37:9d5baac8ad84: Refactor KoUnit
- 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
- Repository
- R37 Krita
- Branch
- tiar/kounit-refactoring (branched from master)
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 9205 Build 9223: arc lint + arc unit
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.
Apart from very minor niggles, I think that this a very nice improvement on the ancient code.
libs/odf/KoUnit.cpp | ||
---|---|---|
172 | I prefer spaces around arithmetic operators | |
202 | Okay, space between if and ( and always use curly braces. The style guide is here: https://community.kde.org/Policies/Kdelibs_Coding_Style |
Fix coding style in KoUnit
It contains only coding style fixes
in the KoUnit refactored code.