~pkunal-parmar/ubuntu-calendar-app/LongPressToCreate

« back to all changes in this revision

Viewing changes to WeekView.qml

  • Committer: Tarmac
  • Author(s): Kunal Parmar
  • Date: 2015-01-08 17:13:47 UTC
  • mfrom: (550.3.7 ubuntu-calendar-app)
  • Revision ID: tarmac-20150108171347-k3tlx60ijghpkm3s
Required changed for new dayview and weekview .

Approved by Nekhelesh Ramananthan, Nicholas Skaggs, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        }
63
63
    }
64
64
 
65
 
    Column {
 
65
    PathViewBase{
 
66
        id: weekViewPath
 
67
        objectName: "weekViewPath"
 
68
 
66
69
        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
 
 
 
70
 
 
71
        //This is used to scroll all view together when currentItem scrolls
 
72
        property var childContentY;
 
73
 
 
74
        onNextItemHighlighted: {
 
75
            nextWeek();
 
76
        }
 
77
 
 
78
        onPreviousItemHighlighted: {
 
79
            previousWeek();
 
80
        }
 
81
 
 
82
        function nextWeek() {
 
83
            dayStart = firstDay.addDays(7);
 
84
        }
 
85
 
 
86
        function previousWeek(){
 
87
            dayStart = firstDay.addDays(-7);
 
88
        }
 
89
 
 
90
        delegate: Loader {
85
91
            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: Loader {
110
 
                width: parent.width
111
 
                height: parent.height
112
 
                asynchronous: index !== weekViewPath.currentIndex
113
 
                sourceComponent: delegateComponent
114
 
 
115
 
                Component{
116
 
                    id: delegateComponent
117
 
 
118
 
                    TimeLineBaseComponent {
119
 
                        id: timeLineView
120
 
 
121
 
                        type: ViewType.ViewTypeWeek
122
 
                        anchors.fill: parent
123
 
                        isActive: parent.PathView.isCurrentItem
124
 
                        startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
125
 
                        keyboardEventProvider: weekViewPath
126
 
 
127
 
                        Component.onCompleted: {
 
92
            height: parent.height
 
93
            asynchronous: !weekViewPath.isCurrentItem
 
94
            sourceComponent: delegateComponent
 
95
 
 
96
            Component{
 
97
                id: delegateComponent
 
98
 
 
99
                TimeLineBaseComponent {
 
100
                    id: timeLineView
 
101
 
 
102
                    type: ViewType.ViewTypeWeek
 
103
                    anchors.fill: parent
 
104
                    isActive: parent.PathView.isCurrentItem
 
105
                    startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
 
106
                    keyboardEventProvider: weekViewPath
 
107
 
 
108
                    Component.onCompleted: {
 
109
                        if(weekViewPage.isCurrentPage){
 
110
                            timeLineView.scrollToCurrentTime();
 
111
                        }
 
112
                    }
 
113
 
 
114
                    onDateSelected: {
 
115
                        weekViewPage.dateSelected(date);
 
116
                    }
 
117
 
 
118
                    Connections{
 
119
                        target: weekViewPage
 
120
                        onIsCurrentPageChanged:{
128
121
                            if(weekViewPage.isCurrentPage){
129
122
                                timeLineView.scrollToCurrentTime();
130
123
                            }
131
124
                        }
132
 
 
133
 
                        Connections{
134
 
                            target: weekViewPage
135
 
                            onIsCurrentPageChanged:{
136
 
                                if(weekViewPage.isCurrentPage){
137
 
                                    timeLineView.scrollToCurrentTime();
138
 
                                }
139
 
                            }
140
 
                        }
141
 
 
142
 
                        //get contentY value from PathView, if its not current Item
143
 
                        Binding{
144
 
                            target: timeLineView
145
 
                            property: "contentY"
146
 
                            value: weekViewPath.childContentY;
147
 
                            when: !parent.PathView.isCurrentItem
148
 
                        }
149
 
 
150
 
                        //set PathView's contentY property, if its current item
151
 
                        Binding{
152
 
                            target: weekViewPath
153
 
                            property: "childContentY"
154
 
                            value: contentY
155
 
                            when: parent.PathView.isCurrentItem
156
 
                        }
 
125
                    }
 
126
 
 
127
                    //get contentY value from PathView, if its not current Item
 
128
                    Binding{
 
129
                        target: timeLineView
 
130
                        property: "contentY"
 
131
                        value: weekViewPath.childContentY;
 
132
                        when: !parent.PathView.isCurrentItem
 
133
                    }
 
134
 
 
135
                    //set PathView's contentY property, if its current item
 
136
                    Binding{
 
137
                        target: weekViewPath
 
138
                        property: "childContentY"
 
139
                        value: contentY
 
140
                        when: parent.PathView.isCurrentItem
157
141
                    }
158
142
                }
159
143
            }