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
112
113
114
115
|
import QtQuick 2.0
import Ubuntu.Components 1.1
Item{
id: dateRootItem
property int date;
property bool isCurrentMonth;
property bool isToday;
property bool showEvent;
property alias fontSize: dateLabel.font.pixelSize
property bool isSelected: false
Loader {
sourceComponent: (isToday && isCurrentMonth) || isSelected ? highLightComp : undefined
onSourceComponentChanged: {
width = Qt.binding( function() {
var width = dateRootItem.height > dateRootItem.width ? dateRootItem.width :dateRootItem.height
return ( width / 1.1 );
});
height = Qt.binding ( function() { return width} );
anchors.centerIn = Qt.binding( function() { return dateLabel});
}
}
Label {
id: dateLabel
anchors.centerIn: parent
text: date
fontSize: root.dateLabelFontSize
color: {
if( isCurrentMonth ) {
if( isToday || isSelected ) {
"white"
} else {
"#5D5D5D"
}
} else {
if(isSelected) {
"white"
} else {
"#AEA79F"
}
}
}
}
Loader{
width: units.gu(1)
height: width
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: dateLabel.bottom
anchors.topMargin: dateRootItem.height/4
sourceComponent: showEvent ? eventIndicatorComp : undefined
}
Component{
id: eventIndicatorComp
Rectangle {
anchors.fill: parent
radius: height/2
color: "black"
}
}
Component{
id: highLightComp
UbuntuShape{
color: {
if( isToday && !isSelected ) {
"#DD4814"
} else {
"gray"
}
}
Rectangle{
anchors.fill: parent
anchors.margins: units.gu(0.5)
color: isToday ? "#DD4814" : "darkgray"
}
}
}
MouseArea {
anchors.fill: parent
onPressAndHold: {
if( isSelected ) {
var selectedDate = new Date();
selectedDate.setFullYear(intern.monthStartYear)
selectedDate.setMonth(intern.monthStartMonth + 1)
selectedDate.setDate(date)
selectedDate.setMinutes(60, 0, 0)
pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
}
}
onClicked: {
var selectedDate = new Date(intern.monthStartYear,
intern.monthStartMonth,
intern.monthStartDate + index, 0, 0, 0, 0)
if( isYearView ) {
//If yearView is clicked then open selected MonthView
root.monthSelected(selectedDate);
} else {
if( isSelected ) {
//If monthView is clicked then open selected DayView
root.dateSelected(selectedDate);
} else {
intern.selectedIndex = index
}
}
}
}
}
|