Code review comment for lp:~yohanboniface/ubuntu-calendar-app/AgendaView

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
                    });
               }
            }
        }

« Back to merge proposal