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

« back to all changes in this revision

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