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

Proposed by Kunal Parmar
Status: Merged
Approved by: Mihir Soni
Approved revision: 713
Merged at revision: 715
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/SyncSelection
Merge into: lp:ubuntu-calendar-app
Diff against target: 342 lines (+104/-4)
9 files modified
MonthComponent.qml (+24/-2)
MonthComponentDateDelegate.qml (+1/-0)
MonthView.qml (+7/-0)
TimeLineBaseComponent.qml (+7/-0)
TimeLineHeader.qml (+14/-0)
TimeLineHeaderComponent.qml (+18/-2)
WeekView.qml (+7/-0)
calendar.qml (+11/-0)
dateExt.js (+15/-0)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/SyncSelection
Reviewer Review Type Date Requested Status
Mihir Soni Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+270237@code.launchpad.net

Commit message

resolves Bug #1475747

Description of the change

resolves Bug #1475747

To post a comment you must log in.
713. By Kunal Parmar

print statement removed

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
Mihir Soni (mihirsoni) 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 'MonthComponent.qml'
2--- MonthComponent.qml 2015-08-03 04:32:33 +0000
3+++ MonthComponent.qml 2015-09-05 05:34:16 +0000
4@@ -30,6 +30,7 @@
5
6 property var currentMonth;
7 property var isYearView;
8+ property var selectedDay;
9
10 property string dayLabelFontSize: "medium"
11 property string dateLabelFontSize: "large"
12@@ -40,7 +41,8 @@
13 property alias dateLabelDelegate : dateLabelRepeater.delegate
14
15 signal monthSelected(var date);
16- signal dateSelected(var date)
17+ signal dateSelected(var date);
18+ signal dateHighlighted(var date);
19
20 //creatng timer only if we need to show events in month
21 Loader {
22@@ -90,6 +92,7 @@
23 property int todayMonth: today.getMonth()
24 property int todayYear: today.getFullYear()
25
26+
27 //date from month will start, this date might be from previous month
28 property var monthStart: currentMonth.weekStart( Qt.locale().firstDayOfWeek )
29 property int monthStartDate: monthStart.getDate()
30@@ -113,10 +116,29 @@
31 property int dayFontSize: FontUtils.sizeToPixels(root.dayLabelFontSize)
32
33 property int selectedIndex: -1
34+
35+ function findSelectedDayIndex(){
36+ if(!selectedDay) {
37+ return -1;
38+ }
39+
40+ if( todayMonth === selectedDay.getMonth() && selectedDay.getFullYear() === todayYear){
41+ return selectedDay.getDate() +
42+ (Date.daysInMonth(monthStartYear, monthStartMonth) - monthStartDate);
43+ } else {
44+ return -1;
45+ }
46+ }
47+ }
48+
49+ onSelectedDayChanged: {
50+ if( isCurrentItem ) {
51+ intern.selectedIndex = intern.findSelectedDayIndex();
52+ }
53 }
54
55 onCurrentMonthChanged: {
56- intern.selectedIndex = -1
57+ intern.selectedIndex = -1;
58 }
59
60 Column{
61
62=== modified file 'MonthComponentDateDelegate.qml'
63--- MonthComponentDateDelegate.qml 2015-08-20 12:14:57 +0000
64+++ MonthComponentDateDelegate.qml 2015-09-05 05:34:16 +0000
65@@ -114,6 +114,7 @@
66 root.dateSelected(selectedDate);
67 } else {
68 intern.selectedIndex = index
69+ root.dateHighlighted(selectedDate)
70 }
71 }
72 }
73
74=== modified file 'MonthView.qml'
75--- MonthView.qml 2015-03-01 14:01:35 +0000
76+++ MonthView.qml 2015-09-05 05:34:16 +0000
77@@ -25,8 +25,10 @@
78 objectName: "monthViewPage"
79
80 property var currentMonth: DateExt.today();
81+ property var selectedDay;
82
83 signal dateSelected(var date);
84+ signal dateHighlighted(var date);
85
86 Keys.forwardTo: [monthViewPath]
87
88@@ -111,11 +113,16 @@
89 currentMonth: monthViewPath.addMonth(monthViewPath.startMonth,
90 monthViewPath.indexType(index));
91
92+ selectedDay: monthViewPage.selectedDay
93 isYearView: false
94
95 onDateSelected: {
96 monthViewPage.dateSelected(date);
97 }
98+
99+ onDateHighlighted: {
100+ monthViewPage.dateHighlighted(date);
101+ }
102 }
103 }
104 }
105
106=== modified file 'TimeLineBaseComponent.qml'
107--- TimeLineBaseComponent.qml 2015-07-25 05:19:10 +0000
108+++ TimeLineBaseComponent.qml 2015-09-05 05:34:16 +0000
109@@ -35,6 +35,7 @@
110 property bool isActive: false
111 property alias contentY: timeLineView.contentY
112 property alias contentInteractive: timeLineView.interactive
113+ property var selectedDay;
114
115 property int type: ViewType.ViewTypeWeek
116
117@@ -44,6 +45,7 @@
118 property EventListModel mainModel;
119
120 signal dateSelected(var date);
121+ signal dateHighlighted(var date);
122
123 function scrollToCurrentTime() {
124 var currentTime = new Date();
125@@ -139,10 +141,15 @@
126 contentX: timeLineView.contentX
127 type: root.type
128 isActive: root.isActive
129+ selectedDay: root.selectedDay
130
131 onDateSelected: {
132 root.dateSelected(date);
133 }
134+
135+ onDateHighlighted: {
136+ root.dateHighlighted(date);
137+ }
138 }
139
140 SimpleDivider{}
141
142=== modified file 'TimeLineHeader.qml'
143--- TimeLineHeader.qml 2015-07-25 05:19:10 +0000
144+++ TimeLineHeader.qml 2015-09-05 05:34:16 +0000
145@@ -30,8 +30,10 @@
146 property double contentX;
147 property int firstDayOfWeek: Qt.locale().firstDayOfWeek
148 property bool isActive: false;
149+ property var selectedDay;
150
151 signal dateSelected(var date);
152+ signal dateHighlighted(var date);
153
154 width: parent.width
155 height: units.gu(10)
156@@ -155,10 +157,22 @@
157 width: parent.width
158 height: units.gu(5)
159 isCurrentItem: root.isActive
160+ selectedDay: {
161+ if( root.selectedDay && startDay.weekNumber(Qt.locale().firstDayOfWeek)
162+ === root.selectedDay.weekNumber(Qt.locale().firstDayOfWeek)) {
163+ root.selectedDay;
164+ } else {
165+ null;
166+ }
167+ }
168
169 onDateSelected: {
170 root.dateSelected(date);
171 }
172+
173+ onDateHighlighted: {
174+ root.dateHighlighted(date);
175+ }
176 }
177
178 SimpleDivider{}
179
180=== modified file 'TimeLineHeaderComponent.qml'
181--- TimeLineHeaderComponent.qml 2015-07-25 05:19:10 +0000
182+++ TimeLineHeaderComponent.qml 2015-09-05 05:34:16 +0000
183@@ -31,27 +31,42 @@
184 property var currentDay
185
186 property int highlightedIndex;
187+ property var selectedDay;
188
189 signal dateSelected(var date);
190+ signal dateHighlighted(var date);
191
192 width: parent.width
193 height: units.gu(4)
194
195+ function findSelectedDayIndex() {
196+ if(!selectedDay){
197+ return -1;
198+ }
199+ return DateExt.daysBetween(startDay, selectedDay);
200+ }
201+
202 onIsCurrentItemChanged: {
203 highlightedIndex = -1
204 }
205
206+ onSelectedDayChanged: {
207+ if(isCurrentItem){
208+ highlightedIndex = findSelectedDayIndex()
209+ }
210+ }
211+
212 Repeater{
213 model: type == ViewType.ViewTypeWeek ? 7 : 1
214
215 delegate: HeaderDateComponent{
216 date: type == ViewType.ViewTypeWeek ? startDay.addDays(index) : startDay
217 dayFormat: Locale.ShortFormat
218- highlighted: (type == ViewType.ViewTypeWeek) && (highlightedIndex == index)
219+ highlighted: (type == ViewType.ViewTypeWeek) && (highlightedIndex === index)
220
221 dayColor: {
222 if( type == ViewType.ViewTypeWeek && date.isSameDay(DateExt.today())){
223- header.highlightedIndex = index
224+ //header.highlightedIndex = index
225 UbuntuColors.orange
226 } /*else if( type == ViewType.ViewTypeDay && date.isSameDay(currentDay) ) {
227 UbuntuColors.orange
228@@ -71,6 +86,7 @@
229 header.dateSelected(date);
230 } else {
231 header.highlightedIndex = index
232+ header.dateHighlighted(date);
233 }
234 }
235 }
236
237=== modified file 'WeekView.qml'
238--- WeekView.qml 2015-03-20 17:32:03 +0000
239+++ WeekView.qml 2015-09-05 05:34:16 +0000
240@@ -28,8 +28,10 @@
241 property var dayStart: new Date();
242 property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
243 property bool isCurrentPage: false
244+ property var selectedDay;
245
246 signal dateSelected(var date);
247+ signal dateHighlighted(var date);
248
249 Keys.forwardTo: [weekViewPath]
250
251@@ -106,6 +108,7 @@
252 isActive: parent.PathView.isCurrentItem
253 startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
254 keyboardEventProvider: weekViewPath
255+ selectedDay: weekViewPage.selectedDay
256
257 onIsActiveChanged: {
258 timeLineView.scrollTocurrentDate();
259@@ -115,6 +118,10 @@
260 weekViewPage.dateSelected(date);
261 }
262
263+ onDateHighlighted:{
264+ weekViewPage.dateHighlighted(date);
265+ }
266+
267 Connections{
268 target: calendarTodayAction
269 onTriggered:{
270
271=== modified file 'calendar.qml'
272--- calendar.qml 2015-06-11 12:29:28 +0000
273+++ calendar.qml 2015-09-05 05:34:16 +0000
274@@ -214,6 +214,7 @@
275 Keys.forwardTo: [tabs.currentPage.item]
276
277 property var currentDay: DateExt.today();
278+ property var selectedDay;
279
280 // Arguments on startup
281 property bool newevent: false;
282@@ -385,6 +386,7 @@
283 source: tabs.selectedTab == monthTab ? Qt.resolvedUrl("MonthView.qml"):""
284 onLoaded: {
285 item.currentMonth = tabs.currentDay.midnight();
286+ item.selectedDay = tabs.selectedDay;
287 }
288
289 anchors{
290@@ -399,6 +401,10 @@
291 tabs.currentDay = date;
292 tabs.selectedTabIndex = dayTab.index;
293 }
294+
295+ onDateHighlighted:{
296+ tabs.selectedDay = date;
297+ }
298 }
299 }
300 }
301@@ -414,6 +420,7 @@
302 onLoaded: {
303 item.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == weekTab })
304 item.dayStart = tabs.currentDay;
305+ item.selectedDay = tabs.selectedDay;
306 }
307
308 anchors{
309@@ -432,6 +439,10 @@
310 tabs.currentDay = date;
311 tabs.selectedTabIndex = dayTab.index;
312 }
313+
314+ onDateHighlighted:{
315+ tabs.selectedDay = date;
316+ }
317 }
318 }
319 }
320
321=== modified file 'dateExt.js'
322--- dateExt.js 2015-04-02 12:54:38 +0000
323+++ dateExt.js 2015-09-05 05:34:16 +0000
324@@ -132,3 +132,18 @@
325 return ( date1.getFullYear() === date2.getFullYear()
326 && date1.getMonth() === date2.getMonth() )
327 }
328+
329+function daysBetween( date1, date2 ) {
330+ //Get 1 day in milliseconds
331+ var one_day=1000*60*60*24;
332+
333+ // Convert both dates to milliseconds
334+ var date1_ms = date1.getTime();
335+ var date2_ms = date2.getTime();
336+
337+ // Calculate the difference in milliseconds
338+ var difference_ms = date2_ms - date1_ms;
339+
340+ // Convert back to days and return
341+ return Math.round(difference_ms/one_day);
342+}

Subscribers

People subscribed via source and target branches

to status/vote changes: