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

« back to all changes in this revision

Viewing changes to WeekView.qml

  • Committer: Kunal Parmar
  • Date: 2014-11-15 08:02:45 UTC
  • Revision ID: pkunal.parmar@gmail.com-20141115080245-9f093ak1owlh5tl8
new day and week view

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
            //weekHeader.incrementCurrentIndex()
 
77
        }
 
78
 
 
79
        onPreviousItemHighlighted: {
 
80
            previousWeek();
 
81
            //weekHeader.decrementCurrentIndex()
 
82
        }
 
83
 
 
84
        function nextWeek() {
 
85
            dayStart = firstDay.addDays(7);
 
86
        }
 
87
 
 
88
        function previousWeek(){
 
89
            dayStart = firstDay.addDays(-7);
 
90
        }
 
91
 
 
92
        delegate: Loader {
85
93
            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: !weekViewPath.isCurrentItem
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: {
 
94
            height: parent.height
 
95
            asynchronous: !weekViewPath.isCurrentItem
 
96
            sourceComponent: delegateComponent
 
97
 
 
98
            Component{
 
99
                id: delegateComponent
 
100
 
 
101
                TimeLineBaseComponent {
 
102
                    id: timeLineView
 
103
 
 
104
                    type: ViewType.ViewTypeWeek
 
105
                    anchors.fill: parent
 
106
                    isActive: parent.PathView.isCurrentItem
 
107
                    startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
 
108
                    keyboardEventProvider: weekViewPath
 
109
 
 
110
                    Component.onCompleted: {
 
111
                        if(weekViewPage.isCurrentPage){
 
112
                            timeLineView.scrollToCurrentTime();
 
113
                        }
 
114
                    }
 
115
 
 
116
                    onDateSelected: {
 
117
                        weekViewPage.dateSelected(date);
 
118
                    }
 
119
 
 
120
                    Connections{
 
121
                        target: weekViewPage
 
122
                        onIsCurrentPageChanged:{
128
123
                            if(weekViewPage.isCurrentPage){
129
124
                                timeLineView.scrollToCurrentTime();
130
125
                            }
131
126
                        }
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
 
                        }
 
127
                    }
 
128
 
 
129
                    //get contentY value from PathView, if its not current Item
 
130
                    Binding{
 
131
                        target: timeLineView
 
132
                        property: "contentY"
 
133
                        value: weekViewPath.childContentY;
 
134
                        when: !parent.PathView.isCurrentItem
 
135
                    }
 
136
 
 
137
                    //set PathView's contentY property, if its current item
 
138
                    Binding{
 
139
                        target: weekViewPath
 
140
                        property: "childContentY"
 
141
                        value: contentY
 
142
                        when: parent.PathView.isCurrentItem
157
143
                    }
158
144
                }
159
145
            }