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
Keys.forwardTo: [dayViewPath]
35
id: calendarTodayAction
36
objectName:"todaybutton"
37
iconName: "calendar-today"
38
text: i18n.tr("Today")
40
currentDay = new Date()
47
commonHeaderActions.newEventAction,
48
commonHeaderActions.showCalendarAction,
49
commonHeaderActions.reloadAction
54
objectName:"monthYearLabel"
56
text: i18n.tr(currentDay.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
57
font.capitalization: Font.Capitalize
63
anchors.topMargin: units.gu(1)
68
objectName: "dayHeader"
69
type: ViewType.ViewTypeDay
70
currentDay: dayViewPage.currentDay
72
onCurrentDayChanged: {
73
date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
77
if(currentDay >= date.addDays(7)) {
78
date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
79
dayHeader.incrementCurrentIndex();
83
function previousDay() {
84
if( currentDay < date) {
85
date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
86
dayHeader.decrementCurrentIndex();
93
objectName: "dayViewPath"
95
property var startDay: currentDay
96
//This is used to scroll all view together when currentItem scrolls
97
property var childContentY;
100
height: dayViewPage.height - dayViewPath.y
102
onNextItemHighlighted: {
104
currentDay = currentDay.addDays(1);
108
onPreviousItemHighlighted: {
110
currentDay = currentDay.addDays(-1);
111
dayHeader.previousDay();
114
delegate: TimeLineBaseComponent {
116
objectName: "DayComponent-"+index
118
type: ViewType.ViewTypeDay
121
height: parent.height
122
z: index == dayViewPath.currentIndex ? 2 : 1
127
onIsCurrentPageChanged:{
128
if(dayViewPage.isCurrentPage){
129
timeLineView.scrollToCurrentTime();
134
//get contentY value from PathView, if its not current Item
138
value: dayViewPath.childContentY;
139
when: !timeLineView.PathView.isCurrentItem
142
//set PathView's contentY property, if its current item
145
property: "childContentY"
147
when: timeLineView.PathView.isCurrentItem
150
contentInteractive: timeLineView.PathView.isCurrentItem
152
startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))