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

Proposed by Kunal Parmar
Status: Merged
Approved by: Olivier Tilloy
Approved revision: no longer in the source branch.
Merged at revision: 212
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/LoaderPage
Merge into: lp:ubuntu-calendar-app
Diff against target: 633 lines (+249/-197)
6 files modified
DayView.qml (+3/-4)
MonthView.qml (+12/-17)
WeekView.qml (+69/-69)
YearView.qml (+63/-61)
calendar.qml (+101/-46)
tests/autopilot/calendar_app/tests/test_calendar.py (+1/-0)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/LoaderPage
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Olivier Tilloy (community) Approve
Review via email: mp+201277@code.launchpad.net

Commit message

Not loading all page at startup, instead now using loader element to load particular view on tab selection,

Description of the change

Not loading all page at startup, instead now using loader element to load particular view on tab selection,

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

This is a first step in the right direction, but is not enough: indeed, the views are loaded on demand, but they are never unloaded, and thus the memory is never freed until the application is quit.

review: Needs Fixing
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: Approve (continuous-integration)
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

> This is a first step in the right direction, but is not enough: indeed, the
> views are loaded on demand, but they are never unloaded, and thus the memory
> is never freed until the application is quit.

Thanks for review this and others :),
I am now unloading view when loading new view.
Please have another look

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: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

This works, but the UITK offers a simpler way of dealing with on-demand loading of pages inside tabs, see the example at http://developer.ubuntu.com/api/qml/sdk-14.04/Ubuntu.Components.Tabs/:

    Tabs {
        id: tabs
        Tab {
            id: yearTab
            page: Loader {
                source: (tabs.selectedTab === yearTab) ? Qt.resolvedUrl("YearView.qml") : ""
                onLoaded: doSomething()
            }
            […]
        }
        […]
    }

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

Thanks Olivier,

That makes more sense, however I am facing some issue with layout as of now when I initially launch application.

http://ubuntuone.com/6tRFKOkXeq8JGi1I1pOsQl

Once app is launched then if I change tab, I dont see this issue. I need to check with SDK guy then we can proceed further.

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
Kunal Parmar (pkunal-parmar) wrote :

> Thanks Olivier,
>
> That makes more sense, however I am facing some issue with layout as of now
> when I initially launch application.
>
> http://ubuntuone.com/6tRFKOkXeq8JGi1I1pOsQl
>
> Once app is launched then if I change tab, I dont see this issue. I need to
> check with SDK guy then we can proceed further.

Afrer setting anchors, issue is resolved.

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: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

523 tabs.selectedTabIndex = 3

It looks like this is useless

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

According to the documentation (see http://developer.ubuntu.com/api/qml/sdk-14.04/Ubuntu.Components.Tabs/), one should avoid setting the top anchor of the Loader:

  « As the example above shows, an external Page inside a Tab can be loaded using a Loader. Note that setting the top anchor or the height of the Loader would override the Page height. We avoid this because the Page automatically adapts its height to accommodate for the header. »

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

481 + tabs.selectedTabIndex = 1

This looks useless as well.

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

490 - }
491 + }

This changes introduces trailing whitespaces, please revert it.

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

476 + item.monthSelected.connect(yearPage.monthSelected);

517 + item.dateSelected.connect(monthPage.dateSelected);

For consistency, and because declarative code is easier to read and maintain, you should use a Connections item, like in weekPage and dayPage.

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

> According to the documentation (see
> http://developer.ubuntu.com/api/qml/sdk-14.04/Ubuntu.Components.Tabs/), one
> should avoid setting the top anchor of the Loader:
>
> « As the example above shows, an external Page inside a Tab can be loaded
> using a Loader. Note that setting the top anchor or the height of the Loader
> would override the Page height. We avoid this because the Page automatically
> adapts its height to accommodate for the header. »

Yes, I read so, but there seems some issue somewhere in SDK, not using it is making monthView disappear

http://ubuntuone.com/6VPfdnxG8YcNl6uZVgyqTN

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

> 476 +
> item.monthSelected.connect(yearPage.monthSelected);
>
> 517 +
> item.dateSelected.connect(monthPage.dateSelected);
>
> For consistency, and because declarative code is easier to read and maintain,
> you should use a Connections item, like in weekPage and dayPage.

Changed

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

> 490 - }
> 491 + }
>
> This changes introduces trailing whitespaces, please revert it.

removed

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

> 523 tabs.selectedTabIndex = 3
>
> It looks like this is useless

I do not understand, How tab will be changed, if we don't set selected tab index ?

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

> 481 + tabs.selectedTabIndex = 1
>
> This looks useless as well.

I using selectedTabIndex to change tab to MonthView, when some one click on year view. do you mean I need to do something else ?

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
Olivier Tilloy (osomon) wrote :

> > 481 + tabs.selectedTabIndex = 1
> >
> > This looks useless as well.
>
> I using selectedTabIndex to change tab to MonthView, when some one click on
> year view. do you mean I need to do something else ?

Sorry, you’re right, I don’t know what I was thinking when I wrote that. That said, there’s a cleaner way to write this, that will ensure it remains correct even if tabs get reordered in the future:

    tabs.selectedTabIndex = monthTab.index

(and the same applies to other assignments of tabs.selectedTabIndex)

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

> > According to the documentation (see
> > http://developer.ubuntu.com/api/qml/sdk-14.04/Ubuntu.Components.Tabs/), one
> > should avoid setting the top anchor of the Loader:
> >
> > « As the example above shows, an external Page inside a Tab can be loaded
> > using a Loader. Note that setting the top anchor or the height of the Loader
> > would override the Page height. We avoid this because the Page automatically
> > adapts its height to accommodate for the header. »
>
> Yes, I read so, but there seems some issue somewhere in SDK, not using it is
> making monthView disappear
>
> http://ubuntuone.com/6VPfdnxG8YcNl6uZVgyqTN

That’s probably because the MonthView component has "anchors.fill: parent" defined at the top-level. Top-level components should never have anchors defined, it breaks encapsulation.

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

> > > 481 + tabs.selectedTabIndex = 1
> > >
> > > This looks useless as well.
> >
> > I using selectedTabIndex to change tab to MonthView, when some one click on
> > year view. do you mean I need to do something else ?
>
> Sorry, you’re right, I don’t know what I was thinking when I wrote that. That
> said, there’s a cleaner way to write this, that will ensure it remains correct
> even if tabs get reordered in the future:
>
> tabs.selectedTabIndex = monthTab.index
>
> (and the same applies to other assignments of tabs.selectedTabIndex)

yes, this seems better, I changed it now

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

> > > According to the documentation (see
> > > http://developer.ubuntu.com/api/qml/sdk-14.04/Ubuntu.Components.Tabs/),
> one
> > > should avoid setting the top anchor of the Loader:
> > >
> > > « As the example above shows, an external Page inside a Tab can be
> loaded
> > > using a Loader. Note that setting the top anchor or the height of the
> Loader
> > > would override the Page height. We avoid this because the Page
> automatically
> > > adapts its height to accommodate for the header. »
> >
> > Yes, I read so, but there seems some issue somewhere in SDK, not using it is
> > making monthView disappear
> >
> > http://ubuntuone.com/6VPfdnxG8YcNl6uZVgyqTN
>
> That’s probably because the MonthView component has "anchors.fill: parent"
> defined at the top-level. Top-level components should never have anchors
> defined, it breaks encapsulation.

Actually I intentionally put anchors.fill in MomthView, As only anchors.fill in MonthView and anchors.top in Calendar, combination seems to layout MonthView properly.

In every other case it either does not show anything or leave blank space on top, like in previous snapshot.

May be its issue with my version of SDK or bug in SDK, but as of now, only this combination works.

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 :

> > > > 481 + tabs.selectedTabIndex = 1
> > > >
> > > > This looks useless as well.
> > >
> > > I using selectedTabIndex to change tab to MonthView, when some one click
> on
> > > year view. do you mean I need to do something else ?
> >
> > Sorry, you’re right, I don’t know what I was thinking when I wrote that.
> That
> > said, there’s a cleaner way to write this, that will ensure it remains
> correct
> > even if tabs get reordered in the future:
> >
> > tabs.selectedTabIndex = monthTab.index
> >
> > (and the same applies to other assignments of tabs.selectedTabIndex)
>
> yes, this seems better, I changed it now

There are still 3 occurrences of hardcoded index assignment in calendar.qml (lines 183, 189, 193), and a function called calculateDifferenceStarttimeEndtime that returns an index as well, so you should remove hardcoded values from there as well.

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

> > > > According to the documentation (see
> > > > http://developer.ubuntu.com/api/qml/sdk-14.04/Ubuntu.Components.Tabs/),
> > one
> > > > should avoid setting the top anchor of the Loader:
> > > >
> > > > « As the example above shows, an external Page inside a Tab can be
> > loaded
> > > > using a Loader. Note that setting the top anchor or the height of the
> > Loader
> > > > would override the Page height. We avoid this because the Page
> > automatically
> > > > adapts its height to accommodate for the header. »
> > >
> > > Yes, I read so, but there seems some issue somewhere in SDK, not using it
> is
> > > making monthView disappear
> > >
> > > http://ubuntuone.com/6VPfdnxG8YcNl6uZVgyqTN
> >
> > That’s probably because the MonthView component has "anchors.fill: parent"
> > defined at the top-level. Top-level components should never have anchors
> > defined, it breaks encapsulation.
>
> Actually I intentionally put anchors.fill in MomthView, As only anchors.fill
> in MonthView and anchors.top in Calendar, combination seems to layout
> MonthView properly.
>
> In every other case it either does not show anything or leave blank space on
> top, like in previous snapshot.
>
> May be its issue with my version of SDK or bug in SDK, but as of now, only
> this combination works.

Indeed, there is something fishy there, I’ve had a quick play with it myself and couldn’t get it to work as documented. Would you mind filing a bug against the UITK? We can try and address it in the calendar in a separate branch.

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

>
> Indeed, there is something fishy there, I’ve had a quick play with it myself
> and couldn’t get it to work as documented. Would you mind filing a bug against
> the UITK? We can try and address it in the calendar in a separate branch.

Thanks for conforming, sure I will create a bug and may be a sample code that replicate the same.

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

> There are still 3 occurrences of hardcoded index assignment in calendar.qml
> (lines 183, 189, 193), and a function called
> calculateDifferenceStarttimeEndtime that returns an index as well, so you
> should remove hardcoded values from there as well.

Thanks, changed those.

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
Olivier Tilloy (osomon) wrote :

471 + property bool initDone: false

This new property seems to be unused, can it be removed?

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

> 471 + property bool initDone: false
>
> This new property seems to be unused, can it be removed?

Removed, I was trying something but this properly was left behind.

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 good!

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
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
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
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
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) :
review: Approve (continuous-integration)
212. By Kunal Parmar

Not loading all page at startup, instead now using loader element to load particular view on tab selection,.

Approved by Ubuntu Phone Apps Jenkins Bot, Olivier Tilloy.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DayView.qml'
2--- DayView.qml 2014-01-31 03:20:40 +0000
3+++ DayView.qml 2014-03-12 00:17:21 +0000
4@@ -4,7 +4,8 @@
5 import "dateExt.js" as DateExt
6 import "ViewType.js" as ViewType
7
8-Item{
9+
10+Page{
11 id: root
12 objectName: "DayView"
13
14@@ -12,13 +13,11 @@
15
16 Column {
17 id: column
18+ anchors.fill: parent
19 anchors.top: parent.top
20 anchors.topMargin: units.gu(1.5)
21- width: parent.width; height: parent.height
22 spacing: units.gu(1)
23
24- anchors.fill: parent
25-
26 ViewHeader{
27 id: viewHeader
28 date: currentDay
29
30=== modified file 'MonthView.qml'
31--- MonthView.qml 2014-01-31 01:35:20 +0000
32+++ MonthView.qml 2014-03-12 00:17:21 +0000
33@@ -3,23 +3,18 @@
34 import "dateExt.js" as DateExt
35 import "colorUtils.js" as Color
36
37-Page {
38- id: monthViewPage
39- objectName: "MonthView"
40+Page{
41+ id: root
42
43 property var currentMonth: DateExt.today();
44-
45 signal dateSelected(var date);
46
47+ anchors.fill: parent
48+
49 PathViewBase{
50 id: monthViewPath
51-
52- property var startMonth: currentMonth;
53-
54- anchors.top:parent.top
55-
56- width:parent.width
57- height: parent.height
58+ objectName: "MonthView"
59+ anchors.fill: parent
60
61 onNextItemHighlighted: {
62 nextMonth();
63@@ -30,11 +25,11 @@
64 }
65
66 function nextMonth() {
67- currentMonth = addMonth(currentMonth,1);
68+ currentMonth = addMonth(root.currentMonth,1);
69 }
70
71 function previousMonth(){
72- currentMonth = addMonth(currentMonth,-1);
73+ currentMonth = addMonth(root.currentMonth,-1);
74 }
75
76 function addMonth(date,month){
77@@ -54,16 +49,16 @@
78 function getMonthDate() {
79 switch( monthViewPath.indexType(index)) {
80 case 0:
81- return monthViewPath.startMonth;
82+ return monthViewPath.addMonth(root.currentMonth,0);
83 case -1:
84- return monthViewPath.addMonth(monthViewPath.startMonth,-1);
85+ return monthViewPath.addMonth(root.currentMonth,-1);
86 case 1:
87- return monthViewPath.addMonth(monthViewPath.startMonth,1);
88+ return monthViewPath.addMonth(root.currentMonth,1);
89 }
90 }
91
92 onDateSelected: {
93- monthViewPage.dateSelected(date);
94+ root.dateSelected(date);
95 }
96 }
97 }
98
99=== modified file 'WeekView.qml'
100--- WeekView.qml 2014-02-12 00:24:25 +0000
101+++ WeekView.qml 2014-03-12 00:17:21 +0000
102@@ -4,82 +4,82 @@
103 import "dateExt.js" as DateExt
104 import "ViewType.js" as ViewType
105
106-Column {
107+Page{
108 id: root
109- objectName: "WeekView"
110-
111 property var dayStart: new Date();
112 property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
113- anchors.top: parent.top
114- anchors.topMargin: units.gu(1.5)
115- spacing: units.gu(1)
116-
117- anchors.fill: parent
118-
119- ViewHeader{
120- id: viewHeader
121- date: dayStart
122- }
123-
124- TimeLineHeader{
125- id: weekHeader
126- objectName: "weekHeader"
127- type: ViewType.ViewTypeWeek
128- date: weekViewPath.weekStart
129- }
130-
131- PathViewBase{
132- id: weekViewPath
133-
134- property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);
135- property var weekStart: weekViewPath.visibleWeek
136-
137- width: parent.width
138- height: root.height - weekViewPath.y
139-
140- onNextItemHighlighted: {
141- nextWeek();
142- weekHeader.incrementCurrentIndex()
143- }
144-
145- onPreviousItemHighlighted: {
146- previousWeek();
147- weekHeader.decrementCurrentIndex()
148- }
149-
150- function nextWeek() {
151- var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
152- dayStart = weekStartDay.addDays(7);
153- }
154-
155- function previousWeek(){
156- var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
157- dayStart = weekStartDay.addDays(-7);
158- }
159-
160- delegate: TimeLineBaseComponent {
161- id: timeLineView
162-
163- type: ViewType.ViewTypeWeek
164+
165+ Column {
166+ objectName: "WeekView"
167+
168+ anchors.fill: parent
169+ anchors.top: parent.top
170+ anchors.topMargin: units.gu(1.5)
171+ spacing: units.gu(1)
172+
173+ ViewHeader{
174+ id: viewHeader
175+ date: dayStart
176+ }
177+
178+ TimeLineHeader{
179+ id: weekHeader
180+ objectName: "weekHeader"
181+ type: typeWeek
182+ date: weekViewPath.weekStart
183+ }
184+
185+ PathViewBase{
186+ id: weekViewPath
187+
188+ property var visibleWeek: root.dayStart.weekStart(Qt.locale().firstDayOfWeek);
189+ property var weekStart: weekViewPath.visibleWeek
190
191 width: parent.width
192- height: parent.height
193- startDay: getWeekStart();
194-
195- function getWeekStart() {
196- switch( weekViewPath.indexType(index)) {
197- case 0:
198- return weekViewPath.weekStart;
199- case -1:
200- var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
201- return weekStartDay.addDays(-7);
202- case 1:
203- var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
204- return weekStartDay.addDays(7);
205+ height: root.height - weekViewPath.y
206+
207+ onNextItemHighlighted: {
208+ nextWeek();
209+ weekHeader.incrementCurrentIndex()
210+ }
211+
212+ onPreviousItemHighlighted: {
213+ previousWeek();
214+ weekHeader.decrementCurrentIndex()
215+ }
216+
217+ function nextWeek() {
218+ var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
219+ dayStart = weekStartDay.addDays(7);
220+ }
221+
222+ function previousWeek(){
223+ var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
224+ dayStart = weekStartDay.addDays(-7);
225+ }
226+
227+ delegate: TimeLineBaseComponent {
228+ id: timeLineView
229+
230+ type: typeWeek
231+
232+ width: parent.width
233+ height: parent.height
234+ startDay: getWeekStart();
235+
236+ function getWeekStart() {
237+ switch( weekViewPath.indexType(index)) {
238+ case 0:
239+ return weekViewPath.weekStart;
240+ case -1:
241+ var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
242+ return weekStartDay.addDays(-7);
243+ case 1:
244+ var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
245+ return weekStartDay.addDays(7);
246+ }
247 }
248 }
249 }
250 }
251 }
252-
253-
254
255=== modified file 'YearView.qml'
256--- YearView.qml 2014-02-10 16:08:55 +0000
257+++ YearView.qml 2014-03-12 00:17:21 +0000
258@@ -3,76 +3,78 @@
259
260 import "dateExt.js" as DateExt
261
262-PathViewBase {
263+Page {
264 id: root
265 objectName: "YearView"
266-
267 property var currentYear: DateExt.today();
268-
269 signal monthSelected(var date);
270
271- anchors.fill: parent
272-
273- onNextItemHighlighted: {
274- currentYear = getDateFromYear(currentYear.getFullYear() + 1);
275- }
276-
277- onPreviousItemHighlighted: {
278- currentYear = getDateFromYear(currentYear.getFullYear() - 1);
279- }
280-
281- function getDateFromYear(year) {
282- return new Date(year,0,1,0,0,0,0);
283- }
284-
285- delegate: GridView{
286- id: yearView
287- clip: true
288-
289- property bool isCurrentItem: index == root.currentIndex
290- property var year: getYear();
291-
292- function getYear() {
293- switch( root.indexType(index)) {
294- case 0:
295- return currentYear;
296- case -1:
297- return getDateFromYear(currentYear.getFullYear() - 1);
298- case 1:
299- return getDateFromYear(currentYear.getFullYear() + 1);
300+ PathViewBase {
301+ id: pathView
302+
303+ anchors.fill: parent
304+
305+ onNextItemHighlighted: {
306+ root.currentYear = pathView.getDateFromYear(root.currentYear.getFullYear() + 1);
307+ }
308+
309+ onPreviousItemHighlighted: {
310+ root.currentYear = pathView.getDateFromYear(root.currentYear.getFullYear() - 1);
311+ }
312+
313+ function getDateFromYear(year) {
314+ return new Date(year,0,1,0,0,0,0);
315+ }
316+
317+ delegate: GridView{
318+ id: yearView
319+ clip: true
320+
321+ property bool isCurrentItem: index == pathView.currentIndex
322+ property var year: getYear();
323+
324+ function getYear() {
325+ switch( pathView.indexType(index)) {
326+ case 0:
327+ return root.currentYear;
328+ case -1:
329+ return pathView.getDateFromYear(root.currentYear.getFullYear() - 1);
330+ case 1:
331+ return pathView.getDateFromYear(root.currentYear.getFullYear() + 1);
332+ }
333 }
334- }
335-
336- width: parent.width
337- height: parent.height
338- anchors.top: parent.top
339-
340- readonly property int minCellWidth: units.gu(30)
341- cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n)
342+
343+ width: parent.width
344+ height: parent.height
345+ anchors.top: parent.top
346+
347+ readonly property int minCellWidth: units.gu(30)
348+ cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n)
349 { return ((width / n >= minCellWidth) ? width / n : width / 2) })))
350
351- cellHeight: cellWidth * 1.4
352-
353- model: 12 /* months in a year */
354- delegate: Item {
355- width: yearView.cellWidth
356- height: yearView.cellHeight
357-
358- MonthComponent{
359- id: monthComponent
360- monthDate: new Date(yearView.year.getFullYear(),index,1,0,0,0,0)
361- anchors.fill: parent
362- anchors.margins: units.gu(0.5)
363-
364- dayLabelFontSize:"x-small"
365- dateLabelFontSize: "medium"
366- monthLabelFontSize: "medium"
367- yearLabelFontSize: "small"
368-
369- MouseArea{
370+ cellHeight: cellWidth * 1.4
371+
372+ model: 12 /* months in a year */
373+ delegate: Item {
374+ width: yearView.cellWidth
375+ height: yearView.cellHeight
376+
377+ MonthComponent{
378+ id: monthComponent
379+ monthDate: new Date(yearView.year.getFullYear(),index,1,0,0,0,0)
380 anchors.fill: parent
381- onClicked: {
382- root.monthSelected(monthComponent.monthDate);
383+ anchors.margins: units.gu(0.5)
384+
385+ dayLabelFontSize:"x-small"
386+ dateLabelFontSize: "medium"
387+ monthLabelFontSize: "medium"
388+ yearLabelFontSize: "small"
389+
390+ MouseArea{
391+ anchors.fill: parent
392+ onClicked: {
393+ root.monthSelected(monthComponent.monthDate);
394+ }
395 }
396 }
397 }
398
399=== modified file 'calendar.qml'
400--- calendar.qml 2014-02-27 13:41:58 +0000
401+++ calendar.qml 2014-03-12 00:17:21 +0000
402@@ -76,14 +76,16 @@
403 property int endtime: -1;
404
405 onCurrentDayChanged: {
406- if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))
407- monthView.currentMonth = currentDay.midnight();
408-
409- if( !dayView.currentDay.isSameDay(currentDay))
410- dayView.currentDay = currentDay
411-
412- if( !weekView.dayStart.isSameDay(currentDay))
413- weekView.dayStart = currentDay
414+ if( monthPage.item
415+ && monthPage.item.currentMonth !== undefined
416+ && !monthPage.item.currentMonth.isSameDay(currentDay))
417+ monthPage.item.currentMonth = currentDay.midnight();
418+
419+ if( dayPage.item && !dayPage.item.currentDay.isSameDay(currentDay))
420+ dayPage.item.currentDay = currentDay
421+
422+ if( weekPage.item && !weekPage.item.dayStart.isSameDay(currentDay))
423+ weekPage.item.dayStart = currentDay
424
425 setStartEndDateToModel();
426 }
427@@ -133,13 +135,13 @@
428 var difference = endTime - startTime;
429
430 if (difference > month)
431- return 0; // Year view
432+ return yearTab.index; // Year view
433 else if (difference > 7 * day)
434- return 1; // Month view}
435+ return monthTab.index; // Month view}
436 else if (difference > day)
437- return 2; // Week view
438+ return weekTab.index; // Week view
439 else
440- return 3; // Day view
441+ return dayTab.index; // Day view
442 }
443
444 // This function parse the argument
445@@ -178,17 +180,17 @@
446 }
447 else {
448 // If no endtime has been setted, open the starttime date in day view
449- tabs.selectedTabIndex = 3;
450+ tabs.selectedTabIndex = dayTab.index;
451 }
452 } // End of else if (starttime)
453 else {
454 // Due to bug #1231558 {if (args.defaultArgument.at(0))} is always true
455 // After the fix we can delete this else
456- tabs.selectedTabIndex= 1;
457+ tabs.selectedTabIndex = monthTab.index;
458 }
459 } // End of if about args.values
460 else {
461- tabs.selectedTabIndex= 1;
462+ tabs.selectedTabIndex = monthTab.index;
463 }
464
465 globalModel = GlobalModel.globalModel();
466@@ -233,71 +235,124 @@
467
468 Tabs{
469 id: tabs
470+
471 Tab{
472+ id: yearTab
473 objectName: "yearTab"
474 title: i18n.tr("Year")
475- page: Page{
476+ page: Loader{
477+ id: yearPage
478 objectName: "yearPage"
479- anchors.fill: parent
480- tools: commonToolBar
481- YearView{
482+ anchors {
483+ top: parent.top
484+ left: parent.left
485+ right: parent.right
486+ bottom: parent.bottom
487+ }
488+ source: (tabs.selectedTab === yearTab) ? Qt.resolvedUrl("YearView.qml") : ""
489+
490+ onLoaded:{
491+ item.tools = commonToolBar
492+ }
493+
494+ Connections{
495+ target: yearPage.item
496 onMonthSelected: {
497- tabs.selectedTabIndex = 1
498+ tabs.selectedTabIndex = monthTab.index
499 var now = DateExt.today();
500 if( date.getMonth() === now.getMonth()
501 && date.getFullYear() === now.getFullYear()) {
502- monthView.currentMonth = now
503+ tabPage.currentDay = now;
504 } else {
505- monthView.currentMonth = date.midnight();
506+ tabPage.currentDay = date.midnight();
507 }
508 }
509 }
510 }
511 }
512+
513 Tab {
514 id: monthTab
515 objectName: "monthTab"
516 title: i18n.tr("Month")
517- page: MonthView{
518- anchors.fill: parent
519- tools: commonToolBar
520- id: monthView
521-
522- onDateSelected: {
523- tabs.selectedTabIndex = 3
524- tabPage.currentDay = date;
525+
526+ page: Loader{
527+ id: monthPage
528+ anchors {
529+ top: parent.top
530+ left: parent.left
531+ right: parent.right
532+ bottom: parent.bottom
533+ }
534+
535+ source: (tabs.selectedTab === monthTab) ? Qt.resolvedUrl("MonthView.qml") : ""
536+
537+ onLoaded: {
538+ item.currentMonth = tabPage.currentDay.midnight();
539+ item.tools = commonToolBar
540+ }
541+
542+ Connections{
543+ target: monthPage.item
544+ onDateSelected: {
545+ tabs.selectedTabIndex = dayTab.index
546+ tabPage.currentDay = date;
547+ }
548 }
549 }
550 }
551+
552 Tab{
553+ id: weekTab
554 objectName: "weekTab"
555 title: i18n.tr("Week")
556- page: Page{
557- anchors.fill: parent
558- tools: commonToolBar
559- WeekView{
560- id: weekView
561- anchors.fill: parent
562-
563+ page: Loader{
564+ id: weekPage
565+ anchors {
566+ top: parent.top
567+ left: parent.left
568+ right: parent.right
569+ bottom: parent.bottom
570+ }
571+ source: (tabs.selectedTab === weekTab) ? Qt.resolvedUrl("WeekView.qml") : ""
572+
573+ onLoaded: {
574+ item.dayStart = tabPage.currentDay;
575+ item.tools = commonToolBar
576+ }
577+
578+ Connections{
579+ target: weekPage.item
580 onDayStartChanged: {
581- tabPage.currentDay = dayStart;
582+ tabPage.currentDay = weekPage.item.dayStart;
583 }
584 }
585 }
586 }
587
588 Tab{
589+ id: dayTab
590 objectName: "dayTab"
591 title: i18n.tr("Day")
592- page: Page{
593- anchors.fill: parent
594- tools: commonToolBar
595- DayView{
596- id: dayView
597- anchors.fill: parent
598-
599+ page: Loader{
600+ id: dayPage
601+ anchors {
602+ top: parent.top
603+ left: parent.left
604+ right: parent.right
605+ bottom: parent.bottom
606+ }
607+ source: (tabs.selectedTab === dayTab) ? Qt.resolvedUrl("DayView.qml") : ""
608+
609+ onLoaded: {
610+ item.currentDay = tabPage.currentDay;
611+ item.tools = commonToolBar
612+ }
613+
614+ Connections{
615+ target: dayPage.item
616 onCurrentDayChanged: {
617- tabPage.currentDay = currentDay;
618+ tabPage.currentDay = dayPage.item.currentDay;
619 }
620 }
621 }
622
623=== modified file 'tests/autopilot/calendar_app/tests/test_calendar.py'
624--- tests/autopilot/calendar_app/tests/test_calendar.py 2013-11-15 16:30:52 +0000
625+++ tests/autopilot/calendar_app/tests/test_calendar.py 2014-03-12 00:17:21 +0000
626@@ -94,6 +94,7 @@
627 self.main_view.open_toolbar().click_button("eventSaveButton")
628
629 #verify that the event has been created in timeline
630+ self.main_view.switch_to_tab("dayTab")
631 self.assertThat(lambda: self.main_view.get_label_with_text(
632 eventTitle, root=self.main_view.get_day_view()),
633 Eventually(Not(Is(None))))

Subscribers

People subscribed via source and target branches

to status/vote changes: