185
186
Keys.onLeftPressed: selectedDate.addDays(-1)
186
187
Keys.onRightPressed: selectedDate.addDays(1)
191
190
property var month: new Cal.Month(model.month)
192
191
property var monthStart: new Cal.Day(model.month.year, model.month.month, 1)
193
192
property var monthEnd: monthStart.addMonths(1)
194
193
property var gridStart: monthStart.weekStart(firstDayOfWeek)
197
columnSpacing: (calendar.width - calendar.implicitWidth) / (columns - 1)
199
rows: priv.weeks + 1 /* the weekDays header */
200
rowSpacing: (calendar.height - calendar.implicitHeight) / (rows - 1)
202
verticalItemAlignment: Grid.AlignVCenter
203
horizontalItemAlignment: Grid.AlignHCenter
210
objectName: "weekDay" + modelData
211
text: Qt.locale(i18n.language).standaloneDayName((modelData + firstDayOfWeek) % priv.days, Locale.ShortFormat).toUpperCase()
212
textSize: Label.XSmall
213
// FIXME: There's no good palette that covers both
214
// Ambiance (Ash) and Suru (Silk)
215
color: theme.palette.highlighted.base
216
onHeightChanged: priv.weekDaysHeight = Math.max(height, priv.weekDaysHeight)
221
model: priv.days * priv.weeks
224
objectName: "dayItem" + index
226
property int weekday: (index % priv.days + firstDayOfWeek) % priv.days
227
property var dayStart: gridStart.addDays(index)
228
property bool isSelected: priv.userSelected && dayStart.equals(priv.selectedDay)
229
property bool isCurrentMonth: (monthStart < dayStart || monthStart.equals(dayStart)) && dayStart < monthEnd
230
property bool isWeekend: weekday == 0 || weekday == 6
231
property bool isToday: dayStart.equals(priv.today)
232
property bool hasEvent: isCurrentMonth && eventDays.indexOf(dayStart.day) != -1
233
property bool isWithinBounds: (priv.minimumDay === undefined || dayStart >= priv.minimumDay) &&
234
(priv.maximumDay === undefined || dayStart <= priv.maximumDay)
236
width: priv.squareUnit
237
height: priv.squareUnit
242
aspect: UbuntuShape.Flat
244
color: dayNumber.color
247
// XXX: since we can't just colorize the shape border
248
// we need another one to fill the center with bg color
250
radius: parent.radius
251
aspect: parent.aspect
252
backgroundColor: theme.palette.normal.background
255
anchors.margins: units.gu(0.1)
261
anchors.centerIn: parent
262
text: dayStart.day > 9 ? dayStart.day : Qt.locale(i18n.language).zeroDigit + dayStart.day
263
textSize: Label.Medium
264
color: isSelected ? theme.palette.normal.positionText : theme.palette.normal.backgroundText
267
when: isCurrentMonth && isWeekend && !isSelected
268
value: theme.palette.normal.backgroundTertiaryText
272
when: !isCurrentMonth
197
visible: calendar.showWeekNumbers
198
spacing: monthGrid.rowSpacing
203
objectName: "weekDay" + modelData
204
text: i18n.tr("WEEK")
205
textSize: Label.XSmall
273
206
// FIXME: There's no good palette that covers both
274
// Ambiance (silk) and Suru (inkstone)
275
value: theme.palette.disabled.base
280
objectName: "eventMarker"+index
281
aspect: UbuntuShape.Flat
283
color: theme.palette.selected.baseText
287
y: dayNumber.height + (parent.height - dayNumber.height - height) / 2
288
anchors.horizontalCenter: parent.horizontalCenter
295
if (isWithinBounds) {
297
calendar.selectedDate = new Date(dayStart.year, dayStart.month, dayStart.day)
298
priv.userSelected = true
299
} else if (priv.userSelected) {
300
calendar.selectedDate = new Date(dayStart.year, dayStart.month)
301
priv.userSelected = false
207
// Ambiance (Ash) and Suru (Silk)
208
color: theme.palette.disabled.base
215
property int weekNumber: modelData + (monthStart.toDate() - new Date(monthStart.year, 0, 1))/1000/86400/7
216
width: priv.squareUnit
217
height: priv.squareUnit
221
anchors.centerIn: parent
222
text: weekNumber > 9 ? weekNumber : Qt.locale(i18n.language).zeroDigit + weekNumber
223
textSize: Label.Medium
224
color: theme.palette.normal.backgroundTertiaryText
233
height: weekColumn.height
236
color: theme.palette.disabled.base
238
anchors.topMargin: units.gu(0.5)
239
anchors.bottomMargin: anchors.topMargin
240
anchors.leftMargin: units.gu(0.9)
241
anchors.rightMargin: anchors.leftMargin
252
columnSpacing: (calendar.width - calendar.implicitWidth - (weekColumn.visible ? weekColumn.width : 0)) / (columns - 1)
254
rows: priv.weeks + 1 /* the weekDays header */
255
rowSpacing: (calendar.height - calendar.implicitHeight) / (rows - 1)
257
verticalItemAlignment: Grid.AlignVCenter
258
horizontalItemAlignment: Grid.AlignHCenter
265
objectName: "weekDay" + modelData
266
text: Qt.locale(i18n.language).standaloneDayName((modelData + firstDayOfWeek) % priv.days, Locale.ShortFormat).toUpperCase()
267
textSize: Label.XSmall
268
// FIXME: There's no good palette that covers both
269
// Ambiance (Ash) and Suru (Silk)
270
color: theme.palette.highlighted.base
271
onHeightChanged: priv.weekDaysHeight = Math.max(height, priv.weekDaysHeight)
276
model: priv.days * priv.weeks
279
objectName: "dayItem" + index
281
property int weekday: (index % priv.days + firstDayOfWeek) % priv.days
282
property var dayStart: gridStart.addDays(index)
283
property bool isSelected: priv.userSelected && dayStart.equals(priv.selectedDay)
284
property bool isCurrentMonth: (monthStart < dayStart || monthStart.equals(dayStart)) && dayStart < monthEnd
285
property bool isWeekend: weekday == 0 || weekday == 6
286
property bool isToday: dayStart.equals(priv.today)
287
property bool hasEvent: isCurrentMonth && eventDays.indexOf(dayStart.day) != -1
288
property bool isWithinBounds: (priv.minimumDay === undefined || dayStart >= priv.minimumDay) &&
289
(priv.maximumDay === undefined || dayStart <= priv.maximumDay)
291
width: priv.squareUnit
292
height: priv.squareUnit
297
aspect: UbuntuShape.Flat
299
color: dayNumber.color
302
// XXX: since we can't just colorize the shape border
303
// we need another one to fill the center with bg color
305
radius: parent.radius
306
aspect: parent.aspect
307
backgroundColor: theme.palette.normal.background
310
anchors.margins: units.gu(0.1)
316
anchors.centerIn: parent
317
text: dayStart.day > 9 ? dayStart.day : Qt.locale(i18n.language).zeroDigit + dayStart.day
318
textSize: Label.Medium
319
color: isSelected ? theme.palette.normal.positionText : theme.palette.normal.backgroundText
322
when: isCurrentMonth && isWeekend && !isSelected
323
value: theme.palette.normal.backgroundTertiaryText
327
when: !isCurrentMonth
328
// FIXME: There's no good palette that covers both
329
// Ambiance (silk) and Suru (inkstone)
330
value: theme.palette.disabled.base
335
objectName: "eventMarker"+index
336
aspect: UbuntuShape.Flat
338
color: theme.palette.selected.baseText
342
y: dayNumber.height + (parent.height - dayNumber.height - height) / 2
343
anchors.horizontalCenter: parent.horizontalCenter
350
if (isWithinBounds) {
352
calendar.selectedDate = new Date(dayStart.year, dayStart.month, dayStart.day)
353
priv.userSelected = true
354
} else if (priv.userSelected) {
355
calendar.selectedDate = new Date(dayStart.year, dayStart.month)
356
priv.userSelected = false