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
107
108
109
110
111
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import "dateExt.js" as DateExt
Column {
id: root
property int type: typeWeek
property var startDay: DateExt.today();
readonly property int typeWeek: 0
readonly property int typeDay: 1
clip: true
width: parent.width
Item{
id: monthHeader
width: parent.width
height: monthLabel.height
Label{
id: monthLabel
fontSize: "large"
text: Qt.locale().standaloneMonthName(root.startDay.getMonth())
anchors.leftMargin: units.gu(1)
anchors.left: parent.left
//color:"white"
anchors.verticalCenter: parent.verticalCenter
}
Label{
id: yearLabel
fontSize: "medium"
text: root.startDay.getFullYear()
anchors.right: parent.right
anchors.rightMargin: units.gu(1)
color:"#AEA79F"
anchors.verticalCenter: parent.verticalCenter
}
}
Row{
id: header
width: parent.width
height: units.gu(10)
Repeater{
model: type == typeWeek ? 7 : 3
delegate: Item {
property var date : startDay.addDays(index);
property int weekDayWidth: header.width / 7
width: {
if( type == typeWeek || (type == typeDay && index != 1 ) ) {
weekDayWidth
} else {
weekDayWidth * 5
}
}
height: parent.height
Column{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
spacing: units.gu(0.5)
Label{
property var day: {
if( type == typeWeek || (type == typeDay && index != 1 ) ) {
Qt.locale().standaloneDayName(date.getDay(), Locale.ShortFormat)
} else {
Qt.locale().standaloneDayName(date.getDay(), Locale.LongFormat)
}
}
text: day.toUpperCase();
fontSize: "medium"
horizontalAlignment: Text.AlignHCenter
color: "#AEA79F"
width: parent.width
}
Label{
text: date.getDate();
fontSize: "large"
horizontalAlignment: Text.AlignHCenter
color: {
if( type == typeDay && index == 1 ) {
"white"
} else if( type == typeWeek && date.isSameDay(DateExt.today())){
"white"
} else {
"#AEA79F"
}
}
width: parent.width
}
}
}
}
}
}
|