2
* Copyright (C) 2013-2014 Canonical Ltd
4
* This file is part of Ubuntu Calendar App
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.
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.
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/>.
20
import Ubuntu.Components 1.1
22
import "dateExt.js" as DateExt
25
objectName: "yearViewPage"
27
property int currentYear: DateExt.today().getFullYear();
2
import Ubuntu.Components 0.1
8
property var year: getDateFromYear(intern.now.getFullYear()-1);
28
10
signal monthSelected(var date);
30
Keys.forwardTo: [yearPathView]
33
id: calendarTodayAction
34
objectName:"todaybutton"
35
iconName: "calendar-today"
36
text: i18n.tr("Today")
38
currentYear = new Date().getFullYear()
45
commonHeaderActions.newEventAction,
46
commonHeaderActions.showCalendarAction,
47
commonHeaderActions.reloadAction,
48
commonHeaderActions.syncCalendarAction
52
objectName:"yearLabel"
54
text: i18n.tr("Year %1").arg(currentYear)
60
objectName: "yearPathView"
64
onNextItemHighlighted: {
65
currentYear = currentYear + 1;
68
onPreviousItemHighlighted: {
69
currentYear = currentYear - 1;
12
onNextItemHighlighted: {
13
year = getDateFromYear(year.getFullYear() + 1);
16
onPreviousItemHighlighted: {
17
year = getDateFromYear(year.getFullYear() - 1);
20
function getDateFromYear(year) {
21
return new Date(year,0,1,0,0,0,0);
26
property var now: new Date()
27
property int weekstartDay: Qt.locale().firstDayOfWeek
34
if (index === root.currentIndex) {
37
var previousIndex = root.currentIndex > 0 ? root.currentIndex - 1 : 2
39
if ( index === previousIndex ) {
40
return getDateFromYear(root.year.getFullYear()-1);
43
return getDateFromYear(root.year.getFullYear()+ 1);
51
text: year.getFullYear()
53
anchors.horizontalCenter: parent.horizontalCenter
73
62
width: parent.width
74
63
height: parent.height
75
anchors.top: parent.top
77
asynchronous: index !== yearPathView.currentIndex
78
sourceComponent: delegateComponent
84
focus: index == yearPathView.currentIndex
87
isCurrentItem: index == yearPathView.currentIndex
88
year: (yearViewPage.currentYear + yearPathView.indexType(index))
64
anchors.top: yearLabel.bottom
65
spacing: units.gu(2.5)
68
model: yearGrid.rows * yearGrid.columns
69
delegate: MonthComponent{
70
date: new Date(year.getFullYear(),index,1,0,0,0,0)
73
root.monthSelected(date);