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

Proposed by Kunal Parmar
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 101
Merged at revision: 108
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/new_month_yearview
Merge into: lp:ubuntu-calendar-app
Diff against target: 730 lines (+254/-332)
6 files modified
MonthComponent.qml (+132/-80)
MonthView.qml (+65/-199)
YearView.qml (+41/-30)
calendar.qml (+10/-22)
dateExt.js (+5/-0)
tests/autopilot/calendar_app/tests/test_monthview.py (+1/-1)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/new_month_yearview
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Olivier Tilloy (community) Approve
Riccardo Padovani (community) Approve
Review via email: mp+183305@code.launchpad.net

Commit message

MonthView and YearView changed according to new design

Description of the change

MonthView and YearView changed according to new design

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
Riccardo Padovani (rpadovani) wrote :

Thanks for your time and the big patch Kunal!

Looking to the design guideline I have noticed some things:
- Page 4 of UDS presentation: In the year view also the name of the month is in the rounded box
- Page 4 of UDS presentation: In the year view there is a label, on right of the name of the month, with the year
- There is no animation when you click on a month
- Page 5 of UDS presentation: In the month view also the name of the month is in the rounded box
- Page 5 of UDS presentation: In the year view there is a label, on right of the name of the month, with the year
- Page 5 of UDS presentation: There is no current date in design guideline, in month view

Also, when you switch tab from month to year, start month is Jan, I think that the start month has to be the current one.

However, they are details, great job Kunal!

review: Needs Fixing
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

HI Riccardo, Thanks for review.

Yes, currently I designed according to old visual, I just got UDS PPT with new Visual, I will be updating it the views.

And yes, Animation is not going to be implemented now. Design team is going to refine them.

"Also, when you switch tab from month to year, start month is Jan, I think that the start month has to be the current one."

You mean if its current year then scroll to current month , else JAN ?
As such its not defined, but that makes sense.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I second Riccardo, that looks really good!

One minor remark:

    506 + text: Qt.formatDateTime( new Date(),"d MMMM yyyy");

The format string should probably be internationalized, with a comment for translators.

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Hi Kunal,
just see your last commit, now looks perfect ;)

Awesome work!

> You mean if its current year then scroll to current month , else JAN ?

Yes, exactly!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

> Thanks for your time and the big patch Kunal!
>
> Looking to the design guideline I have noticed some things:
> - Page 4 of UDS presentation: In the year view also the name of the month is
> in the rounded box
> - Page 4 of UDS presentation: In the year view there is a label, on right of
> the name of the month, with the year
> - There is no animation when you click on a month
> - Page 5 of UDS presentation: In the month view also the name of the month is
> in the rounded box
> - Page 5 of UDS presentation: In the year view there is a label, on right of
> the name of the month, with the year
> - Page 5 of UDS presentation: There is no current date in design guideline, in
> month view
>
> Also, when you switch tab from month to year, start month is Jan, I think that
> the start month has to be the current one.
>
> However, they are details, great job Kunal!

Hi, I addressed your comments except scrolling one and animation. I will create another merge request for scrolling to current month. I need some time for that. and animation we are not focusing right now.

Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

> I second Riccardo, that looks really good!
>
> One minor remark:
>
> 506 + text: Qt.formatDateTime( new Date(),"d MMMM yyyy");
>
> The format string should probably be internationalized, with a comment for
> translators.

Hi, I just changed looks according to new visuals from UDS. As per that there is not Today label anymore. So i just removed it.

Hoe that's fine.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks pretty good!

One minor glitch that I’ve noticed: in the year view, today is marked selected both in the current month and in the previous month (happens because the previous month also displays a few days from the current month, greyed out).
I think today should be marked selected only in the current month.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

Another not so minor issue: in the month view, days are shifted by one, i.e. with my current locale settings (fr_FR) the month view displays the first of September as a Monday, whereas it was a Sunday. This is a regression compared to the current implementation, which correctly displays the first of September as a Sunday.

The year view is also affected, so this is a bug, but not a regression as the bug was already present in the year view in the current implementation.

review: Needs Fixing
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

> Another not so minor issue: in the month view, days are shifted by one, i.e.
> with my current locale settings (fr_FR) the month view displays the first of
> September as a Monday, whereas it was a Sunday. This is a regression compared
> to the current implementation, which correctly displays the first of September
> as a Sunday.
>
> The year view is also affected, so this is a bug, but not a regression as the
> bug was already present in the year view in the current implementation.

