~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

Viewing changes to WeekView.qml

  • Committer: Olivier Tilloy
  • Date: 2013-04-04 10:49:53 UTC
  • mto: (1.2.1 ubuntu-phone-commons)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: olivier.tilloy@canonical.com-20130404104953-z2tu4p2bj5k0omvg
Updated maintainer field of the control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013-2014 Canonical Ltd
3
 
 *
4
 
 * This file is part of Ubuntu Calendar App
5
 
 *
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.
9
 
 *
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.
14
 
 *
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/>.
17
 
 */
18
 
 
19
 
import QtQuick 2.3
20
 
import Ubuntu.Components 1.1
21
 
import "dateExt.js" as DateExt
22
 
import "ViewType.js" as ViewType
23
 
 
24
 
Page{
25
 
    id: weekViewPage
26
 
    objectName: "weekViewPage"
27
 
 
28
 
    property var dayStart: new Date();
29
 
    property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
30
 
    property bool isCurrentPage: false
31
 
 
32
 
    signal dateSelected(var date);
33
 
 
34
 
    Keys.forwardTo: [weekViewPath]
35
 
 
36
 
    flickable: null
37
 
 
38
 
    Action {
39
 
        id: calendarTodayAction
40
 
        objectName:"todaybutton"
41
 
        iconName: "calendar-today"
42
 
        text: i18n.tr("Today")
43
 
        onTriggered: {
44
 
            dayStart = new Date()
45
 
        }
46
 
    }
47
 
 
48
 
    head {
49
 
        actions: [
50
 
            calendarTodayAction,
51
 
            commonHeaderActions.newEventAction,
52
 
            commonHeaderActions.showCalendarAction,
53
 
            commonHeaderActions.reloadAction
54
 
        ]
55
 
 
56
 
        contents: Label {
57
 
            id:monthYear
58
 
            objectName:"monthYearLabel"
59
 
            fontSize: "x-large"
60
 
            text: i18n.tr(dayStart.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
61
 
            font.capitalization: Font.Capitalize
62
 
        }
63
 
    }
64
 
 
65
 
    Column {
66
 
        anchors.fill: parent
67
 
        anchors.topMargin: units.gu(1)
68
 
        spacing: units.gu(1)
69
 
 
70
 
        TimeLineHeader{
71
 
            id: weekHeader
72
 
            objectName: "weekHeader"
73
 
            type: ViewType.ViewTypeWeek
74
 
            date: firstDay
75
 
 
76
 
            onDateSelected: {
77
 
                weekViewPage.dateSelected(date);
78
 
            }
79
 
        }
80
 
 
81
 
        PathViewBase{
82
 
            id: weekViewPath
83
 
            objectName: "weekViewPath"
84
 
 
85
 
            width: parent.width
86
 
            height: weekViewPage.height - weekViewPath.y
87
 
 
88
 
            //This is used to scroll all view together when currentItem scrolls
89
 
            property var childContentY;
90
 
 
91
 
            onNextItemHighlighted: {
92
 
                nextWeek();
93
 
                weekHeader.incrementCurrentIndex()
94
 
            }
95
 
 
96
 
            onPreviousItemHighlighted: {
97
 
                previousWeek();
98
 
                weekHeader.decrementCurrentIndex()
99
 
            }
100
 
 
101
 
            function nextWeek() {
102
 
                dayStart = firstDay.addDays(7);
103
 
            }
104
 
 
105
 
            function previousWeek(){
106
 
                dayStart = firstDay.addDays(-7);
107
 
            }
108
 
 
109
 
            delegate: TimeLineBaseComponent {
110
 
                id: timeLineView
111
 
 
112
 
                type: ViewType.ViewTypeWeek
113
 
 
114
 
                width: parent.width
115
 
                height: parent.height
116
 
 
117
 
                isActive: timeLineView.PathView.isCurrentItem
118
 
 
119
 
                startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
120
 
 
121
 
                Connections{
122
 
                    target: weekViewPage
123
 
                    onIsCurrentPageChanged:{
124
 
                        if(weekViewPage.isCurrentPage){
125
 
                            timeLineView.scrollToCurrentTime();
126
 
                        }
127
 
                    }
128
 
                }
129
 
 
130
 
                //get contentY value from PathView, if its not current Item
131
 
                Binding{
132
 
                    target: timeLineView
133
 
                    property: "contentY"
134
 
                    value: weekViewPath.childContentY;
135
 
                    when: !timeLineView.PathView.isCurrentItem
136
 
                }
137
 
 
138
 
                //set PathView's contentY property, if its current item
139
 
                Binding{
140
 
                    target: weekViewPath
141
 
                    property: "childContentY"
142
 
                    value: contentY
143
 
                    when: timeLineView.PathView.isCurrentItem
144
 
                }
145
 
            }
146
 
        }
147
 
    }
148
 
}