[Qt-components] Validation of properties in the proposed Calendar API

Michael Hasselmann michaelh at openismus.com
Wed Jan 16 14:07:52 CET 2013


On Wed, 2013-01-16 at 14:01 +0100, Mitch Curtis wrote:
> Hi.
> 
> I'm currently working on the Calendar component [1]. I'd like to consult any 
> interested parties regarding validation of its properties.
> 
> The proposed API provides selectedDate, minimumDate and maximumDate 
> properties. The selectedDate property reflects the date currently displayed by 
> the calendar, and can be set either programmatically or through the Calendar 
> UI itself. This property should, in my opinion, be validated against dates 
> outside the range of minimumDate and maximumDate. I'm not so sure about 
> validation against "undefined", but have included that in my examples for 
> completeness.
> 
> Since I can't validate the selectedDate property in its own onChanged handler 
> (results in binding loops), I have to take another approach. From talking with 
> a few developers, I can see two options:
> 
> a) Have two properties (See [2]):
>     - inputDate - Its only purpose is to be set programmatically.
>     - selectedDate - Read-only. The result of inputDate after validation or 
> the date chosen through the UI.

Why not have a separate validator component listening to the
selectedDate property? If the validator doesn't like the current value,
it will reset it to a valid one (or last valid one).

So yes, others listening to that property will temporarily see a wrong
value, if someone sets an incorrect date. But "temporary" should be in
the ms range.

regards,
Michael

BTW: Binding loops don't have to be wrong per se. It could be a
self-stabilizing system that stops changing after n iterations.




More information about the Qt-components mailing list