diff --git a/applets/digital-clock/package/contents/ui/CalendarView.qml b/applets/digital-clock/package/contents/ui/CalendarView.qml --- a/applets/digital-clock/package/contents/ui/CalendarView.qml +++ b/applets/digital-clock/package/contents/ui/CalendarView.qml @@ -50,8 +50,10 @@ property bool isExpanded: plasmoid.expanded onIsExpandedChanged: { - // clear all the selections when the plasmoid is showing/hiding - monthView.resetToToday(); + if (isExpanded) { + // clear all the selections when the plasmoid is showing + monthView.resetToToday(); + } } Item { @@ -87,14 +89,9 @@ target: monthView onCurrentDateChanged: { - // Apparently this is needed because this is a simple QList being - // returned and if the list for the current day has 1 event and the - // user clicks some other date which also has 1 event, QML sees the - // sizes match and does not update the labels with the content. - // Resetting the model to null first clears it and then correct data - // are displayed. - holidaysList.model = null; - holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate); + if (calendar.isExpanded) { + holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate); + } } } @@ -102,12 +99,18 @@ target: monthView.daysModel onAgendaUpdated: { - // Checks if the dates are the same, comparing the date objects - // directly won't work and this does a simple integer subtracting - // so should be fastest. One of the JS weirdness. - if (updatedDate - monthView.currentDate === 0) { - holidaysList.model = null; - holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate); + if (calendar.isExpanded) { + // We have to compare all three values separately instead of comparing the two date objects as a whole. + // Somehow there is a wrong time set in updatedDate that we don't want to take into comparision. + // I think because due to polymorphism updatedDate is a QDateTime object that gets converted to a javascript date object. + // The result is that the hours are saved for the current time zone. + // For example when timezone is GMT+0100 the time in updatedDate is 01:00:00 but in currentDate it is always 00:00:00. + if (updatedDate.getDate() === monthView.currentDate.getDate() + && updatedDate.getMonth() === monthView.currentDate.getMonth() + && updatedDate.getFullYear() === monthView.currentDate.getFullYear()) + { + holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate); + } } } }