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

« back to all changes in this revision

Viewing changes to DayView.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:
60
60
        }
61
61
    }
62
62
 
63
 
    Column {
 
63
    PathViewBase{
 
64
        id: dayViewPath
 
65
        objectName: "dayViewPath"
 
66
 
 
67
        property var startDay: currentDay
 
68
        //This is used to scroll all view together when currentItem scrolls
 
69
        property var childContentY;
 
70
 
64
71
        anchors.fill: parent
65
 
        anchors.topMargin: units.gu(1)
66
 
        spacing: units.gu(1)
67
 
 
68
 
        TimeLineHeader{
69
 
            id: dayHeader
70
 
            objectName: "dayHeader"
71
 
            type: ViewType.ViewTypeDay
72
 
            currentDay: dayViewPage.currentDay
73
 
 
74
 
            onDateSelected: {
75
 
                dayViewPage.currentDay = date;
76
 
                dayViewPage.dateSelected(date);
77
 
            }
78
 
 
79
 
            onCurrentDayChanged: {
80
 
                date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
81
 
            }
82
 
 
83
 
            function nextDay() {
84
 
                if(currentDay >= date.addDays(7)) {
85
 
                    date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
86
 
                    dayHeader.incrementCurrentIndex();
87
 
                }
88
 
            }
89
 
 
90
 
            function previousDay() {
91
 
                if( currentDay < date) {
92
 
                    date = dayViewPage.currentDay.weekStart(Qt.locale().firstDayOfWeek);
93
 
                    dayHeader.decrementCurrentIndex();
94
 
                }
95
 
            }
96
 
        }
97
 
 
98
 
        PathViewBase{
99
 
            id: dayViewPath
100
 
            objectName: "dayViewPath"
101
 
 
102
 
            property var startDay: currentDay
103
 
            //This is used to scroll all view together when currentItem scrolls
104
 
            property var childContentY;
105
 
 
 
72
 
 
73
        onNextItemHighlighted: {
 
74
            //next day
 
75
            currentDay = currentDay.addDays(1);
 
76
        }
 
77
 
 
78
        onPreviousItemHighlighted: {
 
79
            //previous day
 
80
            currentDay = currentDay.addDays(-1);
 
81
        }
 
82
 
 
83
        delegate: Loader {
106
84
            width: parent.width
107
 
            height: dayViewPage.height - dayViewPath.y
108
 
 
109
 
            onNextItemHighlighted: {
110
 
                //next day
111
 
                currentDay = currentDay.addDays(1);
112
 
                dayHeader.nextDay();
113
 
            }
114
 
 
115
 
            onPreviousItemHighlighted: {
116
 
                //previous day
117
 
                currentDay = currentDay.addDays(-1);
118
 
                dayHeader.previousDay();
119
 
            }
120
 
 
121
 
            delegate: Loader {
122
 
                width: parent.width
123
 
                height: parent.height
124
 
                asynchronous: index !== dayViewPath.currentIndex
125
 
                sourceComponent: delegateComponent
126
 
 
127
 
                Component {
128
 
                    id: delegateComponent
129
 
 
130
 
                    TimeLineBaseComponent {
131
 
                        id: timeLineView
132
 
                        objectName: "DayComponent-"+index
133
 
 
134
 
                        type: ViewType.ViewTypeDay
135
 
                        anchors.fill: parent
136
 
 
137
 
                        isActive: parent.PathView.isCurrentItem
138
 
                        contentInteractive: parent.PathView.isCurrentItem
139
 
                        startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
140
 
                        keyboardEventProvider: dayViewPath
141
 
 
142
 
                        Component.onCompleted: {
 
85
            height: parent.height
 
86
            asynchronous: !dayViewPath.isCurrentItem
 
87
            sourceComponent: delegateComponent
 
88
 
 
89
            Component {
 
90
                id: delegateComponent
 
91
 
 
92
                TimeLineBaseComponent {
 
93
                    id: timeLineView
 
94
                    objectName: "DayComponent-"+index
 
95
 
 
96
                    type: ViewType.ViewTypeDay
 
97
                    anchors.fill: parent
 
98
 
 
99
                    isActive: parent.PathView.isCurrentItem
 
100
                    contentInteractive: parent.PathView.isCurrentItem
 
101
                    startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
 
102
                    keyboardEventProvider: dayViewPath
 
103
 
 
104
                    Component.onCompleted: {
 
105
                        if(dayViewPage.isCurrentPage){
 
106
                            timeLineView.scrollToCurrentTime();
 
107
                        }
 
108
                    }
 
109
 
 
110
                    Connections{
 
111
                        target: dayViewPage
 
112
                        onIsCurrentPageChanged:{
143
113
                            if(dayViewPage.isCurrentPage){
144
114
                                timeLineView.scrollToCurrentTime();
145
115
                            }
146
116
                        }
147
 
 
148
 
                        Connections{
149
 
                            target: dayViewPage
150
 
                            onIsCurrentPageChanged:{
151
 
                                if(dayViewPage.isCurrentPage){
152
 
                                    timeLineView.scrollToCurrentTime();
153
 
                                }
154
 
                            }
155
 
                        }
156
 
 
157
 
                        //get contentY value from PathView, if its not current Item
158
 
                        Binding{
159
 
                            target: timeLineView
160
 
                            property: "contentY"
161
 
                            value: dayViewPath.childContentY;
162
 
                            when: !parent.PathView.isCurrentItem
163
 
                        }
164
 
 
165
 
                        //set PathView's contentY property, if its current item
166
 
                        Binding{
167
 
                            target: dayViewPath
168
 
                            property: "childContentY"
169
 
                            value: contentY
170
 
                            when: parent.PathView.isCurrentItem
171
 
                        }
 
117
                    }
 
118
 
 
119
                    //get contentY value from PathView, if its not current Item
 
120
                    Binding{
 
121
                        target: timeLineView
 
122
                        property: "contentY"
 
123
                        value: dayViewPath.childContentY;
 
124
                        when: !parent.PathView.isCurrentItem
 
125
                    }
 
126
 
 
127
                    //set PathView's contentY property, if its current item
 
128
                    Binding{
 
129
                        target: dayViewPath
 
130
                        property: "childContentY"
 
131
                        value: contentY
 
132
                        when: parent.PathView.isCurrentItem
172
133
                    }
173
134
                }
174
135
            }