1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import "dateExt.js" as DateExt
import "colorUtils.js" as Color
Item{
id: root
property var date;
signal monthSelected(var date);
property alias dayLabelDelegate : dayLabelRepeater.delegate
property alias dateLabelDelegate : dateLabelRepeater.delegate
objectName: "MonthComponent"
width: monthGrid.width
height: monthGrid.height + units.gu(0.5)+ monthName.height
MouseArea{
anchors.fill: parent
onClicked: {
root.monthSelected( root.date );
}
}
Label{
id: monthName
width: parent.width
horizontalAlignment: Text.AlignHCenter
font.bold: true
text: {
Qt.locale().standaloneMonthName(root.date.getMonth())
}
}
Row{
id: dayLabelRow
anchors.top: monthName.bottom
anchors.topMargin: units.gu(0.5)
spacing: units.gu(0.5)
width: parent.width
Repeater{
id: dayLabelRepeater
model:7
delegate: dafaultDayLabelComponent
}
}
Grid{
id: monthGrid
property var monthStart: DateExt.getFirstDateofWeek(root.date.getFullYear(),root.date.getMonth())
rows: DateExt.weekCount(root.date.getFullYear(), root.date.getMonth())
columns: 7
spacing: units.gu(0.5)
anchors.top: dayLabelRow.bottom
anchors.topMargin: units.gu(0.5)
Repeater{
id: dateLabelRepeater
model: monthGrid.rows * monthGrid.columns
delegate: defaultDateLabelComponent
}
}
Component{
id: defaultDateLabelComponent
Text {
id: dateLabel
property var day: parent.monthStart.addDays(index)
property var isToday: day.isSameDay(intern.now)
text: day.getDate()
horizontalAlignment: Text.AlignHCenter
width: dummy.width
height: dummy.height
font.pointSize: dummy.font.pointSize
color: isToday ? Color.ubuntuOrange : dummy.color
scale: isToday ? 1.5 : 1.
}
}
Component{
id: dafaultDayLabelComponent
Text{
//FIXME: how to get localized day initial ?
text: Qt.locale().standaloneDayName( (intern.weekstartDay + index), Locale.ShortFormat).charAt(0)
horizontalAlignment: Text.AlignHCenter
width: dummy.width
height: dummy.height
font.pointSize: dummy.font.pointSize
font.bold: true
}
}
Text{
id: dummy
text: "00"
visible: false
font.pointSize: 7.5
}
}
|