~pkunal-parmar/ubuntu-calendar-app/Minor-Performance

400.1.1 by mihirsoni-123
Added copyright header comments in all the pages
1
/*
400.1.2 by mihirsoni-123
updated copyright year
2
 * Copyright (C) 2013-2014 Canonical Ltd
400.1.1 by mihirsoni-123
Added copyright header comments in all the pages
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
 */
72.2.11 by Kunal Parmar
adding missing files
18
import QtQuick 2.0
422.5.1 by Akiva Avraham
Upgraded component library imports
19
import Ubuntu.Components 1.1
72.2.11 by Kunal Parmar
adding missing files
20
21
import "dateExt.js" as DateExt
191.4.1 by Kunal Parmar
Applying changes
22
import "ViewType.js" as ViewType
72.2.11 by Kunal Parmar
adding missing files
23
235.1.1 by Kunal Parmar
View to PAge
24
Page{
338.1.1 by Nicholas Skaggs
restructure yearview, add test
25
    id: dayViewPage
26
    objectName: "dayViewPage"
72.2.31 by Kunal Parmar
Re-apply revision 98.
27
72.2.11 by Kunal Parmar
adding missing files
28
    property var currentDay: new Date()
216.1.2 by Kunal Parmar
Refactoring
29
    property bool isCurrentPage: false
72.2.11 by Kunal Parmar
adding missing files
30
183.1.1 by Kunal Parmar
Key Navigation implemented
31
    Keys.forwardTo: [dayViewPath]
212.4.18 by Kunal Parmar
error resolved
32
    flickable: null
183.1.1 by Kunal Parmar
Key Navigation implemented
33
114.2.1 by Kunal Parmar
dayview weekview transition added
34
    Column {
35
        id: column
96.2.2 by Kunal Parmar
final weekview and dayview
36
        anchors.top: parent.top
37
        anchors.topMargin: units.gu(1.5)
212.1.2 by nskaggs
revert to 211
38
        width: parent.width; height: parent.height
124.4.1 by Kunal Parmar
Background added to day labels
39
        spacing: units.gu(1)
114.2.1 by Kunal Parmar
dayview weekview transition added
40
212.1.2 by nskaggs
revert to 211
41
        anchors.fill: parent
42
114.2.1 by Kunal Parmar
dayview weekview transition added
43
        ViewHeader{
44
            id: viewHeader
199.1.2 by Kunal Parmar
Code clean up and further improvemnts
45
            month: currentDay.getMonth()
46
            year: currentDay.getFullYear()
114.2.1 by Kunal Parmar
dayview weekview transition added
47
        }
48
49
        TimeLineHeader{
50
            id: dayHeader
191.4.1 by Kunal Parmar
Applying changes
51
            type: ViewType.ViewTypeDay
114.2.3 by Kunal Parmar
dayview header changed
52
            date: currentDay
53
            preferredHighlightBegin: 0.5
54
            preferredHighlightEnd: 0.5
55
            path: Path {
56
                startX: -(dayHeader.width/7); startY: dayHeader.height/2
57
                PathLine { x: (dayHeader.width/7) * 8  ; relativeY: 0;  }
58
            }
341.1.1 by nskaggs
first pass at test_switch_day_by_tapping
59
            onDateSelected: {
60
                if(date < currentDay){
61
                    currentDay = currentDay.addDays(-1);
62
                    dayHeader.decrementCurrentIndex()
63
                }
64
                else if( date > currentDay){
65
                     currentDay = currentDay.addDays(1);
66
                     dayHeader.incrementCurrentIndex();
67
                 }
68
             }
114.2.1 by Kunal Parmar
dayview weekview transition added
69
        }
70
71
        PathViewBase{
72
            id: dayViewPath
338.1.1 by Nicholas Skaggs
restructure yearview, add test
73
            objectName: "dayViewPath"
114.2.1 by Kunal Parmar
dayview weekview transition added
74
75
            property var startDay: currentDay
151.1.1 by Kunal Parmar
Day view all component act as one
76
            //This is used to scroll all view together when currentItem scrolls
77
            property var childContentY;
114.2.1 by Kunal Parmar
dayview weekview transition added
78
79
            preferredHighlightBegin: 0.5
80
            preferredHighlightEnd: 0.5
96.2.1 by Kunal Parmar
initial version
81
72.2.11 by Kunal Parmar
adding missing files
82
            width: parent.width
188.2.1 by Samer Masterson
* Changes the height of the frame to fit the window.
83
            height: column.height - dayViewPath.y
114.2.1 by Kunal Parmar
dayview weekview transition added
84
85
            path: Path {
86
                startX: -(dayViewPath.width/1.75); startY: dayViewPath.height/2
87
                PathLine { x: (dayViewPath.width/7) * 11  ; relativeY: 0;  }
88
            }
89
90
            onNextItemHighlighted: {
91
                //next day
92
                currentDay = currentDay.addDays(1);
93
                dayHeader.incrementCurrentIndex()
94
            }
95
96
            onPreviousItemHighlighted: {
97
                //previous day
98
                currentDay = currentDay.addDays(-1);
99
                dayHeader.decrementCurrentIndex()
100
            }
101
102
            delegate: TimeLineBaseComponent {
103
                id: timeLineView
104
                objectName: "DayComponent-"+index
105
191.4.1 by Kunal Parmar
Applying changes
106
                type: ViewType.ViewTypeDay
114.2.1 by Kunal Parmar
dayview weekview transition added
107
108
                width: parent.width/7 * 5
109
                height: parent.height
110
                z: index == dayViewPath.currentIndex ? 2 : 1
295.1.1 by Kunal Parmar
Parallex fix for EventBubble
111
                isActive: true
114.2.1 by Kunal Parmar
dayview weekview transition added
112
216.1.2 by Kunal Parmar
Refactoring
113
                Connections{
338.1.1 by Nicholas Skaggs
restructure yearview, add test
114
                    target: dayViewPage
216.1.2 by Kunal Parmar
Refactoring
115
                    onIsCurrentPageChanged:{
338.1.1 by Nicholas Skaggs
restructure yearview, add test
116
                        if(dayViewPage.isCurrentPage){
216.1.2 by Kunal Parmar
Refactoring
117
                            timeLineView.scrollToCurrentTime();
118
                        }
119
                    }
120
                }
121
151.1.1 by Kunal Parmar
Day view all component act as one
122
                //get contentY value from PathView, if its not current Item
123
                Binding{
124
                    target: timeLineView
125
                    property: "contentY"
126
                    value: dayViewPath.childContentY;
127
                    when: !timeLineView.PathView.isCurrentItem
128
                }
129
130
                //set PathView's contentY property, if its current item
131
                Binding{
132
                    target: dayViewPath
133
                    property: "childContentY"
134
                    value: contentY
135
                    when: timeLineView.PathView.isCurrentItem
136
                }
137
138
                contentInteractive: timeLineView.PathView.isCurrentItem
139
253.1.3 by Kunal Parmar
Trim dayview
140
                startDay: dayViewPath.startDay.addDays(dayViewPath.indexType(index))
72.2.11 by Kunal Parmar
adding missing files
141
            }
142
        }
143
    }
144
}