75
75
onMaximumDateChanged: {
76
76
if (!priv.ready) return
78
var i = calendarModel.count - 1
79
while (i >= 0 && calendarModel.get(i).monthStart > maximumDate) {
80
calendarModel.remove(i)
84
if (calendarModel.count == 0) {
85
priv.__populateModel()
78
priv.__populateModel()
89
81
onMinimumDateChanged: {
90
82
if (!priv.ready) return
93
while (i < calendarModel.count && calendarModel.get(0).monthStart < minimumDate) {
94
calendarModel.remove(0)
98
if (calendarModel.count == 0) {
99
priv.__populateModel()
84
priv.__populateModel()
138
122
// disable the onCurrentIndexChanged logic
139
123
priv.ready = false
141
var minimumAddedDate = priv.__getRealMinimumDate(currentDate.addMonths(-2));
142
var maximumAddedDate = priv.__getRealMaximumDate(currentDate.addMonths(2));
144
var count = Math.min(DateExt.diffMonths(minimumAddedDate, maximumAddedDate) + 1, 5)
145
for (var i = 0; i < count; ++i) {
146
calendarModel.append({"monthStart": minimumAddedDate.monthStart().addMonths(i)});
125
var minimumAddedDate = priv.__getRealMinimumDate(currentDate.addMonths(-2)).monthStart();
126
var maximumAddedDate = priv.__getRealMaximumDate(currentDate.addMonths(2)).monthStart();
128
// Remove old minimum months
129
while (calendarModel.count > 0 && calendarModel.get(0).monthStart < minimumAddedDate) {
130
calendarModel.remove(0);
132
// Remove old maximum months
133
while (calendarModel.count > 0 && calendarModel.get(calendarModel.count - 1).monthStart > maximumAddedDate) {
134
calendarModel.remove(calendarModel.count - 1);
139
while (calendarModel.count > 0 && calendarModel.get(0).monthStart > minimumAddedDate) {
140
calendarModel.insert(0, {"monthStart": calendarModel.get(0).monthStart.addMonths(-1)});
144
if (calendarModel.count > 0) {
146
while (calendarModel.count > 0 && calendarModel.get(calendarModel.count - 1).monthStart < maximumAddedDate) {
147
calendarModel.append({"monthStart": calendarModel.get(calendarModel.count - 1).monthStart.addMonths(1)});
153
calendarModel.append({"monthStart": minimumAddedDate.addMonths(i)});
155
} while (calendarModel.get(i-1).monthStart < maximumAddedDate)
149
158
currentIndex = DateExt.diffMonths(minimumAddedDate, currentDate);