Tried to fix, it looks fine to me, Can you confirm ?

Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

> Looks pretty good!
>
> One minor glitch that I’ve noticed: in the year view, today is marked selected
> both in the current month and in the previous month (happens because the
> previous month also displays a few days from the current month, greyed out).
> I think today should be marked selected only in the current month.

Fixed, please check

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

> > Another not so minor issue: in the month view, days are shifted by one, i.e.
> > with my current locale settings (fr_FR) the month view displays the first
> of
> > September as a Monday, whereas it was a Sunday. This is a regression
> compared
> > to the current implementation, which correctly displays the first of
> September
> > as a Sunday.
> >
> > The year view is also affected, so this is a bug, but not a regression as
> the
> > bug was already present in the year view in the current implementation.
>
> Tried to fix, it looks fine to me, Can you confirm ?

I can confirm this is fixed. Thanks!

Revision history for this message
Olivier Tilloy (osomon) wrote :

> > Looks pretty good!
> >
> > One minor glitch that I’ve noticed: in the year view, today is marked
> selected
> > both in the current month and in the previous month (happens because the
> > previous month also displays a few days from the current month, greyed out).
> > I think today should be marked selected only in the current month.
>
> Fixed, please check

Works. Thanks!

Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks pretty good and works well. Nice job!

review: Approve
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

There is a conflict when merging into the latest trunk, can you resolve it and push a new revision?

101. By Kunal Parmar

