11import org.mauikit.controls as Maui
12import org.mauikit.calendar as Kalendar
14import "dateutils.js" as DateUtils
65 readonly
property date currentDate:
new Date()
70 readonly property
string title:
Qt.formatDate(pathView.currentItem.firstDayOfMonth, "MMM yyyy")
75 property var openOccurrence: ({})
80 property var filter: {
89 readonly
property alias model : _monthViewModel
94 property date startDate
99 property date firstDayOfMonth
114 property bool initialMonth:
true
119 readonly
property bool isLarge: width >
Maui.Style.units.gridUnit * 40
124 readonly
property bool isTiny: width <
Maui.Style.units.gridUnit * 18
129 property date selectedDate : currentDate
134 property bool dragDropEnabled:
true
139 property alias interactive : pathView.interactive
144 signal dateClicked(var date)
149 signal dateRightClicked(var date)
154 signal dateDoubleClicked(var date)
156 background: Rectangle
158 color:
Maui.Theme.backgroundColor
161 Kalendar.InfiniteCalendarViewModel
164 scale: Kalendar.InfiniteCalendarViewModel.MonthScale
167 contentItem: PathView
171 flickDeceleration:
Maui.Style.units.longDuration
172 interactive:
Maui.Handy.isMobile
174 preferredHighlightBegin: 0.5
175 preferredHighlightEnd: 0.5
178 highlightMoveDuration: 0
180 snapMode: PathView.SnapToItem
185 startX: - pathView.width * pathView.count / 2 + pathView.width / 2
186 startY: pathView.height / 2
188 x: pathView.width * pathView.count / 2 + pathView.width / 2
189 y: pathView.height / 2
195 property int startIndex
197 Component.onCompleted:
199 startIndex = count / 2;
200 currentIndex = startIndex;
203 onCurrentIndexChanged:
205 control.startDate = currentItem.startDate;
206 control.firstDayOfMonth = currentItem.firstDayOfMonth;
207 control.month = currentItem.month;
208 control.year = currentItem.year;
210 if(currentIndex >= count - 2) {
211 model.addDates(
true);
212 }
else if (currentIndex <= 1) {
213 model.addDates(
false);
214 startIndex += model.datesToAdd;
222 property date startDate: model.startDate
223 property date firstDayOfMonth: model.firstDay
224 property int month: model.selectedMonth - 1
225 property int year: model.selectedYear
227 property bool isNextOrCurrentItem: index >= pathView.currentIndex -1 && index <= pathView.currentIndex + 1
228 property bool isCurrentItem: PathView.isCurrentItem
230 active: isNextOrCurrentItem
231 asynchronous: !isCurrentItem
232 visible:
status === Loader.Ready
234 sourceComponent: Kalendar.DayGridView
237 objectName:
"monthView"
239 width: pathView.width
240 height: pathView.height
243 isCurrentView: viewLoader.isCurrentItem
244 dragDropEnabled: control.dragDropEnabled
246 startDate: viewLoader.startDate
247 currentDate: control.currentDate
248 month: viewLoader.month
255 control.selectedDate = date
256 control.dateClicked(control.selectedDate)
261 control.selectedDate = date
262 control.dateDoubleClicked(control.selectedDate)
267 leftPadding:
Maui.Style.units.smallSpacing
268 rightPadding:
Maui.Style.units.smallSpacing
274 let longText = day.toLocaleString(
Qt.locale(),
"dddd");
275 let midText = day.toLocaleString(
Qt.locale(),
"ddd");
276 let shortText = midText.slice(0,1);
279 return control.isTiny ? shortText : midText;
283 horizontalAlignment:
Text.AlignLeft
285 font.weight: Font.Bold
286 font.pointSize:
Maui.Style.fontSizes.big
294 weekHeaderDelegate:
Maui.LabelDelegate
296 padding:
Maui.Style.units.smallSpacing
298 label.horizontalAlignment:
Qt.AlignHCenter
299 text: DateUtils.getWeek(startDate,
Qt.locale().firstDayOfWeek)
307 openOccurrence: control.openOccurrence
317 setToDate(
new Date())
325 setToDate(DateUtils.addMonthsToDate(pathView.currentItem.firstDayOfMonth, 1))
331 function previousDate()
333 setToDate(DateUtils.addMonthsToDate(pathView.currentItem.firstDayOfMonth, -1))
339 function addMonthsToDate(date, days)
341 return DateUtils.addMonthsToDate(date, days)
347 function setToDate(date, isInitialMonth =
true)
349 control.initialMonth = isInitialMonth;
350 let monthDiff = date.getMonth() - pathView.currentItem.firstDayOfMonth.getMonth() + (12 * (date.getFullYear() - pathView.currentItem.firstDayOfMonth.getFullYear()))
351 let newIndex = pathView.currentIndex + monthDiff;
353 let firstItemDate = pathView.model.data(pathView.model.index(1,0), Kalendar.InfiniteCalendarViewModel.FirstDayOfMonthRole);
354 let lastItemDate = pathView.model.data(pathView.model.index(pathView.model.rowCount() - 1,0), Kalendar.InfiniteCalendarViewModel.FirstDayOfMonthRole);
356 while(firstItemDate >= date) {
357 pathView.model.addDates(
false)
358 firstItemDate = pathView.model.data(pathView.model.index(1,0), Kalendar.InfiniteCalendarViewModel.FirstDayOfMonthRole);
361 if(firstItemDate < date && newIndex === 0) {
362 newIndex = date.getMonth() - firstItemDate.getMonth() + (12 * (date.getFullYear() - firstItemDate.getFullYear())) + 1;
365 while(lastItemDate <= date) {
366 pathView.model.addDates(
true)
367 lastItemDate = pathView.model.data(pathView.model.index(pathView.model.rowCount() - 1,0), Kalendar.InfiniteCalendarViewModel.FirstDayOfMonthRole);
369 pathView.currentIndex = newIndex;
Q_SCRIPTABLE CaptureState status()
QString path(const QString &relativePath)
QString label(StandardShortcut id)