Merge lp:~pkunal-parmar/ubuntu-calendar-app/yearview into lp:ubuntu-calendar-app

Proposed by Kunal Parmar
Status: Merged
Approved by: Michael Hall
Approved revision: 65
Merged at revision: 64
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/yearview
Merge into: lp:ubuntu-calendar-app
Diff against target: 357 lines (+261/-7)
6 files modified
EventDetails.qml (+7/-7)
MonthComponent.qml (+106/-0)
PathViewBase.qml (+39/-0)
YearView.qml (+79/-0)
calendar.qml (+15/-0)
dateExt.js (+15/-0)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/yearview
Reviewer Review Type Date Requested Status
Michael Hall Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+173743@code.launchpad.net

Commit message

YearView implemented
Reusable MonthView component created ( needs to use it with yearview and monthview)
Reusable PathViewBase created ( needs to use it with timeline view, weekview )

Description of the change

YearView implemented
Reusable MonthView component created ( needs to use it with yearview and monthview)
Reusable PathViewBase created ( needs to use it with timeline view, weekview )

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Hall (mhall119) wrote :

Looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'EventDetails.qml'
2--- EventDetails.qml 2013-04-13 04:43:04 +0000
3+++ EventDetails.qml 2013-07-09 14:45:47 +0000
4@@ -91,19 +91,19 @@
5 Label{
6 id: timeLabel
7 anchors.left: parent.left
8- anchors.verticalCenter: parent.verticalCenter
9+ anchors.verticalCenter: parent.verticalCenter
10 fontSize: "large"
11 }
12 Label{
13 id: dateLabel
14 anchors.right: parent.right
15- anchors.verticalCenter: parent.verticalCenter
16+ anchors.verticalCenter: parent.verticalCenter
17 fontSize: "small"
18 }
19 }
20
21 Label{
22- id: titleLabel
23+ id: titleLabel
24 fontSize: "x-large"
25 width: parent.width
26 wrapMode: Text.WordWrap
27@@ -114,7 +114,7 @@
28 id: descLabel
29 // FIXME: temporaty text, in ui there is no field to enter message
30 text:"Hi both, please turn up on time, it gets really busy by 1pm! Anna x"
31- wrapMode: Text.WordWrap
32+ wrapMode: Text.WordWrap
33 fontSize: "medium"
34 width: parent.width
35 }
36@@ -131,7 +131,7 @@
37 }
38 Label{
39 id:locationLabel
40- wrapMode: Text.WordWrap
41+ wrapMode: Text.WordWrap
42 fontSize: "medium"
43 width: parent.width
44 //color:"#c94212"
45@@ -147,7 +147,7 @@
46 }
47
48 Label{
49- text: i18n.tr("People");
50+ text: i18n.tr("People");
51 fontSize: "small"
52 }
53 ThinDivider{}
54@@ -169,7 +169,7 @@
55 id: contactModel
56 }
57
58- Label{
59+ Label{
60 fontSize: "medium"
61 visible: contactModel.count <= 0
62 anchors.verticalCenter: parent.verticalCenter
63
64=== added file 'MonthComponent.qml'
65--- MonthComponent.qml 1970-01-01 00:00:00 +0000
66+++ MonthComponent.qml 2013-07-09 14:45:47 +0000
67@@ -0,0 +1,106 @@
68+import QtQuick 2.0
69+import Ubuntu.Components 0.1
70+import "dateExt.js" as DateExt
71+import "colorUtils.js" as Color
72+
73+Item{
74+ id: root
75+ property var date;
76+
77+ signal monthSelected(var date);
78+
79+ property alias dayLabelDelegate : dayLabelRepeater.delegate
80+ property alias dateLabelDelegate : dateLabelRepeater.delegate
81+
82+ objectName: "MonthComponent"
83+
84+ width: monthGrid.width
85+ height: monthGrid.height + units.gu(0.5)+ monthName.height
86+
87+ MouseArea{
88+ anchors.fill: parent
89+ onClicked: {
90+ root.monthSelected( root.date );
91+ }
92+ }
93+
94+ Label{
95+ id: monthName
96+ width: parent.width
97+ horizontalAlignment: Text.AlignHCenter
98+ font.bold: true
99+ text: {
100+ Qt.locale().standaloneMonthName(root.date.getMonth())
101+ }
102+ }
103+
104+ Row{
105+ id: dayLabelRow
106+ anchors.top: monthName.bottom
107+ anchors.topMargin: units.gu(0.5)
108+ spacing: units.gu(0.5)
109+ width: parent.width
110+ Repeater{
111+ id: dayLabelRepeater
112+ model:7
113+ delegate: dafaultDayLabelComponent
114+ }
115+ }
116+
117+ Grid{
118+ id: monthGrid
119+ property var monthStart: DateExt.getFirstDateofWeek(root.date.getFullYear(),root.date.getMonth())
120+
121+ rows: DateExt.weekCount(root.date.getFullYear(), root.date.getMonth())
122+ columns: 7
123+ spacing: units.gu(0.5)
124+
125+ anchors.top: dayLabelRow.bottom
126+ anchors.topMargin: units.gu(0.5)
127+
128+ Repeater{
129+ id: dateLabelRepeater
130+ model: monthGrid.rows * monthGrid.columns
131+ delegate: defaultDateLabelComponent
132+ }
133+ }
134+
135+ Component{
136+ id: defaultDateLabelComponent
137+
138+ Text {
139+ id: dateLabel
140+
141+ property var day: parent.monthStart.addDays(index)
142+ property var isToday: day.isSameDay(intern.now)
143+
144+ text: day.getDate()
145+ horizontalAlignment: Text.AlignHCenter
146+ width: dummy.width
147+ height: dummy.height
148+ font.pointSize: dummy.font.pointSize
149+ color: isToday ? Color.ubuntuOrange : dummy.color
150+ scale: isToday ? 1.5 : 1.
151+ }
152+ }
153+
154+ Component{
155+ id: dafaultDayLabelComponent
156+ Text{
157+ //FIXME: how to get localized day initial ?
158+ text: Qt.locale().standaloneDayName( (intern.weekstartDay + index), Locale.ShortFormat).charAt(0)
159+ horizontalAlignment: Text.AlignHCenter
160+ width: dummy.width
161+ height: dummy.height
162+ font.pointSize: dummy.font.pointSize
163+ font.bold: true
164+ }
165+ }
166+
167+ Text{
168+ id: dummy
169+ text: "00"
170+ visible: false
171+ font.pointSize: 7.5
172+ }
173+}
174
175=== added file 'PathViewBase.qml'
176--- PathViewBase.qml 1970-01-01 00:00:00 +0000
177+++ PathViewBase.qml 2013-07-09 14:45:47 +0000
178@@ -0,0 +1,39 @@
179+import QtQuick 2.0
180+
181+PathView {
182+ id: root
183+
184+ model: 3
185+ snapMode: PathView.SnapOneItem
186+
187+ signal nextItemHighlighted();
188+ signal previousItemHighlighted();
189+
190+ path: Path {
191+ startX: -(root.width/2); startY: root.height/2
192+ PathLine { relativeX: root.width; relativeY: 0 }
193+ PathLine { relativeX: root.width; relativeY: 0 }
194+ PathLine { relativeX: root.width; relativeY: 0 }
195+ }
196+
197+ onCurrentIndexChanged: {
198+ var diff = currentIndex - intern.previousIndex
199+
200+ if (intern.previousIndex === count - 1 && currentIndex === 0) diff = 1
201+ if (intern.previousIndex === 0 && currentIndex === count - 1) diff = -1
202+
203+ intern.previousIndex = currentIndex
204+
205+ if ( diff > 0 ) {
206+ root.nextItemHighlighted();
207+ }
208+ else {
209+ root.previousItemHighlighted();
210+ }
211+ }
212+
213+ QtObject{
214+ id: intern
215+ property int previousIndex: root.currentIndex
216+ }
217+}
218
219=== added file 'YearView.qml'
220--- YearView.qml 1970-01-01 00:00:00 +0000
221+++ YearView.qml 2013-07-09 14:45:47 +0000
222@@ -0,0 +1,79 @@
223+import QtQuick 2.0
224+import Ubuntu.Components 0.1
225+
226+PathViewBase {
227+ id: root
228+
229+ anchors.fill: parent
230+ property var year: getDateFromYear(intern.now.getFullYear()-1);
231+
232+ signal monthSelected(var date);
233+
234+ onNextItemHighlighted: {
235+ year = getDateFromYear(year.getFullYear() + 1);
236+ }
237+
238+ onPreviousItemHighlighted: {
239+ year = getDateFromYear(year.getFullYear() - 1);
240+ }
241+
242+ function getDateFromYear(year) {
243+ return new Date(year,0,1,0,0,0,0);
244+ }
245+
246+ QtObject{
247+ id: intern
248+ property var now: new Date()
249+ property int weekstartDay: Qt.locale().firstDayOfWeek
250+ }
251+
252+ delegate: Item{
253+ id: yearView
254+
255+ property var year: {
256+ if (index === root.currentIndex) {
257+ return root.year;
258+ }
259+ var previousIndex = root.currentIndex > 0 ? root.currentIndex - 1 : 2
260+
261+ if ( index === previousIndex ) {
262+ return getDateFromYear(root.year.getFullYear()-1);
263+ }
264+
265+ return getDateFromYear(root.year.getFullYear()+ 1);
266+ }
267+
268+ width: parent.width
269+ height: parent.height
270+
271+ Label{
272+ id: yearLabel
273+ text: year.getFullYear()
274+ fontSize: "large"
275+ anchors.horizontalCenter: parent.horizontalCenter
276+ font.bold: true
277+ }
278+
279+ Grid{
280+ id: yearGrid
281+ rows: 4
282+ columns: 3
283+
284+ width: parent.width
285+ height: parent.height
286+ anchors.top: yearLabel.bottom
287+ spacing: units.gu(2.5)
288+
289+ Repeater{
290+ model: yearGrid.rows * yearGrid.columns
291+ delegate: MonthComponent{
292+ date: new Date(year.getFullYear(),index,1,0,0,0,0)
293+
294+ onMonthSelected: {
295+ root.monthSelected(date);
296+ }
297+ }
298+ }
299+ }
300+ }
301+}
302
303=== modified file 'calendar.qml'
304--- calendar.qml 2013-06-12 15:47:15 +0000
305+++ calendar.qml 2013-07-09 14:45:47 +0000
306@@ -49,6 +49,11 @@
307 }
308 }
309 }
310+ Action {
311+ iconSource: Qt.resolvedUrl("avatar.png")
312+ text: i18n.tr("Year view")
313+ onTriggered: pageStack.push(yearView);
314+ }
315 }
316
317 Tabs {
318@@ -110,6 +115,16 @@
319 id: newEventComponent
320 NewEvent {}
321 }
322+
323+ Component{
324+ id: yearView
325+ YearView{
326+ onMonthSelected: {
327+ // TODO: select month in monthView
328+ pageStack.pop();
329+ }
330+ }
331+ }
332 }
333 }
334 }
335
336=== modified file 'dateExt.js'
337--- dateExt.js 2013-04-21 07:52:56 +0000
338+++ dateExt.js 2013-07-09 14:45:47 +0000
339@@ -85,3 +85,18 @@
340 && this.getMonth() === otherDay.getMonth()
341 && this.getFullYear() === otherDay.getFullYear() );
342 }
343+
344+function weekCount(year, month_number) {
345+ var firstOfMonth = new Date(year, month_number, 1);
346+ var lastOfMonth = new Date(year, month_number+1, 0);
347+
348+ var used = firstOfMonth.getDay() + lastOfMonth.getDate();
349+
350+ return Math.ceil( used / 7);
351+}
352+
353+function getFirstDateofWeek( year, month) {
354+ var date = new Date(year, month, 1);
355+ var first = date.getDate() - date.getDay();
356+ return new Date(date.setDate(first));
357+}

Subscribers

People subscribed via source and target branches

to status/vote changes: