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

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
 */
455.3.5 by Nekhelesh Ramananthan
Small change
18
19
import QtQuick 2.3
422.5.1 by Akiva Avraham
Upgraded component library imports
20
import Ubuntu.Components 1.1
72.2.11 by Kunal Parmar
adding missing files
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
508.2.1 by Kunal Parmar
bug fixed
31
    signal dateSelected(var date);
32
183.1.1 by Kunal Parmar
Key Navigation implemented
33
    Keys.forwardTo: [dayViewPath]
212.4.18 by Kunal Parmar
error resolved
34
    flickable: null
455.3.6 by Nekhelesh Ramananthan
Just fixed the code indentation. No other change
35
455.3.1 by Mihir Soni
Removed duplicate header section from views and added common header
36
    Action {
455.3.6 by Nekhelesh Ramananthan
Just fixed the code indentation. No other change
37
        id: calendarTodayAction
38
        objectName:"todaybutton"
39
        iconName: "calendar-today"
40
        text: i18n.tr("Today")
41
        onTriggered: {
42
            currentDay = new Date()
43
        }
44
    }
455.3.1 by Mihir Soni
Removed duplicate header section from views and added common header
45
455.5.1 by Nekhelesh Ramananthan
Improved DayView.qml
46
    head {
47
        actions: [
48
            calendarTodayAction,
49
            commonHeaderActions.newEventAction,
50
            commonHeaderActions.showCalendarAction,
51
            commonHeaderActions.reloadAction
52
        ]
53
489.2.1 by Kunal Parmar
Dayview like iOS
54
        contents: Label {
55
            id:monthYear
56
            objectName:"monthYearLabel"
57
            fontSize: "x-large"
58
            text: i18n.tr(currentDay.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
59
            font.capitalization: Font.Capitalize
455.5.1 by Nekhelesh Ramananthan
Improved DayView.qml
60
        }
61
    }
62
489.2.1 by Kunal Parmar
Dayview like iOS
63
    Column {
212.1.2 by nskaggs
revert to 211
64
        anchors.fill: parent
489.2.1 by Kunal Parmar
Dayview like iOS
65
        anchors.topMargin: units.gu(1)
66
        spacing: units.gu(1)
67
68
        TimeLineHeader{
69
            id: dayHeader
70
            objectName: "dayHeader"
191.4.1 by Kunal Parmar
Applying changes
71
            type: ViewType.ViewTypeDay
489.2.1 by Kunal Parmar
Dayview like iOS
72
            currentDay: dayViewPage.currentDay
73
508.2.1 by Kunal Parmar
bug fixed
74
            onDateSelected: {
75
                dayViewPage.currentDay = date;
76
                dayViewPage.dateSelected(date);
77
            }
78
489.2.5 by Kunal Parmar
review comment
79
            onCurrentDayChanged: {
489.2.1 by Kunal Parmar
Dayview like iOS
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;
96.2.1 by Kunal Parmar
initial version
105
72.2.11 by Kunal Parmar
adding missing files
106
            width: parent.width
489.2.1 by Kunal Parmar
Dayview like iOS
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
522.1.1 by Kunal Parmar
week day view performance improvements
121
            delegate: Loader {
489.2.1 by Kunal Parmar
Dayview like iOS
122
                width: parent.width
123
                height: parent.height
522.1.1 by Kunal Parmar
week day view performance improvements
124
                asynchronous: !dayViewPath.isCurrentItem
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: {
143
                            if(dayViewPage.isCurrentPage){
144
                                timeLineView.scrollToCurrentTime();
145
                            }
146
                        }
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
489.2.1 by Kunal Parmar
Dayview like iOS
171
                        }
216.1.2 by Kunal Parmar
Refactoring
172
                    }
173
                }
489.2.1 by Kunal Parmar
Dayview like iOS
174
            }
72.2.11 by Kunal Parmar
adding missing files
175
        }
176
    }
177
}