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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
import "dateExt.js" as DateExt
MainView {
id: mainView
objectName: "calendar"
applicationName: "calendar-app"
width: units.gu(45)
height: units.gu(80)
headerColor: "#266249"
backgroundColor: "#478158"
footerColor: "#478158"
PageStack {
id: pageStack
Component.onCompleted: push(tabPage)
Page{
id: tabPage
property var currentDay: DateExt.today();
onCurrentDayChanged: {
if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))
monthView.currentMonth = currentDay.midnight();
if( !dayView.currentDay.isSameDay(currentDay))
dayView.currentDay = currentDay
if( !weekView.dayStart.isSameDay(currentDay))
weekView.dayStart = currentDay
}
function newEvent() {
PopupUtils.open(newEventComponent, tabPage, {"defaultDate": currentDay})
}
Component.onCompleted: {
tabs.selectedTabIndex= 1;
}
ToolbarItems {
id: commonToolBar
ToolbarButton {
objectName: "neweventbutton"
action: Action {
iconSource: Qt.resolvedUrl("avatar.png")
text: i18n.tr("New Event")
onTriggered: tabPage.newEvent()
}
}
ToolbarButton {
objectName: "todaybutton"
action: Action {
iconSource: Qt.resolvedUrl("avatar.png");
text: i18n.tr("Today");
onTriggered: {
tabPage.currentDay = (new Date()).midnight();
}
}
}
}
Tabs{
id: tabs
Tab{
title: i18n.tr("Year")
page: Page{
anchors.fill: parent
tools: commonToolBar
YearView{
onMonthSelected: {
tabs.selectedTabIndex = 1
var now = DateExt.today();
if( date.getMonth() === now.getMonth()
&& date.getFullYear() === now.getFullYear()) {
monthView.currentMonth = now
} else {
monthView.currentMonth = date.midnight();
}
}
}
}
}
Tab {
id: monthTab
title: i18n.tr("Month")
page: MonthView{
anchors.fill: parent
tools: commonToolBar
id: monthView
onDateSelected: {
tabs.selectedTabIndex = 3
tabPage.currentDay = date;
}
}
}
Tab{
title: i18n.tr("Week")
page: Page{
anchors.fill: parent
tools: commonToolBar
WeekView{
id: weekView
anchors.fill: parent
onDayStartChanged: {
tabPage.currentDay = dayStart;
}
}
}
}
Tab{
title: i18n.tr("Day")
page: Page{
anchors.fill: parent
tools: commonToolBar
DayView{
id: dayView
anchors.fill: parent
onCurrentDayChanged: {
tabPage.currentDay = currentDay;
}
}
}
}
}
Component {
id: newEventComponent
NewEvent {}
}
}
}
}
|