| Summary: | option to format null as zero in Decimal and NumericTextRidget | ||
|---|---|---|---|
| Product: | [RT] Riena | Reporter: | Steffen Kriese <steffen.kriese> |
| Component: | ridget | Assignee: | Elias Volanakis <elias> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | christian.campo, ekke, elias, florian.pirchner |
| Version: | unspecified | ||
| Target Milestone: | 3.0.0.M4 | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Steffen Kriese
Curious: what are the features your are currently missing? (providing support for any format is going to be quite difficult) It would be sufficient, if we could force the Ridget to show zeros when a zero or null is bound. At the moment a empty string with a comma is shown. I don't need all these scientific notations, but the formats # and 0. We are already padding a too-short value in the decimal text field. There is always at least one digit before the dec.separator and max.precision digits after the dec.separator. i.e. ,1 -> 0,10 0 -> 0,00 1,2 -> 1,20 (assuming precision of two) The only thing missing is how to treat the null-value. Currently: - in NumericTextRidget null -> empty - in DecimalTextRidget null -> , Next steps: (a) With regard to Steffen's comment: from my POV it would be sufficient to have a flag that will treat null as zero, example: ridget.setFormatNullAsZero(true). If set to true the formatting would be as follows: - in NumericTextRidget null -> 0 - in DecimalTextRidget null -> 0,0..0 (b) a general setFormat method is not needed at this time Adjusting bug summary. This has proven a bit tricky, due to all the other stuff happening in the text widgets (markers, hiding of text, ...). Here's the sketch of the current solution: ridget.setConvertEmptyToZero(true/false); // default is false When set to true (assuming decimal ridget, precision 2) : - null -> ridget.getText() is "", control.getText() is "0,00" (previously ",") - "" -> ridget.getText() is "", control.getText() is "0,00" (previously ",") - "0" -> ridget.getText() is "0", control.getText() is "0,00" When set to false (assuming decimal ridget, precision 2) the behavior is as before: - null -> ridget.getText() is "", control.getText() is "," - "" -> ridget.getText() is "", control.getText() is "," - "0" -> ridget.getText() is "0", control.getText() is "0,00" For NumericTextRidget the behavior is similar (minus the decimal part, i.e. "0" instead of "0,00"). Summary: nothing should change, except the way the value is shown in the control. One clarification: the algorithm described in comment #5 to handly empty value, applies only when the value is coming via r.setText(...) or r.updateFromModel(...). When setConvertEmptyToZero is on, and the user focuses on the widget, it is not possible to leave the widget empty. I.e. empty (",") will always be converted to ("0,00") and will become the value of the ridget. See SnippetNumericTextRidget002 for an example. Resolving. |