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
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
MainView {
id: mainView
objectName: "calendar"
applicationName: "calendar"
width: units.gu(45)
height: units.gu(80)
Tabs {
id: tabs
anchors.fill: parent
Tab { title: Qt.locale(i18n.language).monthName(0) }
Tab { title: Qt.locale(i18n.language).monthName(1) }
Tab { title: Qt.locale(i18n.language).monthName(2) }
Tab { title: Qt.locale(i18n.language).monthName(3) }
Tab { title: Qt.locale(i18n.language).monthName(4) }
Tab { title: Qt.locale(i18n.language).monthName(5) }
Tab { title: Qt.locale(i18n.language).monthName(6) }
Tab { title: Qt.locale(i18n.language).monthName(7) }
Tab { title: Qt.locale(i18n.language).monthName(8) }
Tab { title: Qt.locale(i18n.language).monthName(9) }
Tab { title: Qt.locale(i18n.language).monthName(10) }
Tab { title: Qt.locale(i18n.language).monthName(11) }
onSelectedTabIndexChanged: monthView.gotoNextMonth(selectedTabIndex)
tools: ToolbarActions {
Action {
iconSource: Qt.resolvedUrl("avatar.png")
text: i18n.tr("To-do")
onTriggered:; // FIXME
}
Action {
iconSource: Qt.resolvedUrl("avatar.png")
text: i18n.tr("New Event")
onTriggered: mainView.newEvent()
}
Action {
iconSource: Qt.resolvedUrl("avatar.png")
text: i18n.tr("Timeline")
onTriggered:; // FIXME
}
}
}
Rectangle {
anchors.fill: monthView
color: "white"
}
MonthView {
id: monthView
onMonthStartChanged: tabs.selectedTabIndex = monthStart.getMonth()
y: units.gu(9.5) // FIXME
onMovementEnded: eventView.currentDayStart = currentDayStart
onCurrentDayStartChanged: if (!(dragging || flicking)) eventView.currentDayStart = currentDayStart
Component.onCompleted: eventView.currentDayStart = currentDayStart
}
EventView {
id: eventView
property real minY: monthView.y + monthView.compressedHeight
property real maxY: monthView.y + monthView.expandedHeight
y: maxY
width: mainView.width
height: parent.height - y
expanded: monthView.compressed
Component.onCompleted: {
incrementCurrentDay.connect(monthView.incrementCurrentDay)
decrementCurrentDay.connect(monthView.decrementCurrentDay)
}
onExpand: {
monthView.compressed = true
yBehavior.enabled = true
y = minY
}
onCompress: {
monthView.compressed = false
y = maxY
}
Behavior on y {
id: yBehavior
enabled: false
NumberAnimation { duration: 100 }
}
onNewEvent: mainView.newEvent()
}
signal newEvent
onNewEvent: PopupUtils.open(newEventComponent, mainView, {"defaultDate": monthView.currentDayStart})
Component {
id: newEventComponent
NewEvent {}
}
}
|