summaryrefslogtreecommitdiff
path: root/src/controls/Private/CalendarHeaderModel.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2014-09-23 09:40:13 +0200
committerMitch Curtis <mitch.curtis@digia.com>2015-02-02 12:54:04 +0000
commit31803eb51bb2dde55776317b678d48d76f0e27fe (patch)
treee053d9d6c4a7fc5ded8ed42a7149493e93387e57 /src/controls/Private/CalendarHeaderModel.qml
parent94fe5ab8a619d009d698214623b8a9b5e2746f1b (diff)
downloadqtquickcontrols-31803eb51bb2dde55776317b678d48d76f0e27fe.tar.gz
Fix asynchronous loading of Calendar.
For some reason, adding the days of the week to the header model on component completion caused some (six) of the delegates to never be loaded. Instead, we assume that for most cases, the locale will be en_US, and only change the model via setProperty if this is not the case. This is enough to cause the delegates to be loaded properly. Change-Id: Ic399be4b3c9e252fec4eafac84bd9d44c61c1150 Task-number: QTBUG-41481 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls/Private/CalendarHeaderModel.qml')
-rw-r--r--src/controls/Private/CalendarHeaderModel.qml29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/controls/Private/CalendarHeaderModel.qml b/src/controls/Private/CalendarHeaderModel.qml
index ef57e65b..8adfcc1a 100644
--- a/src/controls/Private/CalendarHeaderModel.qml
+++ b/src/controls/Private/CalendarHeaderModel.qml
@@ -68,6 +68,28 @@ ListModel {
*/
property var locale
+ ListElement {
+ dayOfWeek: Locale.Sunday
+ }
+ ListElement {
+ dayOfWeek: Locale.Monday
+ }
+ ListElement {
+ dayOfWeek: Locale.Tuesday
+ }
+ ListElement {
+ dayOfWeek: Locale.Wednesday
+ }
+ ListElement {
+ dayOfWeek: Locale.Thursday
+ }
+ ListElement {
+ dayOfWeek: Locale.Friday
+ }
+ ListElement {
+ dayOfWeek: Locale.Saturday
+ }
+
Component.onCompleted: {
var daysOfWeek = [Locale.Sunday, Locale.Monday, Locale.Tuesday,
Locale.Wednesday, Locale.Thursday, Locale.Friday, Locale.Saturday];
@@ -76,9 +98,10 @@ ListModel {
var shifted = daysOfWeek.splice(firstDayOfWeek, daysOfWeek.length - firstDayOfWeek);
daysOfWeek = shifted.concat(daysOfWeek)
- for (var i = 0; i < daysOfWeek.length; ++i) {
- var element = { dayOfWeek: daysOfWeek[i] }
- root.append(element);
+ if (firstDayOfWeek !== Locale.Sunday) {
+ for (var i = 0; i < daysOfWeek.length; ++i) {
+ root.setProperty(i, "dayOfWeek", daysOfWeek[i]);
+ }
}
}
}