[Qt-components] Validation of properties in the proposed Calendar API
Mitch Curtis
mitch.curtis at digia.com
Wed Jan 16 14:01:09 CET 2013
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.
This has the advantage of being declarative, but could be a bit confusing.
b) Have one property and a setter "setSelectedDate" (See [3]).
This has the advantage of being straightforward, but is not as declarative.
I'd also like to see the chosen approach applied to the minimumDate and
maximumDate properties; minimumDate should not be larger than maximumDate and
vice versa, minimumDate and maximumDate should be within the valid JS date
range. These properties would then also be in the "_private" scope, with their
public properties exposed through one of the approaches listed above.
Cheers.
[1] https://codereview.qt-project.org/#change,44899
[2] http://paste.kde.org/648524/
[3] http://paste.kde.org/648530/
More information about the Qt-components
mailing list