Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Allow empty null representation in spinboxes #7943

Merged
merged 2 commits into from Sep 18, 2018

Conversation

elpaso
Copy link
Contributor

@elpaso elpaso commented Sep 18, 2018

Fixes #18583 - Widget "Range": Representation for NULL value is NOT always displayed correctly

Fixes qgis#18583 - Widget "Range": Representation for NULL value is NOT always displayed correctly
@elpaso elpaso added the Bugfix label Sep 18, 2018
@elpaso elpaso added this to the 3.4.0 milestone Sep 18, 2018
QString QgsDoubleSpinBox::stripped( const QString &originalText ) const
{
//adapted from QAbstractSpinBoxPrivate::stripped
//trims whitespace, prefix and suffix from spin box text
QString text = originalText;
if ( specialValueText().isEmpty() || text != specialValueText() )
{
// Strip SPECIAL_TEXT_WHEN_EMPTY
if ( text.contains( SPECIAL_TEXT_WHEN_EMPTY ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

==?

Copy link
Contributor Author

@elpaso elpaso Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No: the problem that is addressed here is that when the widget value is null and the user enters a text, the text gets appended/prepended to the invisible character and the value is not correctly converted to double/int, this is also checked in the tests, so we really want to replace any invisible char in any position in the text.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sidenote: at some point I'll create a number-optimized QLineEdit with proper placeholder text and int/double properties. Noone needs the arrows on spinboxes anyway. And the only thing they reliably get right is data corruption because they grab the mouse wheel.

☠️ death to spinboxes ☠️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and they could even make copy/paste with thousand separators work as expected.

// This is required because private implementation of
// QAbstractSpinBoxPrivate checks for specialText emptiness
// and skips specialText handling if it's empty
static QString SPECIAL_TEXT_WHEN_EMPTY;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any special reason to put this into the header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the whole variable appears like an internal implementation detail that could only live isolated in the cpp on first look?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, besides that I'm using SPECIAL_TEXT_WHEN_EMPTY in the test, I thought it could be clearer to define a variable for that char instead of hardcoding the utf code directly (if is that what you meant).
But I'm fine to change it if you insist :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't insist, I was just thinking out loud. Mostly I try to keep implementation details out of installed headers.
Do as you wish ;)

@m-kuhn
Copy link
Member

m-kuhn commented Sep 18, 2018

Off topic: does the [bugfix] prefix trigger something?

@elpaso
Copy link
Contributor Author

elpaso commented Sep 18, 2018

Off topic: does the [bugfix] prefix trigger something?

Not that I'm aware of, but it goes into git logs while a tag doesn't. Do you suggest we don't use it? I was asking myself the same question.

@m-kuhn
Copy link
Member

m-kuhn commented Sep 18, 2018

I'm suggesting to not use it for as long as I don't see a reason why we use it.

Possible reasons (but no idea if they apply)

  • Helps reviewers
  • Helps to create a log for bugfixes
  • Triggers some webhooks (as needs-docs etc)
  • ...

At the same time, I started to put tags that are only for webhooks in less prominent places. The headline for a commit is short enough to be meaningful already.

What I would propose:

Short description of what it does

Longer in-depth description of what's happening, explanation and considerations.

[possibly][some][tags][for]
[webhooks]

@elpaso elpaso merged commit 2ee6122 into qgis:master Sep 18, 2018
@elpaso elpaso deleted the bugfix-18583-range-widget-nulls branch September 18, 2018 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants