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

Range widget #1500

Merged
merged 13 commits into from
Jun 24, 2021
Merged

Range widget #1500

merged 13 commits into from
Jun 24, 2021

Conversation

tomasMizera
Copy link
Collaborator

@tomasMizera tomasMizera commented Jun 18, 2021

Complete rework of range widget.

Important parts:

  • Range editable and range slider widgets were separated into two qml files
  • Range editable is no longer using qml SpinBox many bugs were coming from there. It is now just RowLayout with:
    • minus sign (new icon)
    • number input (text field)
    • optional suffix (text)
    • plus sign (new icon)
  • State has been introduced for numeric fields, it is the text underneath field name (the same as constraint description). It informs user when a value he/she typed is either invalid (can not be converted to number with convertCompatible) or is outside of specified min/max range
  • We do not use any qml validator, AttributeController serves as validator
  • Step is set to have a value that is visible! It is possible to set e.g. precision:3 and step:0.0001 which resulted in number not being incremented (it actually was incremented, but it was not visible). Now step is set as a maximum of step from qgis and minimum visible increment.

Current workflow:

  • User types in number or hits +/- sign
  • Number is converted to double with Number.fromLocaleString
  • Value is sent to AttributeController
  • If the value is not valid or the value is outside of the specified range (min/max), state of the formItem is set accordingly
  • If any of formItems have not valid state, it is not possible to save the form
  • When value is changed, it is converted back to the field with Number.toLocaleString

Also, there was this toast when user inserted some invalid value to a field, something like "Value x is not compatible with field y". It was not working in recent versions, I would just remove it, what do you think?

Needs to be properly tested, best in combinations with default values and apply-on-update values. I have used projects: lutraconsulting/test_decimals, tomas/decimals and tomas/another-decimals.

There are still some edge case bugs and I also need to completely change the tests because in the end, we are not using any validator (AttributeController is our validator). Please add all spotted bugs to comments. Best to test it on mobile device, desktop might handle scope differently (mainly due to a virtual keyboard).

Todo:

Resolves #1426
Resolves #1435
Resolves #1422
Should fix also #1183 and #493 but need to double check Needs to be fixed with #1507, we are currently not ideally deal null values

Let me know what you think

Screen_Recording_20210618-084502.mp4

@tomasMizera tomasMizera requested review from sklencar and PeterPetrik and removed request for sklencar June 18, 2021 08:00
@jozefbudac
Copy link

jozefbudac commented Jun 18, 2021

Few comments:

Copy link
Contributor

@PeterPetrik PeterPetrik left a comment

Choose a reason for hiding this comment

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

good work!

One top-level question about "constrains [soft/hard]" and "invalid field" etc. In general from QML point of view it is just "string" to show/not show below the field and if user can/cannot save the features. I am wondering if the whole separation of constrains (qgis code concept) and validity (newly introduced input concept) shouldn't be just internal/private implementation detail of attribute controller ....

@wonder-sk @tomasMizera what do you think?

app/attributes/attributecontroller.cpp Outdated Show resolved Hide resolved
app/attributes/attributecontroller.cpp Outdated Show resolved Hide resolved
app/attributes/attributecontroller.h Outdated Show resolved Hide resolved
app/attributes/attributedata.cpp Show resolved Hide resolved
app/attributes/attributeformmodel.h Outdated Show resolved Hide resolved
app/editor/rangewidgethelper.cpp Outdated Show resolved Hide resolved
app/editor/rangewidgethelper.cpp Outdated Show resolved Hide resolved
app/editor/rangewidgethelper.h Outdated Show resolved Hide resolved
app/qml/FeatureForm.qml Outdated Show resolved Hide resolved
@tomasMizera
Copy link
Collaborator Author

good work!

One top-level question about "constrains [soft/hard]" and "invalid field" etc. In general from QML point of view it is just "string" to show/not show below the field and if user can/cannot save the features. I am wondering if the whole separation of constrains (qgis code concept) and validity (newly introduced input concept) shouldn't be just internal/private implementation detail of attribute controller ....

@wonder-sk @tomasMizera what do you think?

I am 100% for. We could maybe still have two types of constraints:

  • soft: those that let's you save the form, e.g. qgis soft constraint or scan an invalid QR code but the field can be null
  • hard: those that won't let you save the form, as you said range and qgis hard constraints

@PeterPetrik in this case, would you still keep the formItem's state property or how would we differentiate between different errors?

@PeterPetrik
Copy link
Contributor

maybe just msgText and msgLevel = [None/Info/Warn/Error] and then have a boolean property in attribute controller possible to save or not? not sure

@tomasMizera
Copy link
Collaborator Author

Hm, so AttributeController would set the msgText e.g. number out of range or invalid value?

@tomasMizera
Copy link
Collaborator Author

tomasMizera commented Jun 21, 2021

@PeterPetrik @wonder-sk I have created a separate ticket for the invalid values topic we discussed
#1507

@PeterPetrik
Copy link
Contributor

let me know when it its ready for review, I still see "WIP" in the title?

@tomasMizera tomasMizera changed the title WIP: Range widget Range widget Jun 21, 2021
@tomasMizera
Copy link
Collaborator Author

@PeterPetrik ready for final review, there are some remarks but it is not blocking review

Copy link
Contributor

@PeterPetrik PeterPetrik left a comment

Choose a reason for hiding this comment

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

just 1/2 of the review

app/attributes/attributecontroller.cpp Outdated Show resolved Hide resolved
app/attributes/attributecontroller.cpp Outdated Show resolved Hide resolved
app/attributes/attributecontroller.cpp Outdated Show resolved Hide resolved
app/attributes/attributecontroller.h Outdated Show resolved Hide resolved
app/attributes/attributedata.cpp Show resolved Hide resolved
app/attributes/attributedata.h Show resolved Hide resolved
app/attributes/attributedata.h Show resolved Hide resolved
app/qml/FeatureForm.qml Show resolved Hide resolved
app/qml/FeatureForm.qml Show resolved Hide resolved
app/qml/FeatureForm.qml Outdated Show resolved Hide resolved
Copy link
Contributor

@sklencar sklencar left a comment

Choose a reason for hiding this comment

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

  • position of value and suffix (iOS + A)
  • still buggy for values that are completely out of the range (too big numbers): +- buttons doesn't work (iOS + A):
  • different behaviour as in QGIS: when value is out of range, +- buttons sets value to edge range value (QGIS), Input just in/decreases value by a step. Assuming we want to keep invalid values visible for a user, it is just a note that it works differently.
  • not only "invalid value text" disappears, but also (hard) constrain disappears on second click on a field (iOS + A)

app/attributes/attributecontroller.cpp Outdated Show resolved Hide resolved
app/attributes/attributecontroller.h Show resolved Hide resolved
@sklencar
Copy link
Contributor

Also slider doesn't work properly (test project: tomas/decimals):

RPReplay_Final1624452537.MP4

However, field config also seems to not be set correctly - range is rather none that set as <-inf, inf>
Screenshot 2021-06-23 at 14 50 10

@sklencar
Copy link
Contributor

Generally besides known issues and small remarks, I can approve it since it works with most of the user cases.
However, best to resolve code comments before.

@tomasMizera
Copy link
Collaborator Author

Also slider doesn't work properly (test project: tomas/decimals):

RPReplay_Final1624452537.MP4
However, field config also seems to not be set correctly - range is rather none that set as <-inf, inf>
Screenshot 2021-06-23 at 14 50 10

Yes, that is just project discrepancy between field name and actual values in range.
There is however one ongoing issue (was here in previous versions too): #1516

@tomasMizera tomasMizera added the squash squash before merging label Jun 24, 2021
@PeterPetrik PeterPetrik merged commit 4942b22 into master Jun 24, 2021
@PeterPetrik PeterPetrik deleted the range-widget branch June 24, 2021 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
squash squash before merging
Projects
None yet
5 participants