Trunk code merged

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MonthComponent.qml'
--- MonthComponent.qml 2013-09-03 00:51:30 +0000
+++ MonthComponent.qml 2013-09-03 23:46:33 +0000
@@ -5,103 +5,155 @@
55
6Item{6Item{
7 id: root7 id: root
8 property var date;8 objectName: "MonthComponent"
99
10 signal monthSelected(var date);10 property var monthDate;
11
12 property string dayLabelFontSize: "medium"
13 property string dateLabelFontSize: "large"
14 property string monthLabelFontSize: "large"
15 property string yearLabelFontSize: "medium"
1116
12 property alias dayLabelDelegate : dayLabelRepeater.delegate17 property alias dayLabelDelegate : dayLabelRepeater.delegate
13 property alias dateLabelDelegate : dateLabelRepeater.delegate18 property alias dateLabelDelegate : dateLabelRepeater.delegate
1419
15 objectName: "MonthComponent"20 signal dateSelected(var date)
1621
17 width: monthGrid.width22 height: ubuntuShape.height
18 height: monthGrid.height + units.gu(0.5)+ monthName.height23
1924 UbuntuShape {
20 MouseArea{25 id: ubuntuShape
26
21 anchors.fill: parent27 anchors.fill: parent
22 onClicked: {28 radius: "medium"
23 root.monthSelected( root.date );29
24 }30 Column{
25 }31 id: column
2632
27 Label{33 anchors.top: parent.top
28 id: monthName34 anchors.topMargin: units.gu(1.5)
29 width: parent.width35 anchors.fill: parent
30 horizontalAlignment: Text.AlignHCenter36 spacing: units.gu(1.5)
31 font.bold: true37
32 text: {38 Item{
33 Qt.locale().standaloneMonthName(root.date.getMonth())39 id: monthHeader
34 }40 width: parent.width
35 }41 height: monthLabel.height
3642
37 Row{43 Label{
38 id: dayLabelRow44 id: monthLabel
39 anchors.top: monthName.bottom45 fontSize: monthLabelFontSize
40 anchors.topMargin: units.gu(0.5)46 text: Qt.locale().standaloneMonthName(root.monthDate.getMonth())
41 spacing: units.gu(0.5)47 anchors.leftMargin: units.gu(1)
42 width: parent.width48 anchors.left: parent.left
43 Repeater{49 //color:"white"
44 id: dayLabelRepeater50 anchors.verticalCenter: parent.verticalCenter
45 model:751 }
46 delegate: dafaultDayLabelComponent52
47 }53 Label{
48 }54 id: yearLabel
4955 fontSize: yearLabelFontSize
50 Grid{56 text: root.monthDate.getFullYear()
51 id: monthGrid57 anchors.right: parent.right
52 property var monthStart: DateExt.getFirstDateofWeek(root.date.getFullYear(),root.date.getMonth())58 anchors.rightMargin: units.gu(1)
5359 color:"#AEA79F"
54 rows: DateExt.weekCount(root.date.getFullYear(), root.date.getMonth())60 anchors.verticalCenter: parent.verticalCenter
55 columns: 761 }
56 spacing: units.gu(0.5)62 }
5763
58 anchors.top: dayLabelRow.bottom64 Row{
59 anchors.topMargin: units.gu(0.5)65 id: dayLabelRow
6066 width: parent.width
61 Repeater{67 anchors.horizontalCenter: parent.horizontalCenter
62 id: dateLabelRepeater68
63 model: monthGrid.rows * monthGrid.columns69 Repeater{
64 delegate: defaultDateLabelComponent70 id: dayLabelRepeater
71 model:7
72 delegate: dafaultDayLabelComponent
73 }
74 }
75
76 Grid{
77 id: monthGrid
78
79 property int weekCount : 6
80 property var monthStart: root.monthDate.weekStart( Qt.locale().firstDayOfWeek )
81
82 width: parent.width
83 height: parent.height - monthHeader.height - dayLabelRow.height - units.gu(3)
84
85 rows: weekCount
86 columns: 7
87
88 Repeater{
89 id: dateLabelRepeater
90 model: monthGrid.rows * monthGrid.columns
91 delegate: defaultDateLabelComponent
92 }
93 }
65 }94 }
66 }95 }
6796
68 Component{97 Component{
69 id: defaultDateLabelComponent98 id: defaultDateLabelComponent
7099
71 Text {100 Item{
72 id: dateLabel101 id: dateRootItem
73102
74 property var day: parent.monthStart.addDays(index)103 property var date: parent.monthStart.addDays(index);
75 property var isToday: day.isSameDay(intern.now)104 property bool isCurrentMonth: DateExt.isSameMonth(root.monthDate,date)
76 property bool isPaddingDate: day.getMonth() != root.date.getMonth()105
77106 width: parent.width / 7;
78 text: day.getDate()107 height: parent.height / parent.weekCount
79 horizontalAlignment: Text.AlignHCenter108
80 width: dummy.width109 UbuntuShape{
81 height: dummy.height110 id: highLightRect
82 font.pointSize: dummy.font.pointSize111
83 color: isToday ? Color.ubuntuOrange : (isPaddingDate ? Color.warmGrey : dummy.color)112 width: parent.width
84 scale: isToday ? 1.5 : 1.113 height: width
114 anchors.centerIn: parent
115
116 color: "white"
117 visible: date.isSameDay(DateExt.today()) && isCurrentMonth
118 }
119
120 Label{
121 id: dateLabel
122 anchors.centerIn: parent
123 text: date.getDate()
124 horizontalAlignment: Text.AlignHCenter
125 fontSize: root.dateLabelFontSize
126 color: {
127 if( date.isSameDay(DateExt.today()) && isCurrentMonth ) {
128 "#2C001E"
129 } else if( parent.isCurrentMonth ) {
130 "#333333"
131 } else {
132 "#AEA79F"
133 }
134 }
135 }
136
137 MouseArea{
138 anchors.fill: parent
139 onClicked: {
140 root.dateSelected(date);
141 }
142 }
85 }143 }
86 }144 }
87145
88 Component{146 Component{
89 id: dafaultDayLabelComponent147 id: dafaultDayLabelComponent
90 Text{148
91 //FIXME: how to get localized day initial ?149 Label{
92 text: Qt.locale().standaloneDayName( (intern.weekstartDay + index), Locale.ShortFormat).charAt(0)150 id: weekDay
151 width: parent.width / 7
152 property var day :Qt.locale().standaloneDayName(( Qt.locale().firstDayOfWeek + index), Locale.ShortFormat)
153 text: day.toUpperCase();
93 horizontalAlignment: Text.AlignHCenter154 horizontalAlignment: Text.AlignHCenter
94 width: dummy.width155 fontSize: root.dayLabelFontSize
95 height: dummy.height156 color: "#AEA79F"
96 font.pointSize: dummy.font.pointSize
97 font.bold: true
98 }157 }
99 }158 }
100
101 Text{
102 id: dummy
103 text: "00"
104 visible: false
105 font.pointSize: 7.5
106 }
107}159}
108160
=== modified file 'MonthView.qml'
--- MonthView.qml 2013-08-04 02:26:31 +0000
+++ MonthView.qml 2013-09-03 23:46:33 +0000
@@ -3,204 +3,70 @@
3import "dateExt.js" as DateExt3import "dateExt.js" as DateExt
4import "colorUtils.js" as Color4import "colorUtils.js" as Color
55
6ListView {6Page {
7 id: monthView7 id: monthViewPage
88
9 // FIXME: change monthview to use this date as start date9 property var currentMonth: DateExt.today();
10 property alias startDay: intern.currentDayStart10
1111 signal dateSelected(var date);
12 readonly property var monthStart: currentItem != null ? currentItem.monthStart : (new Date()).monthStart()12
13 readonly property var monthEnd: currentItem != null ? currentItem.monthEnd : (new Date()).monthStart().addMonths(1)13 PathViewBase{
14 readonly property var currentDayStart: intern.currentDayStart14 id: monthViewPath
1515
16 property bool compressed: false16 property var startMonth: addMonth(currentMonth,-1);
17 readonly property real compressedHeight: intern.squareUnit + intern.verticalMargin * 217
18 readonly property real expandedHeight: intern.squareUnit * 6 + intern.verticalMargin * 218 anchors.top:parent.top
1919
20 signal incrementCurrentDay20 width:parent.width
21 signal decrementCurrentDay21 height: parent.height
2222
23 signal gotoNextMonth(int month)23 onNextItemHighlighted: {
24 signal focusOnDay(var dayStart)24 nextMonth();
2525 }
26 onCurrentItemChanged: {26
27 if (currentItem == null) {27 onPreviousItemHighlighted: {
28 intern.currentDayStart = intern.currentDayStart28 previousMonth();
29 return29 }
30 }30
31 if (currentItem.monthStart <= intern.currentDayStart && intern.currentDayStart < currentItem.monthEnd)31 function nextMonth() {
32 return32 currentMonth = addMonth(currentMonth,1);
33 if (currentItem.monthStart <= intern.today && intern.today < currentItem.monthEnd)33 }
34 intern.currentDayStart = intern.today34
35 else35 function previousMonth(){
36 intern.currentDayStart = currentItem.monthStart36 currentMonth = addMonth(currentMonth,-1);
37 }37 }
3838
39 onIncrementCurrentDay: {39 function addMonth(date,month){
40 var t = intern.currentDayStart.addDays(1)40 var temp = new Date(date.getFullYear(),date.getMonth(),1,0,0,0);
41 if (t < monthEnd) {41 temp.setMonth(date.getMonth() + month);
42 intern.currentDayStart = t42 return temp;
43 }43 }
44 else if (currentIndex < count - 1) {44
45 intern.currentDayStart = t45 delegate: MonthComponent{
46 currentIndex = currentIndex + 146 width: parent.width - units.gu(5)
47 }47 height: parent.height - units.gu(5)
48 }48
4949 monthDate: getMonthDate();
50 onDecrementCurrentDay: {50
51 var t = intern.currentDayStart.addDays(-1)51 function getMonthDate() {
52 if (t >= monthStart) {52 //previous page
53 intern.currentDayStart = t53 if (index === monthViewPath.currentIndex) {
54 }54 return monthViewPath.startMonth;
55 else if (currentIndex > 0) {55 }
56 intern.currentDayStart = t56
57 currentIndex = currentIndex - 157 //next page
58 }58 var previousIndex = monthViewPath.currentIndex > 0 ? monthViewPath.currentIndex - 1 : 2
59 }59 if ( index === previousIndex ) {
6060 return monthViewPath.addMonth(monthViewPath.startMonth,2);
61 onGotoNextMonth: {61 }
62 if (monthStart.getMonth() != month) {62
63 var i = intern.monthIndex0, m = intern.today.getMonth()63 //current page
64 while (m != month) {64 return monthViewPath.addMonth(monthViewPath.startMonth,1);
65 m = (m + 1) % 1265 }
66 i = i + 166
67 }67 onDateSelected: {
68 currentIndex = i68 monthViewPage.dateSelected(date);
69 }69 }
70 }70 }
71
72 onFocusOnDay: {
73 if (dayStart < monthStart) {
74 if (currentIndex > 0) {
75 intern.currentDayStart = dayStart
76 currentIndex = currentIndex - 1
77 }
78 }
79 else if (dayStart >= monthEnd) {
80 if (currentIndex < count - 1) {
81 intern.currentDayStart = dayStart
82 currentIndex = currentIndex + 1
83 }
84 }
85 else intern.currentDayStart = dayStart
86 }
87
88 function goToToday() {
89 var today = (new Date()).midnight();
90 intern.currentDayStart = today
91 currentIndex= intern.monthIndex0
92 }
93
94 focus: true
95 Keys.onLeftPressed: decrementCurrentDay()
96 Keys.onRightPressed: incrementCurrentDay()
97
98 QtObject {
99 id: intern
100
101 property int squareUnit: monthView.width / 8
102 property int verticalMargin: units.gu(1)
103 property int weekstartDay: Qt.locale().firstDayOfWeek
104 property int monthCount: 49 // months for +-2 years
105
106 property var today: (new Date()).midnight() // TODO: update at midnight
107 property var currentDayStart: today
108 property int monthIndex0: Math.floor(monthCount / 2)
109 property var monthStart0: today.monthStart()
110 }
111
112 width: parent.width
113 height: compressed ? compressedHeight : expandedHeight
114
115 interactive: !compressed
116 clip: true
117 orientation: ListView.Horizontal
118 snapMode: ListView.SnapOneItem
119 cacheBuffer: width + 1
120
121 highlightRangeMode: ListView.StrictlyEnforceRange
122 preferredHighlightBegin: 0
123 preferredHighlightEnd: width
124
125 model: intern.monthCount
126 currentIndex: intern.monthIndex0
127
128 delegate: Item {
129 id: monthItem
130
131 property var monthStart: intern.monthStart0.addMonths(index - intern.monthIndex0)
132 property var monthEnd: monthStart.addMonths(1)
133 property var gridStart: monthStart.weekStart(intern.weekstartDay)
134 property int currentWeekRow: Math.floor((currentDayStart.getTime() - gridStart.getTime()) / Date.msPerWeek)
135
136 width: monthView.width
137 height: monthView.height
138
139 Grid {
140 id: monthGrid
141
142 rows: 6
143 columns: 7
144
145 x: intern.squareUnit / 2
146 y: intern.verticalMargin
147 width: intern.squareUnit * columns
148 height: intern.squareUnit * rows
149
150 Repeater {
151 model: monthGrid.rows * monthGrid.columns
152 delegate: Item {
153 id: dayItem
154 property var dayStart: gridStart.addDays(index)
155 property bool isCurrentMonth: monthStart <= dayStart && dayStart < monthEnd
156 property bool isToday: dayStart.getTime() === intern.today.getTime()
157 property bool isCurrent: dayStart.getTime() === intern.currentDayStart.getTime()
158 property int weekday: (index % 7 + intern.weekstartDay) % 7
159 property bool isSunday: weekday == 0
160 property int row: Math.floor(index / 7)
161 property bool isCurrentWeek: row == currentWeekRow
162 property real topMargin: (row == 0 || (monthView.compressed && isCurrentWeek)) ? -intern.verticalMargin : 0
163 property real bottomMargin: (row == 5 || (monthView.compressed && isCurrentWeek)) ? -intern.verticalMargin : 0
164 visible: monthView.compressed ? isCurrentWeek : true
165 width: intern.squareUnit
166 height: intern.squareUnit
167 Rectangle {
168 visible: isSunday
169 anchors.fill: parent
170 anchors.topMargin: dayItem.topMargin
171 anchors.bottomMargin: dayItem.bottomMargin
172 color: Color.warmGrey
173 opacity: 0.1
174 }
175 Text {
176 anchors.centerIn: parent
177 text: dayStart.getDate()
178 font: themeDummy.font
179 color: isToday ? Color.ubuntuOrange : themeDummy.color
180 scale: isCurrent ? 1.8 : 1.
181 opacity: isCurrentMonth ? 1. : 0.3
182 Behavior on scale {
183 NumberAnimation { duration: 50 }
184 }
185 }
186 MouseArea {
187 anchors.fill: parent
188 anchors.topMargin: dayItem.topMargin
189 anchors.bottomMargin: dayItem.bottomMargin
190 onReleased: monthView.focusOnDay(dayStart)
191 }
192 // Component.onCompleted: console.log(dayStart, intern.currentDayStart)
193 }
194 }
195 }
196
197 // Component.onCompleted: console.log("Created delegate for month", index, monthStart, gridStart, currentWeekRow, currentWeekRowReal)
198 }
199
200 Label {
201 visible: false
202 id: themeDummy
203 fontSize: "large"
204 // Component.onCompleted: console.log(color, Qt.lighter(color, 1.74))
205 }71 }
206}72}
20773
=== modified file 'YearView.qml'
--- YearView.qml 2013-07-09 14:35:09 +0000
+++ YearView.qml 2013-09-03 23:46:33 +0000
@@ -1,20 +1,23 @@
1import QtQuick 2.01import QtQuick 2.0
2import Ubuntu.Components 0.12import Ubuntu.Components 0.1
33
4import "dateExt.js" as DateExt
5
4PathViewBase {6PathViewBase {
5 id: root7 id: root
68
9 property var currentYear: DateExt.today();
10
11 signal monthSelected(var date);
12
7 anchors.fill: parent13 anchors.fill: parent
8 property var year: getDateFromYear(intern.now.getFullYear()-1);
9
10 signal monthSelected(var date);
1114
12 onNextItemHighlighted: {15 onNextItemHighlighted: {
13 year = getDateFromYear(year.getFullYear() + 1);16 currentYear = getDateFromYear(currentYear.getFullYear() + 1);
14 }17 }
1518
16 onPreviousItemHighlighted: {19 onPreviousItemHighlighted: {
17 year = getDateFromYear(year.getFullYear() - 1);20 currentYear = getDateFromYear(currentYear.getFullYear() - 1);
18 }21 }
1922
20 function getDateFromYear(year) {23 function getDateFromYear(year) {
@@ -23,54 +26,62 @@
2326
24 QtObject{27 QtObject{
25 id: intern28 id: intern
26 property var now: new Date()29 property var startYear: getDateFromYear(currentYear.getFullYear()-1);
27 property int weekstartDay: Qt.locale().firstDayOfWeek
28 }30 }
2931
30 delegate: Item{32 delegate: Flickable{
31 id: yearView33 id: yearView
3234 clip: true
33 property var year: {35
36 property var year: getYear();
37
38 function getYear(){
34 if (index === root.currentIndex) {39 if (index === root.currentIndex) {
35 return root.year;40 return intern.startYear;
36 }41 }
37 var previousIndex = root.currentIndex > 0 ? root.currentIndex - 1 : 242 var previousIndex = root.currentIndex > 0 ? root.currentIndex - 1 : 2
3843
39 if ( index === previousIndex ) {44 if ( index === previousIndex ) {
40 return getDateFromYear(root.year.getFullYear()-1);45 return getDateFromYear(intern.startYear.getFullYear() - 1);
41 }46 }
4247
43 return getDateFromYear(root.year.getFullYear()+ 1);48 return getDateFromYear(intern.startYear.getFullYear() + 1);
44 }49 }
4550
46 width: parent.width51 width: parent.width
47 height: parent.height52 height: parent.height
4853
49 Label{54 contentHeight: yearGrid.height + units.gu(2)
50 id: yearLabel55 contentWidth: width
51 text: year.getFullYear()
52 fontSize: "large"
53 anchors.horizontalCenter: parent.horizontalCenter
54 font.bold: true
55 }
5656
57 Grid{57 Grid{
58 id: yearGrid58 id: yearGrid
59 rows: 459 rows: 6
60 columns: 360 columns: 2
6161
62 width: parent.width62 anchors.top: parent.top
63 height: parent.height63 anchors.topMargin: units.gu(1.5)
64 anchors.top: yearLabel.bottom64
65 spacing: units.gu(2.5)65 width: parent.width - ((columns-1) * yearGrid.spacing)
66 spacing: units.gu(2)
67 anchors.horizontalCenter: parent.horizontalCenter
6668
67 Repeater{69 Repeater{
68 model: yearGrid.rows * yearGrid.columns70 model: yearGrid.rows * yearGrid.columns
69 delegate: MonthComponent{71 delegate: MonthComponent{
70 date: new Date(year.getFullYear(),index,1,0,0,0,0)72 monthDate: new Date(yearView.year.getFullYear(),index,1,0,0,0,0)
73 width: (parent.width - units.gu(2))/2
74 height: width * 1.5
75 dayLabelFontSize:"x-small"
76 dateLabelFontSize: "medium"
77 monthLabelFontSize: "medium"
78 yearLabelFontSize: "small"
7179
72 onMonthSelected: {80 MouseArea{
73 root.monthSelected(date);81 anchors.fill: parent
82 onClicked: {
83 root.monthSelected(monthDate);
84 }
74 }85 }
75 }86 }
76 }87 }
7788
=== modified file 'calendar.qml'
--- calendar.qml 2013-08-20 14:32:27 +0000
+++ calendar.qml 2013-09-03 23:46:33 +0000
@@ -24,8 +24,8 @@
24 property var currentDay: DateExt.today();24 property var currentDay: DateExt.today();
2525
26 onCurrentDayChanged: {26 onCurrentDayChanged: {
27 if( monthView.startDay !== undefined && !monthView.startDay.isSameDay(currentDay))27 if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))
28 monthView.startDay = currentDay.midnight();28 monthView.currentMonth = currentDay.midnight();
2929
30 if( !dayView.currentDay.isSameDay(currentDay))30 if( !dayView.currentDay.isSameDay(currentDay))
31 dayView.currentDay = currentDay31 dayView.currentDay = currentDay
@@ -60,7 +60,6 @@
60 text: i18n.tr("Today");60 text: i18n.tr("Today");
61 onTriggered: {61 onTriggered: {
62 tabPage.currentDay = (new Date()).midnight();62 tabPage.currentDay = (new Date()).midnight();
63 monthView.goToToday();
64 }63 }
65 }64 }
66 }65 }
@@ -76,13 +75,12 @@
76 YearView{75 YearView{
77 onMonthSelected: {76 onMonthSelected: {
78 tabs.selectedTabIndex = 177 tabs.selectedTabIndex = 1
79 var now = new Date();78 var now = DateExt.today();
80 if( date.getMonth() === now.getMonth()79 if( date.getMonth() === now.getMonth()
81 && date.getFullYear() === now.getFullYear()) {80 && date.getFullYear() === now.getFullYear()) {
82 monthView.goToToday();81 monthView.currentMonth = now
83 } else {82 } else {
84 monthView.startDay = date.midnight();83 monthView.currentMonth = date.midnight();
85 monthView.gotoNextMonth(date.getMonth());
86 }84 }
87 }85 }
88 }86 }
@@ -91,24 +89,14 @@
91 Tab {89 Tab {
92 id: monthTab90 id: monthTab
93 title: i18n.tr("Month")91 title: i18n.tr("Month")
94 page: Page{92 page: MonthView{
95 anchors.fill: parent93 anchors.fill: parent
96 tools: commonToolBar94 tools: commonToolBar
97 Column {95 id: monthView
98 anchors.fill: parent
99 Label{
100 id: monthLabel
101 fontSize: "large"
102 text: Qt.formatDateTime(monthView.startDay,"MMMM yyyy");
103 }
10496
105 MonthView {97 onDateSelected: {
106 id: monthView98 tabs.selectedTabIndex = 3
107 onFocusOnDay: {99 tabPage.currentDay = date;
108 tabs.selectedTabIndex = 3
109 tabPage.currentDay = dayStart;
110 }
111 }
112 }100 }
113 }101 }
114 }102 }
115103
=== modified file 'dateExt.js'
--- dateExt.js 2013-09-03 01:52:17 +0000
+++ dateExt.js 2013-09-03 23:46:33 +0000
@@ -104,3 +104,8 @@
104 date.setHours(0,0,0,0);104 date.setHours(0,0,0,0);
105 return date105 return date
106}106}
107
108function isSameMonth(date1, date2) {
109 return ( date1.getMonth() === date2.getMonth()
110 && date1.getFullYear() === date2.getFullYear())
111}
107112
=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
--- tests/autopilot/calendar_app/tests/test_monthview.py 2013-08-28 16:19:06 +0000
+++ tests/autopilot/calendar_app/tests/test_monthview.py 2013-09-03 23:46:33 +0000
@@ -24,7 +24,7 @@
2424
25 def get_currentDayStart(self):25 def get_currentDayStart(self):
26 month_view = self.main_view.get_month_view()26 month_view = self.main_view.get_month_view()
27 return datetime.fromtimestamp(month_view.currentDayStart)27 return datetime.fromtimestamp(month_view.currentMonth)
2828
29 def change_month(self, delta):29 def change_month(self, delta):
30 month_view = self.main_view.get_month_view()30 month_view = self.main_view.get_month_view()

Subscribers

People subscribed via source and target branches

to status/vote changes: