From e34acd44166035729ea58ad04172778102ca165f Mon Sep 17 00:00:00 2001 From: Raquel Medina Date: Fri, 12 Jul 2019 00:21:48 +0300 Subject: settings: datetime: qml: fix warning on model init - workaround invalid currentIndex - rework model initialization from array Bug-AGL: SPEC-2635 Signed-off-by: Raquel Medina Change-Id: I7e218ee73aa40f9e85271d480c98a7eb45ac29b5 --- app/datetime/DateEdit.qml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/datetime/DateEdit.qml b/app/datetime/DateEdit.qml index f9f75fd..abfcfa9 100644 --- a/app/datetime/DateEdit.qml +++ b/app/datetime/DateEdit.qml @@ -65,7 +65,7 @@ GridLayout { Component.onCompleted: regenerateModel() function regenerateModel() { var eom = 0 - var y = yearControl.model[yearControl.currentIndex] + var y = yearControl.currentIndex === -1 ? yearControl.model[0] : yearControl.model[yearControl.currentIndex] var m = monthControl.currentIndex + 1 switch (m) { case 2: @@ -103,13 +103,13 @@ GridLayout { Tumbler { id: yearControl - Component.onCompleted: { - var arr = new Array - for (var i = 2010; i < 2050; i++) { + readonly property var years: (function() { + var arr = [] + for (var i = 2010; i < 2050; i++) arr.push(i) - } - yearControl.model = arr - } + return arr + })() + model: years onCurrentIndexChanged: dayControl.regenerateModel() EditSeparator { anchors.fill: parent } } -- cgit 1.2.3-korg