Improvements #14832
openHonor custom editor formats in WFormDelegate for WDate, WTime and WDateTime
0%
Description
Problem¶
Applications using the standard date and time form delegates, including Dbo
forms, cannot reliably use editor formats that differ from the current locale.
WFormDelegate, WFormDelegate and
WFormDelegate parse editor text using the current locale's date,
time or date-time format. They do not use the format configured on the
corresponding WDateEdit, WTimeEdit or WDateTimeEdit.
For example, configure the locale date format as yyyy-MM-dd, set a
WDateEdit format to dd/MM/yyyy, enter 16/09/2026, and call the date
delegate's updateModelValue(). The editor accepts the date, but the delegate
parses it using yyyy-MM-dd. Instead of storing WDate(2026, 9, 16), its
failure path can store a validator result. Formats that overlap can also be
interpreted differently.
The reverse direction has the same mismatch: updateViewValue() uses
asString() without an explicit format, which formats temporal values using
the locale. Refreshing the view can therefore replace a correctly formatted
editor value with text that does not match its format.
Expected Behavior¶
Update all three delegates consistently so conversion between typed model
values and their corresponding editors respects the editor's effective
format. An application should be able to configure an editor format without
having to replace the form delegate just to keep model and view consistent.
Preserve locale-based behavior for generic form widgets such as WLineEdit,
and preserve existing empty-value and invalid-input handling. This change
should cover both conversion directions and retain input when validation
fails. The exact implementation is open; a WDateTime-only exception is outside
the intended scope.
Acceptance Criteria¶
Custom formats differing from the locale produce the correct typed model
value for WDate, WTime and WDateTime.
Updating each corresponding editor from a model value uses its effective
format and supports a value-preserving round trip.
Generic editors retain the established locale-format fallback.
Empty input retains null-value behavior. Invalid input and validation
results retain their established handling without erasing the input.
Regression coverage exercises all three types, mismatched editor and locale
formats, both conversion directions, and generic-editor fallback behavior.
Context and Scope
This is a separate follow-up to WT-8759, requested during review of the
WDateTimeEdit integration.
ED Updated by emil de keyser 13 days ago
- Related to Feature #8759: Add a WDateTimeEdit added
RM Updated by Romain Mardulyn 6 days ago
- Target version changed from 4.15.0 to 4.16.0