Merge lp:~yohanboniface/ubuntu-calendar-app/AgendaView into lp:ubuntu-calendar-app

Proposed by ybon
Status: Rejected
Rejected by: Mihir Soni
Proposed branch: lp:~yohanboniface/ubuntu-calendar-app/AgendaView
Merge into: lp:ubuntu-calendar-app
Diff against target: 161 lines (+135/-0)
3 files modified
AgendaView.qml (+107/-0)
calendar.qml (+14/-0)
dateExt.js (+14/-0)
To merge this branch: bzr merge lp:~yohanboniface/ubuntu-calendar-app/AgendaView
Reviewer Review Type Date Requested Status
Mihir Soni Disapprove
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Kunal Parmar Needs Fixing
Victor Thompson (community) Needs Information
Review via email: mp+212164@code.launchpad.net

Commit message

Basic version of a AgendaView (flat ordered list of incoming events).
Need autopilot tests.
See http://imgur.com/BodtxLK for a preview.

Description of the change

Basic version of a AgendaView (flat ordered list of incoming events).
Need autopilot tests.
See http://imgur.com/BodtxLK for a preview.

To post a comment you must log in.
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

16 + property var model;

This looks like private variable for this view.
Can we shift it to internal QtObject like, and use that
QtObject{
 id: internal
 property var model;
}

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

