63.1.1
by Kunal Parmar
year view implementation |
1 |
import QtQuick 2.0 |
2 |
import Ubuntu.Components 0.1 |
|
3 |
||
94.1.1
by Kunal Parmar
MonthView/YearView chaged according to new design |
4 |
import "dateExt.js" as DateExt |
222.3.8
by Bartosz Kosiorek
Sync with lp:ubuntu-calendar-app trunk |
5 |
Page { |
222.3.2
by Bartosz Kosiorek
Add quick add event for Year View |
6 |
id: yearViewPage
|
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
7 |
objectName: "yearViewPage" |
235.1.1
by Kunal Parmar
View to PAge |
8 |
|
199.1.2
by Kunal Parmar
Code clean up and further improvemnts |
9 |
property int currentYear: DateExt.today().getFullYear(); |
94.1.1
by Kunal Parmar
MonthView/YearView chaged according to new design |
10 |
signal monthSelected(var date); |
11 |
||
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
12 |
Keys.forwardTo: [yearPathView] |
235.1.3
by Kunal Parmar
YearView merge issue fixed |
13 |
|
235.1.1
by Kunal Parmar
View to PAge |
14 |
PathViewBase { |
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
15 |
id: yearPathView
|
16 |
objectName: "yearPathView" |
|
235.1.1
by Kunal Parmar
View to PAge |
17 |
|
18 |
anchors.fill: parent |
|
19 |
||
20 |
onNextItemHighlighted: { |
|
21 |
currentYear = currentYear + 1; |
|
22 |
}
|
|
23 |
||
24 |
onPreviousItemHighlighted: { |
|
25 |
currentYear = currentYear - 1; |
|
26 |
}
|
|
27 |
||
28 |
delegate: GridView{ |
|
29 |
id: yearView
|
|
30 |
clip: true |
|
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
31 |
focus: index == yearPathView.currentIndex |
235.1.1
by Kunal Parmar
View to PAge |
32 |
|
235.1.2
by Kunal Parmar
Merge from trunk |
33 |
property int scrollMonth: 0; |
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
34 |
property bool isCurrentItem: index == yearPathView.currentIndex |
35 |
property int year: (yearViewPage.currentYear + yearPathView.indexType(index)) |
|
235.1.1
by Kunal Parmar
View to PAge |
36 |
|
37 |
width: parent.width |
|
38 |
height: parent.height |
|
39 |
anchors.top: parent.top |
|
40 |
||
41 |
readonly property int minCellWidth: units.gu(30) |
|
42 |
cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n) |
|
192.1.3
by Kunal Parmar
Review comment |
43 |
{ return ((width / n >= minCellWidth) ? width / n : width / 2) }))) |
44 |
||
235.1.1
by Kunal Parmar
View to PAge |
45 |
cellHeight: cellWidth * 1.4 |
46 |
||
47 |
model: 12 /* months in a year */ |
|
235.1.2
by Kunal Parmar
Merge from trunk |
48 |
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
49 |
onYearChanged: { |
50 |
scrollMonth = 0; |
|
51 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
|
235.1.2
by Kunal Parmar
Merge from trunk |
52 |
}
|
53 |
||
54 |
//scroll in case content height changed
|
|
55 |
onHeightChanged: { |
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
56 |
scrollMonth = 0; |
57 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
|
235.1.2
by Kunal Parmar
Merge from trunk |
58 |
}
|
59 |
||
60 |
Connections{ |
|
338.1.1
by Nicholas Skaggs
restructure yearview, add test |
61 |
target: yearPathView |
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
62 |
onScrollUp: { |
235.1.2
by Kunal Parmar
Merge from trunk |
63 |
scrollMonth -= 2; |
64 |
if(scrollMonth < 0) { |
|
65 |
scrollMonth = 0; |
|
66 |
}
|
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
67 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
235.1.2
by Kunal Parmar
Merge from trunk |
68 |
}
|
69 |
||
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
70 |
onScrollDown: { |
235.1.2
by Kunal Parmar
Merge from trunk |
71 |
scrollMonth += 2; |
72 |
var visibleMonths = yearView.height / cellHeight; |
|
73 |
if( scrollMonth >= (11 - visibleMonths)) { |
|
74 |
scrollMonth = (11 - visibleMonths); |
|
75 |
}
|
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
76 |
yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); |
235.1.2
by Kunal Parmar
Merge from trunk |
77 |
}
|
78 |
}
|
|
79 |
||
235.1.1
by Kunal Parmar
View to PAge |
80 |
delegate: Item { |
81 |
width: yearView.cellWidth |
|
82 |
height: yearView.cellHeight |
|
83 |
||
222.3.8
by Bartosz Kosiorek
Sync with lp:ubuntu-calendar-app trunk |
84 |
MonthComponent { |
235.1.1
by Kunal Parmar
View to PAge |
85 |
id: monthComponent
|
240.1.1
by Kunal Parmar
Events on MonthView |
86 |
showEvents: false |
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
87 |
currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0) |
88 |
||
89 |
isYearView: true |
|
138.1.1
by Kunal Parmar
creating month hightlight when necessary |
90 |
anchors.fill: parent |
235.1.1
by Kunal Parmar
View to PAge |
91 |
anchors.margins: units.gu(0.5) |
92 |
||
93 |
dayLabelFontSize:"x-small" |
|
94 |
dateLabelFontSize: "medium" |
|
95 |
monthLabelFontSize: "medium" |
|
96 |
yearLabelFontSize: "small" |
|
222.3.12
by Bartosz Kosiorek
Use signals instead of direct call method from YearView |
97 |
|
98 |
onMonthSelected: { |
|
99 |
yearViewPage.monthSelected(date); |
|
100 |
}
|
|
63.1.1
by Kunal Parmar
year view implementation |
101 |
}
|
102 |
}
|
|
103 |
}
|
|
104 |
}
|
|
105 |
}
|