4
4
import "dateExt.js" as DateExt
8
8
objectName: "YearView"
10
9
property var currentYear: DateExt.today();
12
10
signal monthSelected(var date);
16
onNextItemHighlighted: {
17
currentYear = getDateFromYear(currentYear.getFullYear() + 1);
20
onPreviousItemHighlighted: {
21
currentYear = getDateFromYear(currentYear.getFullYear() - 1);
24
function getDateFromYear(year) {
25
return new Date(year,0,1,0,0,0,0);
32
property bool isCurrentItem: index == root.currentIndex
33
property var year: getYear();
36
switch( root.indexType(index)) {
40
return getDateFromYear(currentYear.getFullYear() - 1);
42
return getDateFromYear(currentYear.getFullYear() + 1);
17
onNextItemHighlighted: {
18
root.currentYear = pathView.getDateFromYear(root.currentYear.getFullYear() + 1);
21
onPreviousItemHighlighted: {
22
root.currentYear = pathView.getDateFromYear(root.currentYear.getFullYear() - 1);
25
function getDateFromYear(year) {
26
return new Date(year,0,1,0,0,0,0);
33
property bool isCurrentItem: index == pathView.currentIndex
34
property var year: getYear();
37
switch( pathView.indexType(index)) {
39
return root.currentYear;
41
return pathView.getDateFromYear(root.currentYear.getFullYear() - 1);
43
return pathView.getDateFromYear(root.currentYear.getFullYear() + 1);
48
anchors.top: parent.top
50
readonly property int minCellWidth: units.gu(30)
51
cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n)
49
anchors.top: parent.top
51
readonly property int minCellWidth: units.gu(30)
52
cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n)
52
53
{ return ((width / n >= minCellWidth) ? width / n : width / 2) })))
54
cellHeight: cellWidth * 1.4
56
model: 12 /* months in a year */
58
width: yearView.cellWidth
59
height: yearView.cellHeight
63
monthDate: new Date(yearView.year.getFullYear(),index,1,0,0,0,0)
65
anchors.margins: units.gu(0.5)
67
dayLabelFontSize:"x-small"
68
dateLabelFontSize: "medium"
69
monthLabelFontSize: "medium"
70
yearLabelFontSize: "small"
55
cellHeight: cellWidth * 1.4
57
model: 12 /* months in a year */
59
width: yearView.cellWidth
60
height: yearView.cellHeight
64
monthDate: new Date(yearView.year.getFullYear(),index,1,0,0,0,0)
73
65
anchors.fill: parent
75
root.monthSelected(monthComponent.monthDate);
66
anchors.margins: units.gu(0.5)
68
dayLabelFontSize:"x-small"
69
dateLabelFontSize: "medium"
70
monthLabelFontSize: "medium"
71
yearLabelFontSize: "small"
76
root.monthSelected(monthComponent.monthDate);