39
17
property alias dayLabelDelegate : dayLabelRepeater.delegate
40
18
property alias dateLabelDelegate : dateLabelRepeater.delegate
42
signal monthSelected(var date);
43
20
signal dateSelected(var date)
45
//creatng timer only if we need to show events in month
48
sourceComponent: showEvents ? timerComp : undefined
51
// Timer to delay creation of Model, There seems some problem fetching events if we create Model immediatly
55
interval: 200; running: true; repeat: false
57
modelLoader.sourceComponent = modelComponent
70
startPeriod: intern.monthStart.midnight();
71
endPeriod: intern.monthStart.addDays((/*monthGrid.rows * cols */ 42 )-1).endOfDay()
72
filter: eventModel.filter
74
intern.eventStatus = Qt.binding(function() { return mainModel.containsItems(startPeriod, endPeriod, 86400/*24*60*60*/)});
82
property var eventStatus;
84
property int curMonthDate: currentMonth.getDate()
85
property int curMonth: currentMonth.getMonth()
86
property int curMonthYear: currentMonth.getFullYear()
88
property var today: DateExt.today()
89
property int todayDate: today.getDate()
90
property int todayMonth: today.getMonth()
91
property int todayYear: today.getFullYear()
93
//date from month will start, this date might be from previous month
94
property var monthStart: currentMonth.weekStart( Qt.locale().firstDayOfWeek )
95
property int monthStartDate: monthStart.getDate()
96
property int monthStartMonth: monthStart.getMonth()
97
property int monthStartYear: monthStart.getFullYear()
99
property int daysInStartMonth: Date.daysInMonth(monthStartYear, monthStartMonth)
100
property int daysInCurMonth: Date.daysInMonth(curMonthYear,curMonth)
102
//check if current month is start month
103
property bool isCurMonthStartMonth: curMonthDate === monthStartDate
104
&& curMonth === monthStartMonth
105
&& curMonthYear === monthStartYear
107
//check current month is same as today's month
108
property bool isCurMonthTodayMonth: todayYear === curMonthYear && todayMonth == curMonth
109
//offset from current month's first date to start date of current month
110
property int offset: isCurMonthStartMonth ? -1 : (daysInStartMonth - monthStartDate)
112
property int dateFontSize: FontUtils.sizeToPixels(root.dateLabelFontSize)
113
property int dayFontSize: FontUtils.sizeToPixels(root.dayLabelFontSize)
121
topMargin: units.gu(1.5)
122
bottomMargin: units.gu(1)
125
spacing: units.gu(1.5)
129
month: intern.curMonth
130
year: intern.curMonthYear
132
monthLabelFontSize: root.monthLabelFontSize
133
yearLabelFontSize: root.yearLabelFontSize
134
visible: isYearView === true
139
height: dayLabelRow.height + units.gu(1)
141
DayHeaderBackground{}
146
anchors.horizontalCenter: parent.horizontalCenter
147
anchors.verticalCenter: parent.verticalCenter
148
property int dayWidth: width / 7;
22
height: ubuntuShape.height
33
anchors.top: parent.top
34
anchors.topMargin: units.gu(1.5)
35
anchors.bottomMargin: units.gu(1)
37
spacing: units.gu(1.5)
42
monthLabelFontSize: root.monthLabelFontSize
43
yearLabelFontSize: root.yearLabelFontSize
48
height: dayLabelRow.height + units.gu(1)
55
anchors.horizontalCenter: parent.horizontalCenter
56
anchors.verticalCenter: parent.verticalCenter
61
delegate: dafaultDayLabelComponent
68
objectName: "monthGrid"
70
property int weekCount : 6
71
property var monthStart: root.monthDate.weekStart( Qt.locale().firstDayOfWeek )
74
height: parent.height - monthHeader.height - dayLabelRow.height - units.gu(3)
153
delegate: dafaultDayLabelComponent
81
model: monthGrid.rows * monthGrid.columns
82
delegate: defaultDateLabelComponent
160
objectName: "monthGrid"
163
height: parent.height - monthGrid.y
165
property int dayWidth: width / 7 /*cols*/;
166
property int dayHeight: height / 6/*rows*/;
172
id: dateLabelRepeater
173
model: 42 //monthGrid.rows * monthGrid.columns
174
delegate: defaultDateLabelComponent
180
89
id: defaultDateLabelComponent
181
MonthComponentDateDelegate{
183
//try to find date from index and month's first week's first date
184
var temp = intern.daysInStartMonth - intern.offset + index
185
//date exceeds days in startMonth,
186
//this means previous month is over and we are now in current month
187
//to get actual date we need to remove number of days in startMonth
188
if( temp > intern.daysInStartMonth ) {
189
temp = temp - intern.daysInStartMonth
190
//date exceeds days in current month
191
// this means date is from next month
192
//to get actual date we need to remove number of days in current month
193
if( temp > intern.daysInCurMonth ) {
194
temp = temp - intern.daysInCurMonth
94
property var date: parent.monthStart.addDays(index);
95
property bool isCurrentMonth: DateExt.isSameMonth(root.monthDate,date)
97
width: parent.width / 7;
98
height: parent.height / parent.weekCount
103
anchors.centerIn: parent
104
sourceComponent: date.isSameDay(DateExt.today()) && isCurrentMonth ? highLightComp : undefined
109
anchors.centerIn: parent
111
horizontalAlignment: Text.AlignHCenter
112
fontSize: root.dateLabelFontSize
114
if( date.isSameDay(DateExt.today()) && isCurrentMonth ) {
116
} else if( parent.isCurrentMonth ) {
201
//remove offset from index
202
//if index falls in 1 to no of days in current month
203
//then date is inside current month
204
var temp = index - intern.offset
205
return (temp >= 1 && temp <= intern.daysInCurMonth)
208
isToday: intern.todayDate == date && intern.isCurMonthTodayMonth
210
width: parent.dayWidth
211
height: parent.dayHeight
212
fontSize: intern.dateFontSize
217
id: eventIndicatorComp
127
root.dateSelected(date);