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/>.
2
import Ubuntu.Components 0.1
20
import Ubuntu.Components 1.1
21
4
import "dateExt.js" as DateExt
22
import "ViewType.js" as ViewType
5
import "dataService.js" as DataService
26
objectName: "weekViewPage"
28
11
property var dayStart: new Date();
29
property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
30
property bool isCurrentPage: false
32
signal dateSelected(var date);
34
Keys.forwardTo: [weekViewPath]
39
id: calendarTodayAction
40
objectName:"todaybutton"
41
iconName: "calendar-today"
42
text: i18n.tr("Today")
51
commonHeaderActions.newEventAction,
52
commonHeaderActions.showCalendarAction,
53
commonHeaderActions.reloadAction
58
objectName:"monthYearLabel"
60
text: i18n.tr(dayStart.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
61
font.capitalization: Font.Capitalize
67
anchors.topMargin: units.gu(1)
72
objectName: "weekHeader"
73
type: ViewType.ViewTypeWeek
77
weekViewPage.dateSelected(date);
83
objectName: "weekViewPath"
16
property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);
17
property var weekStart: weekViewPath.visibleWeek.addDays(-7)
19
anchors.top: parent.top
20
anchors.topMargin: units.gu(1.5)
22
height: parent.height - units.gu(3)
24
onNextItemHighlighted: {
28
onPreviousItemHighlighted: {
33
var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
34
dayStart = weekStartDay.addDays(7);
37
function previousWeek(){
38
var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
39
dayStart = weekStartDay.addDays(-7);
42
delegate: TimeLineBaseComponent {
85
47
width: parent.width
86
height: weekViewPage.height - weekViewPath.y
88
//This is used to scroll all view together when currentItem scrolls
89
property var childContentY;
91
onNextItemHighlighted: {
93
weekHeader.incrementCurrentIndex()
96
onPreviousItemHighlighted: {
98
weekHeader.decrementCurrentIndex()
101
function nextWeek() {
102
dayStart = firstDay.addDays(7);
105
function previousWeek(){
106
dayStart = firstDay.addDays(-7);
111
height: parent.height
112
asynchronous: !weekViewPath.isCurrentItem
113
sourceComponent: delegateComponent
116
id: delegateComponent
118
TimeLineBaseComponent {
121
type: ViewType.ViewTypeWeek
123
isActive: parent.PathView.isCurrentItem
124
startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
125
keyboardEventProvider: weekViewPath
127
Component.onCompleted: {
128
if(weekViewPage.isCurrentPage){
129
timeLineView.scrollToCurrentTime();
135
onIsCurrentPageChanged:{
136
if(weekViewPage.isCurrentPage){
137
timeLineView.scrollToCurrentTime();
142
//get contentY value from PathView, if its not current Item
146
value: weekViewPath.childContentY;
147
when: !parent.PathView.isCurrentItem
150
//set PathView's contentY property, if its current item
153
property: "childContentY"
155
when: parent.PathView.isCurrentItem
49
startDay: getWeekStart();
51
function getWeekStart() {
52
if (index === weekViewPath.currentIndex) {
53
return weekViewPath.weekStart;
55
var previousIndex = weekViewPath.currentIndex > 0 ? weekViewPath.currentIndex - 1 : 2
57
if ( index === previousIndex ) {
58
var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
59
return weekStartDay.addDays(14);
62
var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
63
return weekStartDay.addDays(7);