Replace "unit" property option with "suffix"; add "prefix", support in double/integer/composed types
ClosedPublic

Authored by staniek on Apr 13 2017, 1:18 AM.

Details

Summary
  • Replace "unit" property option with "suffix"
  • add "prefix", support in double/integer/composed types
  • Values no longer are converted based on units, users have to convert after getting property values and before setting values.
  • Unit-related code has been removed
  • Also update example app by adding more cases with suffixes and prefixes.
  • Update docs for options

Suffixes are nicely displayed also in parent rows of composed properties and in inactive rows:

Prefix, suffix or prefix+suffix can be specified, e.g.

Note: we will have to port KReport 3.1 and Kexi 3.1 to this (convert units when needed). They build but no conversion is performed on loading/saving.

SINCE:3.1.0

Test Plan
  • try KPropertyExample - the new Prefixes / Suffixes group

Diff Detail

Repository
R13 KProperty
Branch
arcpatch-D5419
Lint
No Linters Available
Unit
No Unit Test Coverage
staniek created this revision.Apr 13 2017, 1:18 AM
Restricted Application added a project: KProperty. · View Herald TranscriptApr 13 2017, 1:18 AM
staniek edited the summary of this revision. (Show Details)Apr 13 2017, 1:20 AM
staniek edited the test plan for this revision. (Show Details)
staniek edited the summary of this revision. (Show Details)
piggz added inline comments.Apr 14 2017, 3:56 PM
src/KPropertyUtils_p.cpp
390

could this be simpler?
eg, something like

QString r = valueString;
if (!prefix.isEmpty()) {
  r = QString::fromLatin1("%1 %2).arg(r).arg(suffix);
}
if (!suffix.isEmpty()) {
  return = QString::fromLatin1("%1 %2).arg(prefix).arg(r);
}

(+ the bits for locale)

return r;
src/editors/spinbox.cpp
161

why / 100?

staniek added inline comments.Apr 14 2017, 10:31 PM
src/KPropertyUtils_p.cpp
390
> QString r = valueString;
> if (!prefix.isEmpty()) {
>   r = QString::fromLatin1("%1 %2).arg(r).arg(suffix);

You meant !prefix.isEmpty() probably but I see what you mean

> }
> if (!suffix.isEmpty()) {
>   return = QString::fromLatin1("%1 %2).arg(prefix).arg(r);

yes, good idea

> }
> 
> (+ the bits for locale)
> 
> return r;
src/editors/spinbox.cpp
161

Checked for you - comes from

85447da427b41 2006-02-21 - Qt 4 issue probably :)

  • fix for displaying double values for current locale

BUT it's still present today. Test: enter DBL_MAX i.e. 1.79769e+308 as value eg. in window.cpp:

m_set.addProperty(p = new KProperty("Double", DBL_MAX, "Double"), group)

Then you get this value in the GUI:

1797693134862315633301262629765050630866728936377003738459752501701914801454763796210449641241516314779480883561305033792001456611676070178718250902275612892141556670084334558762242165238180420033094130920939320073544954448635079731752693526288593899415905695239791325170347763968341437224060469123940876288.0000

which is (try to paster in a python shell):

1.7976931348623156e+306

which is a bit more than DBL_MAX/100.0 == 1.79769e+306.

I'll add this explanation to the code...

;)

staniek updated this revision to Diff 13449.Apr 15 2017, 12:09 AM
staniek edited the test plan for this revision. (Show Details)
  • Update default max value for double types
staniek updated this revision to Diff 13450.Apr 15 2017, 12:18 AM
  • Update default max value for double types
  • Simplify valueWithPrefixAndSuffix()
staniek marked 4 inline comments as done.Apr 15 2017, 12:19 AM
piggz accepted this revision.Apr 15 2017, 7:36 AM

Yep, that pretty much as I thought it should look, much smaller :)

This revision is now accepted and ready to land.Apr 15 2017, 7:36 AM
This revision was automatically updated to reflect the committed changes.