+Item {
13 + id: root
14 + objectName: "AgendaView"

Can you make this a Page? I am planning to make other Views also a Page, to make those loaded using Loader on demand.

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

+ Column {
35 + id: column
36 + anchors.top: parent.top
37 + anchors.topMargin: units.gu(1.5)
38 + width: parent.width; height: parent.height
39 + spacing: units.gu(1)
40 +
41 + anchors.fill: parent

I think If we are using anchors.fill, then we don't need to set width and height.

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

+ Component.onCompleted: {
44 + model = GlobalModel.gloablModel();
45 + model.reloaded.connect(buildList);
46 + }

As we are loading whole year's events using buildList, I suspect there will be performance problem, might hang UI if there are many events.

I think for this case it might be better to use separate OrganizerModel for agenda view, then you will not need to populate model your self and also it will not rebuild model in case of addition or deletion of event.

But I need to consult EDS developer for the same.

202. By ybon

Merged from trunk

203. By ybon

Use QtObject instead of item property

204. By ybon

Replace Item by Page

205. By ybon

No need to width/height when using anchors.fill

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

54 + var itemIds = intern.model.itemIds(new Date().midnight());

as per discussion here
https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1298239

In agenda view, we decided to show events only for one month, can you address that.

Rest of changes looks good to me

Revision history for this message
ybon (yohanboniface) wrote :

Sure, I will try to take time today for this.

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

121 + Tab {
122 + objectName: "agendaTab"
123 + title: i18n.tr("Agenda")
124 + page: Page {
125 + anchors.fill: parent
126 + tools: commonToolBar
127 + AgendaView {
128 + id: agendaView
129 + anchors.fill: parent
130 + }
131 + }
132 + }

Agenda view is already a Page, we need not create another Page container for agenda view.

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

145 +Date.prototype.formatTime = function (d) {
146 + // TRANSLATORS: this is a time formatting string,
147 + // see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
148 + var format = qsTr("hh:mm");
149 + return Qt.formatTime(this, format);
150 +}

I was suggested to use following for time date translation, can you also use the same.

        var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
        var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat);

BTW above code is from EventDetails.

Revision history for this message
ybon (yohanboniface) wrote :

Oh, you're right. But then what was you expecting me to do with this comment: https://code.launchpad.net/~yohanboniface/ubuntu-calendar-app/AgendaView/+merge/212164/comments/501716 ?

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

> Oh, you're right. But then what was you expecting me to do with this comment:
> https://code.launchpad.net/~yohanboniface/ubuntu-calendar-
> app/AgendaView/+merge/212164/comments/501716 ?

so, I wanted to you make root element of AgendaView a Page.

12 +Page {
13 + id: root
14 + objectName: "AgendaView"

Which you already did, I have no further comment there.

But, you are creating a Page and putting AgendaView ( which is also a page) inside this page, which is not necessary.
        + page: Page {
125 + anchors.fill: parent
126 + tools: commonToolBar
127 + AgendaView {

so, I think we can directly put AgendaView inside tab, instead of creating intermediate page. Like

+ Tab {
122 + objectName: "agendaTab"
123 + title: i18n.tr("Agenda")
124 + page: AgendaView {
                                  tools: commonToolBar
                                  // and rest of necessary properties
                             }

206. By ybon

Use an Item for AgendaView for now

207. By ybon

Pick only next month events in AgendaView

Revision history for this message
ybon (yohanboniface) wrote :

I've reverted the Page thing to Item for now. I see that in the trunk it's not cleaned yet, so I suggest not to mix MR and to fix Tab/Page structure once for all in a dedicate branch.

Revision history for this message
ybon (yohanboniface) wrote :

If I replace
Date.prototype.formatDate = function () {
    // TRANSLATORS: this is a date formatting string,
    // see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
    var format = qsTr("dd MMMM yyyy");
    return Qt.formatDate(this, format);
}

by

Date.prototype.formatDate = function () {
    this.toLocaleTimeString(Qt.locale(), "dd MMMM yyyy");
    return this;
}

I only have raw date printed.
It may be that Qt.locale() without argument is not finding any default.

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

>
> Date.prototype.formatDate = function () {
> this.toLocaleTimeString(Qt.locale(), "dd MMMM yyyy");
> return this;
> }
>
> I only have raw date printed.
> It may be that Qt.locale() without argument is not finding any default.

ok, I will have a look then

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

I missed something in original comment,

        var timeFormat = i18n.tr("hh:mm");
        var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
        var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat);

I was suggested to use i18n.tr() instead of qsTr(), and format date/time as shown in above code.

but I am not able to figure out how to use i18n.tr from using from JS.
How about using code similar to above from QML directly for now ?
and then take help from some expert for how to move formating code to JS lib and use i18n.tr from JS,

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
Roman Shchekin (mrqtros) wrote :

section property can be reformatted:

section {
    property:
    ...
}

Revision history for this message
ybon (yohanboniface) wrote :

@Kunal: I suggest to keep code DRY and well organised/separated, and thus to keep the Date custom methods in DateExt (instead of putting generic functions in a qml file), and to update there when we know how to properly handle date localization in JavaScript. Thoughts?

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 :

> @Kunal: I suggest to keep code DRY and well organised/separated, and thus to
> keep the Date custom methods in DateExt (instead of putting generic functions
> in a qml file), and to update there when we know how to properly handle date
> localization in JavaScript. Thoughts?

I personally would prefer correctness over structure of code. Not to say that your code is not correct, but as I said
earlier, I was suggested to use following over Qt.formatDate, so I will suggest you to use the same.

        var timeFormat = i18n.tr("hh:mm");
        var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat)

But if you must use function then I have following suggestion.
- Create a QtObject and move format function there, like done in Defines.js, getReminderLabels() function. that will allow usage of i18n.tr with toLocaleTimeString.

- now that we are using toLocaleTimeString, we can have only single format function that takes DATE/TIME format as argument and we can have constant with well defined name and use function with those constants.

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Looks good, but I'm not sure I need to see my alarms in there, or indeed where they're coming from..?

http://imgur.com/OK9MbMK

Revision history for this message
ybon (yohanboniface) wrote :

@kunal: ok, will do before next moon ;)
@popey: don't you have the alarm showing also on other views?

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

@ybon, no.

208. By ybon

Merge with trunk

209. By ybon

merge

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
ybon (yohanboniface) wrote :

One curious thing about i18n.tr() and JavaScript is that I'm able to use it directly in the JavaScript file in OSMTouch, but not in Calendar. See http://bazaar.launchpad.net/~yohanboniface/osmtouch/trunk/view/head:/components/Categories.js
I need to investigate this.

Revision history for this message
ybon (yohanboniface) wrote :

@popey: I've merged with trunk, can you please try again and see if alarm things are still shown?

Revision history for this message
Victor Thompson (vthompson) wrote :

I just tested from trunk and I see my Clock alarms as well: http://imgur.com/QPBTd0q

Only the "Test" and "Test2" events should have been shown.

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

 + Component.onCompleted: {
48 + mainModel.addModelChangeListener(buildList);
49 + }
50 +
51 + function buildList () {
52 + eventModel.clear();

Now that you are using EventListModel {}, you should be able to use it directly with your ListView.

And you should be able to achieve following.
// 3. no way to cheat like adding on the fly a method or property to the ListItem while looping

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

> One curious thing about i18n.tr() and JavaScript is that I'm able to use it
> directly in the JavaScript file in OSMTouch, but not in Calendar. See http://b
> azaar.launchpad.net/~yohanboniface/osmtouch/trunk/view/head:/components/Catego
> ries.js
> I need to investigate this.

This is because, Calendar JS file is shared library, declared by
.pragma library. But your JS file does not seems to be shared lib.

http://qt-project.org/doc/qt-5/qtqml-javascript-resources.html

Revision history for this message
ybon (yohanboniface) wrote :

Thanks all for answers.
@Kunal: how can I filter alarm events? I don't see where this is done in other event list of calendar app.

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

I am not sure why only agenda view is getting alarm data, but looking at Alarm model source code.

Alarm is stored as todo item type. so if you apply Detail Filter on model with only item type of ItemType.Event
ItemType.EventOccurrence . you should be able to filter out alarm data from model.

http://developer.ubuntu.com/api/qml/sdk-1.0/QtOrganizer.ItemType/
http://developer.ubuntu.com/api/qml/sdk-1.0/QtOrganizer.DetailFilter/

http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/trunk/view/head:/modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp

Revision history for this message
ybon (yohanboniface) wrote :

Status: not able, even with the help of renato, to make the DetailFilter work (here is a smaller test case: http://paste.ubuntu.com/7257603/ but not working, i.e. no event at all is displayed as soon as I set up the filter).

> And you should be able to achieve following.
> // 3. no way to cheat like adding on the fly a method or property to the ListItem while looping

No sure how :)
I can use EvenListModel directly as model in my ListView, yes, but I don't know how to set a property on each item with the event *date* value (in string format). Any clue?

Thanks!

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

I will need to check about DetailsFilter, I never tried that filter.

> I can use EvenListModel directly as model in my ListView, yes, but I don't
> know how to set a property on each item with the event *date* value (in string
> format). Any clue?

Regarding using EventListModel directly, something like following should work. Though we need i18n.tr, instead of Qt.formatDate, this is code from Qt example.

                TextEdit {
                    id: startTime
                    font.pixelSize: 12
                    text: (model.item) ? Qt.formatDate(
                                             model.item.startDateTime) : ""
                    readOnly: true
                }

Following is link for complete example, will be useful.
https://qt.gitorious.org/qt/qtpim/source/cdbe3d4a34f728caaac15eccc9fdca3195b60b3a:examples/organizer/qmlorganizerlistview/qmlorganizerlistview.qml

Revision history for this message
Victor Thompson (vthompson) wrote :

In your test code I see the following console output:

file:///home/victor/Development/test.qml:11:17: Unable to assign int to QDeclarativeOrganizerItemDetail*

Seems like DetailFilter's detail property can not be set directly to the enumeration.

Revision history for this message
Victor Thompson (vthompson) wrote :

I think you'll also want to merge with trunk and add the Loader infrastructure for the AgendaView tab as well. I believe the tab won't be visible otherwise. I say this because this might also resolve some errors I see in the console with this branch.

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

Victor is right, DetailFilter's details propperty accepts Type object and not type itself.
Needs to do something like below.

    Type {
        id: typeDetailToMatch
        type: Type.Todo
    }
    DetailFilter {
        id: todoFilter
        detail: typeDetailToMatch
    }

Revision history for this message
ybon (yohanboniface) wrote :

> I will need to check about DetailsFilter, I never tried that filter.
>
> > I can use EvenListModel directly as model in my ListView, yes, but I don't
> > know how to set a property on each item with the event *date* value (in
> string
> > format). Any clue?
>
> Regarding using EventListModel directly, something like following should work.
> Though we need i18n.tr, instead of Qt.formatDate, this is code from Qt
> example.
>
> TextEdit {
> id: startTime
> font.pixelSize: 12
> text: (model.item) ? Qt.formatDate(
> model.item.startDateTime) : ""
> readOnly: true
> }
>
> Following is link for complete example, will be useful.
> https://qt.gitorious.org/qt/qtpim/source/cdbe3d4a34f728caaac15eccc9fdca3195b60
> b3a:examples/organizer/qmlorganizerlistview/qmlorganizerlistview.qml

Sorry, it seems I've not been clear.
The need is to have the date of the event to create the "section" part (the date header that group events of same day).
So we need:
- a property on each item (cannot be a method, section don't want a method)
- the property value need to be the date, without hours, minutes, etc. Because to want to group event by day, so we need events of same day to have the exact same value in the property given to section
- this property need to be a string type (not a date, section seems to only call the toString() of the property), not a Date type

If you have an idea, great! If not, I will but back my ugly workaround... ;)

Revision history for this message
ybon (yohanboniface) wrote :

> Victor is right, DetailFilter's details propperty accepts Type object and not
> type itself.
> Needs to do something like below.
>
> Type {
> id: typeDetailToMatch
> type: Type.Todo
> }
> DetailFilter {
> id: todoFilter
> detail: typeDetailToMatch
> }

Well, I know that, I've read the documentation too. This example comes right from the DetailFilter page (http://developer.ubuntu.com/api/qml/sdk-14.04/QtOrganizer.DetailFilter/), and indeed this was my first attempt too, but it doesn't work either:

ybon@edoardo:~/Code/qml/calendar-app$ qmlscene testfilter.qml
file:///home/ybon/Code/qml/calendar-app/testfilter.qml:10 Invalid property assignment: "type" is a read-only property

We need someone who *knows*. The documentation is useless and wrong (and renato sadly doesn't know either). And I sadly don't have enough time these days to play the riddle for hours :(

Revision history for this message
Victor Thompson (vthompson) wrote :

Does the following qmltypes file [1] give any useful information? Also, note there's a qmltypes file for QtOrganizer installed by default under "/usr/lib/*/qt5/qml/QtOrganizer/plugins.qmltypes", IIRC.

[1] https://github.com/qtproject/qtpim/blob/master/src/imports/organizer/plugins.qmltypes

Revision history for this message
ybon (yohanboniface) wrote :

AFAIK, the available types are here: http://developer.ubuntu.com/api/qml/sdk-14.04/QtOrganizer.ItemType/#itemType-prop but I don't know how to filter them ;)

Revision history for this message
Michael Hall (mhall119) wrote :

It seems the example given in DetailFilter is incorrect. From what I can tell, the "Type" component doesn't exist, but the "Detail" component has the same properties and would make sense to assign to the 'detail' property of DetailFilter. Also there is no Type enum, but ItemType seems to contain the value used in the example. So maybe something like this:

    Detail {
        id: typeDetailToMatch
        type: ItemType.Todo
    }
    DetailFilter {
        id: todoFilter
        detail: typeDetailToMatch
    }

Revision history for this message
Michael Hall (mhall119) wrote :

Or maybe this should use DetailFieldFilter instead of DetailFilter: http://developer.ubuntu.com/api/qml/sdk-14.04/QtOrganizer.DetailFieldFilter/

Revision history for this message
ybon (yohanboniface) wrote :

Thanks for the inputs, Michael. But no more luck until now :(

For the record, with the first suggestion, same error about type read-only (http://paste.ubuntu.com/7263748/):

file:///home/ybon/Code/qml/calendar-app/testfilter.qml:10 Invalid property assignment: "type" is a read-only property

And with the DetailFieldFilter, I don't get it to return anything (not sure the types match the ones of OrganizerModel), event playing around with values, but I've no specific error.

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Any progress to report on this Yohan?

Revision history for this message
ybon (yohanboniface) wrote :

Nope.
As the documentation is wrong, we need someone aware of the secret sauce to be able to move forward :/

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

I've asked Zsombor and Renato to provide guidance here.

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

You should be able to filter events type using this this example:

    OrganizerModel {
        id: organizer

        startPeriod: new Date("2014-01-01")
        endPeriod: new Date("2014-12-31")
        manager: "eds"
        autoUpdate: true
        onItemCountChanged: console.debug("Item count changed: " + itemCount)
        filter: DetailFieldFilter {
            id: todoFilter
            detail: Detail.ItemType
            field: Type.FieldType
            value: Type.Todo
            matchFlags: Filter.MatchExactly
        }
        Component.onCompleted: console.debug("Type: " + Type.Todo)

    }

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

You do not need this:

47 + Component.onCompleted: {
48 + mainModel.addModelChangeListener(buildList);
49 + }
50 +
51 + function buildList () {
52 + eventModel.clear();
53 + // Include all events from 00:00 so you can still consult the past events of the day
54 + // (or just you are late 10 minutes to your RDV, and you need details from the event...)
55 + var itemIds = mainModel.getItems();
56 + for(var i = 0 ; i < itemIds.length ; ++i) {
57 + var event = itemIds[(i)];
58 + if( event ) {
59 + // Recreating new ListItem model, because
60 + // 1. I'm not able to take control on section.property formating in ListView
61 + // 2. section in deledate has been cast to string (even if property was a QDateTime
62 + // 3. no way to cheat like adding on the fly a method or property to the ListItem while looping
63 + eventModel.append({
64 + sectionLabel: event.startDateTime.formatDate(),
65 + event: event
66 + });
67 + }
68 + }
69 + }
70 +
71 + ListModel {
72 + id: eventModel
73 + }

60 + // 1. I'm not able to take control on section.property formating in ListView
61 + // 2. section in deledate has been cast to string (even if property was a QDateTime
62 + // 3. no way to cheat like adding on the fly a method or property to the ListItem while looping
Why do you need cheat the section property? If the section was cast to string you can use the string to convert back to a QDateTime object using the "section" property no?

Revision history for this message
ybon (yohanboniface) wrote :

Thanks all!

> Why do you need cheat the section property? If the section was cast to string you can use the string to convert back
> to a QDateTime object using the "section" property no?

Because items are grouped by section *before* I can do anything on the value, so if I keep passing the raw Date value (including hours, minutes..), then every item event will ends in its own section, which is not what we want.

I'm gonna test our example code and give feedback asap.

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Renato / Yohan - will you both be around for the calendar meeting tomorrow at 13:00 UTC so we can increase the velocity of this merge?

Revision history for this message
ybon (yohanboniface) wrote :

Sounds possible for me, so I will be there :)

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

You can make this simpler:

51 + function buildList () {
52 + eventModel.clear();
53 + // Include all events from 00:00 so you can still consult the past events of the day
54 + // (or just you are late 10 minutes to your RDV, and you need details from the event...)
55 + var itemIds = mainModel.getItems();
56 + for(var i = 0 ; i < itemIds.length ; ++i) {
57 + var event = itemIds[(i)];
58 + if( event ) {
59 + // Recreating new ListItem model, because
60 + // 1. I'm not able to take control on section.property formating in ListView
61 + // 2. section in deledate has been cast to string (even if property was a QDateTime
62 + // 3. no way to cheat like adding on the fly a method or property to the ListItem while looping
63 + eventModel.append({
64 + sectionLabel: event.startDateTime.formatDate(),
65 + event: event
66 + });
67 + }
68 + }
69 + }

function buildList () {
        eventModel.clear();
        // Include all events from 00:00 so you can still consult the past events of the day
        // (or just you are late 10 minutes to your RDV, and you need details from the event...)
        var items = mainModel.items
        for(var i = 0 ; i < itemIds.length ; ++i) {
            var event = items[i]
                    // Recreating new ListItem model, because
                    // 1. I'm not able to take control on section.property formating in ListView
                    // 2. section in deledate has been cast to string (even if property was a QDateTime
                    // 3. no way to cheat like adding on the fly a method or property to the ListItem while looping
                    eventModel.append({
                        sectionLabel: event.startDateTime.formatDate(),
                        event: event
                    });
               }
            }
        }

210. By ybon

Simpler buildList, thanks to Renato

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
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

This is looking great, thanks Yohan & Renato.

https://imgur.com/HSdgtad

I'm keen to see this landed, it's very useful. Kunal, can you please review?

Revision history for this message
ybon (yohanboniface) wrote :

Great news!
(6:30 Gym, seriously? ;) )

Revision history for this message
Victor Thompson (vthompson) wrote :

I'll test this out right now. I'm looking at the translation string of each of the MPs in the queue and one thing I just noticed is that the empty state for the agenda view is "No incoming event", should this be "No upcoming event"?

Revision history for this message
Victor Thompson (vthompson) wrote :

I still see alarms in the Agenda View: http://i.imgur.com/8c1Z6SE.png

Maybe the issue with alarms in the agenda view can be fixed later?

One thing I want to know is did we consider placing the agenda view in the toolbar? It doesn't fit the same flat pattern of Year/Month/Week/Day, so with the current UI it seems to make more sense in the toolbar. Also, once the app moves to using the app drawer and toolbar icons are placed in the header, having both "Agenda" and "New Event" in the header would be nice.

review: Needs Information
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

My inclination is to say that "day/week/month/year and agenda" should all go in the header, with agenda the default if you have items in your calendar.

I would see "New event" being a button on the right end of the header/toolbar, and a quick action launched via a quick swipe up from the bottom.

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

101 + pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event": model.event});

we need to pass model as well now,

like

pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":modelData,"model": root.model});

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

Agenda tab needs to follow loader architecture like other tab,

something like below,

            Tab {
                id: agendaTab
                objectName: "agendaTab"
                title: i18n.tr("Agenda")
                page: Loader{
                    id: agendaViewLoader
                    objectName: "agendaViewLoader"
                    source: tabs.selectedTab == agendaTab ? Qt.resolvedUrl("AgendaView.qml"):""
                    onLoaded: {
                        item.tools = Qt.binding(function() { return commonToolBar })
                    }

                    anchors{
                        left: parent.left
                        right: parent.right
                        bottom: parent.bottom
                    }
                }
            }

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

148 + var format = qsTr("hh:mm");
149 + return Qt.formatTime(this, format);

This still needs to be changed to use i18n.tr, as suggested in my previous review comment.

review: Needs Fixing
211. By ybon

Pass model to pageStack.push()

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 :

Rejecting this branch , as new branch has been merged to the trunk.
https://code.launchpad.net/~pkunal-parmar/ubuntu-calendar-app/AgedaView

review: Disapprove

Unmerged revisions

211. By ybon

Pass model to pageStack.push()

210. By ybon

Simpler buildList, thanks to Renato

209. By ybon

merge

208. By ybon

Merge with trunk

207. By ybon

Pick only next month events in AgendaView

206. By ybon

Use an Item for AgendaView for now

205. By ybon

No need to width/height when using anchors.fill

204. By ybon

Replace Item by Page

203. By ybon

Use QtObject instead of item property

202. By ybon

Merged from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'AgendaView.qml'
2--- AgendaView.qml 1970-01-01 00:00:00 +0000
3+++ AgendaView.qml 2014-05-21 09:10:19 +0000
4@@ -0,0 +1,107 @@
5+import QtQuick 2.0
6+import Ubuntu.Components 0.1
7+import Ubuntu.Components.ListItems 0.1 as ListItem
8+
9+import "dateExt.js" as DateExt
10+
11+Item {
12+ id: root
13+ objectName: "AgendaView"
14+
15+ property var startDay: DateExt.today();
16+
17+ EventListModel {
18+ id: mainModel
19+ startPeriod: startDay.midnight()
20+ endPeriod: startPeriod.addDays(30).endOfDay()
21+ }
22+
23+ Label {
24+ id: noEvent
25+ objectName: "noEvent"
26+
27+ width: parent.width-units.gu(6)
28+ visible: eventModel.count === 0
29+ anchors.centerIn: parent
30+
31+ fontSize: "medium"
32+ wrapMode: Text.WordWrap
33+ horizontalAlignment: Text.AlignHCenter
34+
35+ text: i18n.tr("No incoming event")
36+ }
37+
38+ Column {
39+ id: column
40+ anchors.top: parent.top
41+ anchors.topMargin: units.gu(1.5)
42+ spacing: units.gu(1)
43+
44+ anchors.fill: parent
45+
46+
47+ Component.onCompleted: {
48+ mainModel.addModelChangeListener(buildList);
49+ }
50+
51+ function buildList () {
52+ eventModel.clear();
53+ // Include all events from 00:00 so you can still consult the past events of the day
54+ // (or just you are late 10 minutes to your RDV, and you need details from the event...)
55+ var items = mainModel.items;
56+ for(var i = 0 ; i < items.length ; ++i) {
57+ var event = items[i];
58+ // Recreating new ListItem model, because
59+ // 1. I'm not able to take control on section.property formating in ListView
60+ // 2. section in deledate has been cast to string (even if property was a QDateTime
61+ // 3. no way to cheat like adding on the fly a method or property to the ListItem while looping
62+ eventModel.append({
63+ sectionLabel: event.startDateTime.formatDate(),
64+ event: event
65+ });
66+ }
67+ }
68+
69+ ListModel {
70+ id: eventModel
71+ }
72+
73+ Component {
74+ id: dateHeading
75+ ListItem.Header {
76+ text: section
77+ }
78+ }
79+
80+ ListView {
81+ id: eventList
82+ model: eventModel
83+
84+ width: parent.width
85+ height: parent.height
86+ anchors { left: parent.left; right: parent.right}
87+ clip: true
88+
89+ section {
90+ property: "sectionLabel"
91+ criteria: ViewSection.FullString
92+ labelPositioning: ViewSection.InlineLabels
93+ delegate: dateHeading
94+ }
95+
96+ delegate: ListItem.Standard {
97+ id: eventItem
98+ text: event.startDateTime.formatTime() + " - " + event.displayLabel
99+ progression: true
100+ onClicked: {
101+ pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event": model.event, "model": model});
102+ }
103+
104+ }
105+ Scrollbar {
106+ flickableItem: eventList
107+ }
108+ }
109+
110+ }
111+}
112
113=== modified file 'calendar.qml'
114--- calendar.qml 2014-04-27 05:12:51 +0000
115+++ calendar.qml 2014-05-21 09:10:19 +0000
116@@ -363,6 +363,20 @@
117 }
118 }
119 }
120+
121+ Tab {
122+ objectName: "agendaTab"
123+ title: i18n.tr("Agenda")
124+ page: Page {
125+ anchors.fill: parent
126+ tools: commonToolBar
127+ AgendaView {
128+ id: agendaView
129+ anchors.fill: parent
130+ }
131+ }
132+ }
133+
134 }
135 }
136 }
137
138=== modified file 'dateExt.js'
139--- dateExt.js 2014-03-22 03:07:26 +0000
140+++ dateExt.js 2014-05-21 09:10:19 +0000
141@@ -90,6 +90,20 @@
142 && this.getFullYear() === otherDay.getFullYear() );
143 }
144
145+Date.prototype.formatTime = function (d) {
146+ // TRANSLATORS: this is a time formatting string,
147+ // see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
148+ var format = qsTr("hh:mm");
149+ return Qt.formatTime(this, format);
150+}
151+
152+Date.prototype.formatDate = function () {
153+ // TRANSLATORS: this is a date formatting string,
154+ // see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
155+ var format = qsTr("dd MMMM yyyy");
156+ return Qt.formatDate(this, format);
157+}
158+
159 function weekCount(year, month_number) {
160 var firstOfMonth = new Date(year, month_number, 1);
161 var lastOfMonth = new Date(year, month_number+1, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: