~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
 */
455.3.5 by Nekhelesh Ramananthan
Small change
18
import QtQuick 2.3
422.5.1 by Akiva Avraham
Upgraded component library imports
19
import Ubuntu.Components 1.1
7.2.2 by Frank Mertens
Added test application calendarTests.qml and improved the data service.
20
import "dateExt.js" as DateExt
4.2.11 by Frank Mertens
Added methods for stepping days.
21
import "colorUtils.js" as Color
3 by Frank Mertens
Initial code for the month view. Also bootstrapped a small extension library for JS::Date.
22
212.1.2 by nskaggs
revert to 211
23
Page {
24
    id: monthViewPage
338.1.6 by nskaggs
fix objectnames, add object passing
25
    objectName: "monthViewPage"
94.1.1 by Kunal Parmar
MonthView/YearView chaged according to new design
26
27
    property var currentMonth: DateExt.today();
212.1.2 by nskaggs
revert to 211
28
94.1.1 by Kunal Parmar
MonthView/YearView chaged according to new design
29
    signal dateSelected(var date);
30
183.1.1 by Kunal Parmar
Key Navigation implemented
31
    Keys.forwardTo: [monthViewPath]
455.3.6 by Nekhelesh Ramananthan
Just fixed the code indentation. No other change
32
455.3.1 by Mihir Soni
Removed duplicate header section from views and added common header
33
    Action {
455.3.6 by Nekhelesh Ramananthan
Just fixed the code indentation. No other change
34
        id: calendarTodayAction
35
        objectName:"todaybutton"
36
        iconName: "calendar-today"
37
        text: i18n.tr("Today")
38
        onTriggered: {
39
            currentMonth = new Date().midnight()
40
        }
41
    }
455.3.1 by Mihir Soni
Removed duplicate header section from views and added common header
42
460.1.1 by Mihir Soni
improved yearview & Monthview
43
    head {
44
        actions: [
45
            calendarTodayAction,
46
            commonHeaderActions.newEventAction,
47
            commonHeaderActions.showCalendarAction,
48
            commonHeaderActions.reloadAction
49
        ]
50
51
        contents: Label {
52
            fontSize: "x-large"
467.1.1 by David Planella
Translation improvements
53
            // TRANSLATORS: this is a time formatting string,
54
            // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
55
            // It's used in the header of the month and week views
460.1.1 by Mihir Soni
improved yearview & Monthview
56
            text: i18n.tr(currentMonth.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy")))
467.1.1 by David Planella
Translation improvements
57
            font.capitalization: Font.Capitalize
460.1.1 by Mihir Soni
improved yearview & Monthview
58
        }
59
    }
183.1.1 by Kunal Parmar
Key Navigation implemented
60
174.1.12 by Kunal Parmar
LoaderPage replaced by Loader
61
    PathViewBase{
62
        id: monthViewPath
338.1.4 by Nicholas Skaggs
standardize object names, tweak setups
63
        objectName: "monthViewPath"
212.1.2 by nskaggs
revert to 211
64
65
        property var startMonth: currentMonth;
66
67
        anchors.top:parent.top
68
69
        width:parent.width
70
        height: parent.height
174.1.12 by Kunal Parmar
LoaderPage replaced by Loader
71
72
        onNextItemHighlighted: {
73
            nextMonth();
74
        }
75
76
        onPreviousItemHighlighted: {
77
            previousMonth();
78
        }
79
80
        function nextMonth() {
222.3.12 by Bartosz Kosiorek
Use signals instead of direct call method from YearView
81
            currentMonth = addMonth(currentMonth, 1);
82
        }
83
84
        function previousMonth() {
85
            currentMonth = addMonth(currentMonth, -1);
86
        }
87
88
        function addMonth(date,month) {
89
            return  new Date(date.getFullYear(), date.getMonth() + month, 1, 0, 0, 0);
90
        }
91
92
        delegate: MonthComponent {
174.1.12 by Kunal Parmar
LoaderPage replaced by Loader
93
            property bool isCurrentItem: index === monthViewPath.currentIndex
94
240.1.1 by Kunal Parmar
Events on MonthView
95
            showEvents: true
96
460.1.1 by Mihir Soni
improved yearview & Monthview
97
            width: parent.width - units.gu(4)
98
            height: parent.height
174.1.12 by Kunal Parmar
LoaderPage replaced by Loader
99
253.1.4 by Kunal Parmar
formating
100
            currentMonth: monthViewPath.addMonth(monthViewPath.startMonth,
101
                                                 monthViewPath.indexType(index));
102
222.3.12 by Bartosz Kosiorek
Use signals instead of direct call method from YearView
103
            isYearView: false
174.1.12 by Kunal Parmar
LoaderPage replaced by Loader
104
105
            onDateSelected: {
212.1.2 by nskaggs
revert to 211
106
                monthViewPage.dateSelected(date);
174.1.12 by Kunal Parmar
LoaderPage replaced by Loader
107
            }
94.1.1 by Kunal Parmar
MonthView/YearView chaged according to new design
108
        }
4.2.6 by Frank Mertens
First prototype of the horizontally flicking month view.
109
    }
3 by Frank Mertens
Initial code for the month view. Also bootstrapped a small extension library for JS::Date.
110
}