~carla-sella/ubuntu-calendar-app/fix-dayview-default-view

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,
581.3.1 by Andrew Hayzen
* Add sync header action to AgendaView.qml DayView.qml MonthView.qml WeekView.qml YearView.qml
51
            commonHeaderActions.reloadAction,
52
            commonHeaderActions.syncCalendarAction
455.5.1 by Nekhelesh Ramananthan
Improved DayView.qml
53
        ]
54
489.2.1 by Kunal Parmar
Dayview like iOS
55
        contents: Label {
56
            id:monthYear
57
            objectName:"monthYearLabel"
58
            fontSize: "x-large"
59
            text: i18n.tr(currentDay.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
60
            font.capitalization: Font.Capitalize
455.5.1 by Nekhelesh Ramananthan
Improved DayView.qml
61
        }
62
    }
63
550.3.1 by Kunal Parmar
new day and week view
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
212.1.2 by nskaggs
revert to 211
72
        anchors.fill: parent
550.3.1 by Kunal Parmar
new day and week view
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 {
72.2.11 by Kunal Parmar
adding missing files
85
            width: parent.width
550.3.1 by Kunal Parmar
new day and week view
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:{
522.1.1 by Kunal Parmar
week day view performance improvements
114
                            if(dayViewPage.isCurrentPage){
115
                                timeLineView.scrollToCurrentTime();
116
                            }
117
                        }
550.3.1 by Kunal Parmar
new day and week view
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
216.1.2 by Kunal Parmar
Refactoring
134
                    }
135
                }
489.2.1 by Kunal Parmar
Dayview like iOS
136
            }
72.2.11 by Kunal Parmar
adding missing files
137
        }
138
    }
139
}