2
* Copyright (C) 2013-2014 Canonical Ltd
4
* This file is part of Ubuntu Calendar App
6
* Ubuntu Calendar App is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 3 as
8
* published by the Free Software Foundation.
10
* Ubuntu Calendar App is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
import Ubuntu.Components 1.1
21
import "dateExt.js" as DateExt
22
import "ViewType.js" as ViewType
26
objectName: "dayViewPage"
28
property var currentDay: new Date()
29
property bool isCurrentPage: false
31
signal dateSelected(var date);
33
Keys.forwardTo: [dayViewPath]
37
id: calendarTodayAction
38
objectName:"todaybutton"
39
iconName: "calendar-today"
40
text: i18n.tr("Today")
42
currentDay = new Date()
49
commonHeaderActions.newEventAction,
50
commonHeaderActions.showCalendarAction,
51
commonHeaderActions.reloadAction
56
objectName:"monthYearLabel"
58
text: i18n.tr(currentDay.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
59
font.capitalization: Font.Capitalize
65
anchors.topMargin: units.gu(1)
70
objectName: "dayHeader"
71
type: ViewType.ViewTypeDay
72
currentDay: dayViewPage.currentDay
75
dayViewPage.currentDay = date;
76
dayViewPage.dateSelected(date);
79
onCurrentDayChanged: {
80
date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
84
if(currentDay >= date.addDays(7)) {
85
date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
86
dayHeader.incrementCurrentIndex();
90
function previousDay() {
91
if( currentDay < date) {
92
date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
93
dayHeader.decrementCurrentIndex();
100
objectName: "dayViewPath"
102
property var startDay: currentDay
103
//This is used to scroll all view together when currentItem scrolls
104
property var childContentY;
107
height: dayViewPage.height - dayViewPath.y
109
onNextItemHighlighted: {
111
currentDay = currentDay.addDays(1);
115
onPreviousItemHighlighted: {
117
currentDay = currentDay.addDays(-1);
118
dayHeader.previousDay();
123
height: parent.height
124
asynchronous: !dayViewPath.isCurrentItem
125
sourceComponent: delegateComponent
128
id: delegateComponent
130
TimeLineBaseComponent {
132
objectName: "DayComponent-"+index
134
type: ViewType.ViewTypeDay
137
isActive: parent.PathView.isCurrentItem
138
contentInteractive: parent.PathView.isCurrentItem
139
startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
140
keyboardEventProvider: dayViewPath
142
Component.onCompleted: {
143
if(dayViewPage.isCurrentPage){
144
timeLineView.scrollToCurrentTime();
150
onIsCurrentPageChanged:{
151
if(dayViewPage.isCurrentPage){
152
timeLineView.scrollToCurrentTime();
157
//get contentY value from PathView, if its not current Item
161
value: dayViewPath.childContentY;
162
when: !parent.PathView.isCurrentItem
165
//set PathView's contentY property, if its current item
168
property: "childContentY"
170
when: parent.PathView.isCurrentItem