~timo-jyrinki/ubuntu-calendar-app/use_pickerpanelworkaround_lp1351024

« back to all changes in this revision

Viewing changes to EventDetails.qml

  • Committer: Kunal Parmar
  • Date: 2014-05-19 08:54:41 UTC
  • mfrom: (274 ubuntu-calendar-app)
  • mto: This revision was merged to the branch mainline in revision 354.
  • Revision ID: pkunal.parmar@gmail.com-20140519085441-rw80fn7schao4tqi
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
    property var model;
17
17
 
18
18
    anchors.fill: parent
 
19
    flickable: null
 
20
 
19
21
    Component.onCompleted: {
20
22
        if( pageStack.header )
21
23
            pageStack.header.visible = false;
26
28
        if( pageStack.header )
27
29
            pageStack.header.visible = true;
28
30
    }
 
31
 
29
32
    Connections{
30
33
        target: pageStack
31
34
        onCurrentPageChanged:{
35
38
            }
36
39
        }
37
40
    }
38
 
    function showEvent(e) {
39
 
        // TRANSLATORS: this is a time formatting string,
40
 
        // see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
41
 
        var timeFormat = i18n.tr("hh:mm");
42
 
        var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
43
 
        var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
44
 
 
45
 
        startHeader.value = startTime;
46
 
        endHeader.value = endTime;
47
 
 
48
 
        allDayEventCheckbox.checked = e.allDay;
49
 
 
50
 
        // This is the event title
51
 
        if( e.displayLabel) {
52
 
            titleLabel.text = e.displayLabel;
53
 
        }
54
 
 
55
 
        if( e.description ) {
56
 
            descLabel.text = e.description;
57
 
        }
58
 
        var attendees = e.attendees;
 
41
 
 
42
    function updateRecurrence( event ) {
 
43
        var index = 0;
 
44
        if(event.recurrence ) {
 
45
            var recurrenceRule = event.recurrence.recurrenceRules;
 
46
            if(recurrenceRule.length > 0){
 
47
                index =  recurrenceRule[0].frequency ;
 
48
            }
 
49
            else{
 
50
                index = 0
 
51
            }
 
52
        }
 
53
        recurrentHeader.value = Defines.recurrenceLabel[index];
 
54
    }
 
55
 
 
56
    function updateContacts(event) {
 
57
        var attendees = event.attendees;
59
58
        contactModel.clear();
60
59
        if( attendees !== undefined ) {
61
60
            for( var j = 0 ; j < attendees.length ; ++j ) {
62
61
                contactModel.append( {"name": attendees[j].name,"participationStatus": attendees[j].participationStatus }  );
63
62
            }
64
63
        }
 
64
    }
65
65
 
 
66
    function updateReminder(event) {
66
67
        var index = 0;
67
 
        if(e.recurrence ) {
68
 
            var recurrenceRule = e.recurrence.recurrenceRules;
69
 
            index = ( recurrenceRule.length > 0 ) ? recurrenceRule[0].frequency : 0;
70
 
        }
71
 
        recurrentHeader.value = Defines.recurrenceLabel[index];
72
 
 
73
 
        index = 0;
74
 
        var reminder = e.detail( Detail.VisualReminder);
 
68
        var reminder = event.detail( Detail.VisualReminder);
75
69
        if( reminder ) {
76
70
            var reminderTime = reminder.secondsBeforeStart;
77
71
            var foundIndex = Defines.reminderValue.indexOf(reminderTime);
78
72
            index = foundIndex != -1 ? foundIndex : 0;
79
73
        }
80
74
        reminderHeader.value = Defines.reminderLabel[index];
81
 
 
82
 
        var collection = model.collection( e.collectionId );
83
 
        calendarIndicator.color = collection.color
84
 
        calendarName.text = collection.name
85
 
 
86
 
        if( e.location ) {
87
 
            locationLabel.text = e.location;
 
75
    }
 
76
 
 
77
    function updateLocation(event) {
 
78
        if( event.location ) {
 
79
            locationLabel.text = event.location;
88
80
 
89
81
            // FIXME: need to cache map image to avoid duplicate download every time
90
 
            var imageSrc = "http://maps.googleapis.com/maps/api/staticmap?center="+e.location+
91
 
                    "&markers=color:red|"+e.location+"&zoom=15&size="+mapContainer.width+
 
82
            var imageSrc = "http://maps.googleapis.com/maps/api/staticmap?center="+event.location+
 
83
                    "&markers=color:red|"+event.location+"&zoom=15&size="+mapContainer.width+
92
84
                    "x"+mapContainer.height+"&sensor=false";
93
85
            mapImage.source = imageSrc;
94
86
        }
99
91
        }
100
92
    }
101
93
 
 
94
    function updateCollection(event) {
 
95
        var collection = model.collection( e.collectionId );
 
96
        calendarIndicator.color = collection.color
 
97
        calendarName.text = collection.name
 
98
    }
 
99
 
 
100
    function showEvent(e) {
 
101
        // TRANSLATORS: this is a time formatting string,
 
102
        // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions
 
103
        var timeFormat = i18n.tr("hh:mm");
 
104
        // TRANSLATORS: this is a time & Date formatting string,
 
105
        //see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details
 
106
        var dateFormat = i18n.tr("dd-MMM-yyyy")
 
107
        eventDate.value = e.startDateTime.toLocaleString(Qt.locale(),dateFormat);
 
108
        var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
 
109
        var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
 
110
 
 
111
        if( e.itemType === Type.EventOccurrence ){
 
112
            var requestId = -1;
 
113
            model.onItemsFetched.connect( function(id,fetchedItems){
 
114
                if(requestId === id && fetchedItems.length > 0) {
 
115
                    internal.parentEvent = fetchedItems[0];
 
116
                    updateRecurrence(internal.parentEvent);
 
117
                    updateContacts(internal.parentEvent);
 
118
                }
 
119
            });
 
120
            requestId = model.fetchItems([e.parentId]);
 
121
        }
 
122
 
 
123
        startHeader.value = startTime;
 
124
        endHeader.value = endTime;
 
125
 
 
126
        allDayEventCheckbox.checked = e.allDay;
 
127
 
 
128
        // This is the event title
 
129
        if( e.displayLabel) {
 
130
            titleLabel.text = e.displayLabel;
 
131
        }
 
132
 
 
133
        if( e.description ) {
 
134
            descLabel.text = e.description;
 
135
        }
 
136
 
 
137
        updateCollection(e);
 
138
 
 
139
        updateContacts(e);
 
140
 
 
141
        updateRecurrence(e);
 
142
 
 
143
        updateReminder(e);
 
144
 
 
145
        updateLocation(e);
 
146
    }
 
147
 
102
148
    Keys.onEscapePressed: {
103
149
        pageStack.pop();
104
150
    }
129
175
                text: i18n.tr("Edit");
130
176
                iconSource: Qt.resolvedUrl("edit.svg");
131
177
                onTriggered: {
132
 
                   pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event,"model":model});
 
178
                    if( event.itemType === Type.EventOccurrence ) {
 
179
                        var dialog = PopupUtils.open(Qt.resolvedUrl("EditEventConfirmationDialog.qml"),root,{"event": event});
 
180
                        dialog.editEvent.connect( function(eventId){
 
181
                            if( eventId === event.parentId ) {
 
182
                                pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":internal.parentEvent,"model":model});
 
183
                            } else {
 
184
                                pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event,"model":model});
 
185
                            }
 
186
                        });
 
187
                    } else {
 
188
                        pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event,"model":model});
 
189
                    }
133
190
                }
134
191
            }
135
192
        }
136
193
    }
137
194
 
 
195
    QtObject{
 
196
        id: internal
 
197
        property var parentEvent;
 
198
    }
 
199
 
138
200
    Rectangle {
139
 
        id:eventDetilsView
140
 
        anchors.fill: parent
 
201
        id: bg
141
202
        color: "white"
 
203
        anchors.fill: parent
 
204
    }
 
205
 
 
206
    Scrollbar {
 
207
        flickableItem: flicable
 
208
        align: Qt.AlignTrailing
 
209
    }
 
210
 
 
211
    Flickable{
 
212
        id: flicable
 
213
        anchors.fill: parent
 
214
 
 
215
        contentHeight: column.height + units.gu(3) /*top margin + spacing */
 
216
        contentWidth: parent.width
 
217
 
 
218
        interactive: contentHeight > height
 
219
 
142
220
        Column{
143
221
            id: column
144
 
            anchors.fill: parent
145
 
            width: parent.width
146
222
            spacing: units.gu(1)
147
223
            anchors{
148
224
                top:parent.top
152
228
                left:parent.left
153
229
                leftMargin: units.gu(2)
154
230
            }
155
 
            property int timeLabelMaxLen: Math.max( startHeader.headerWidth, endHeader.headerWidth)// Dynamic Width
 
231
            property int timeLabelMaxLen: Math.max( startHeader.headerWidth, endHeader.headerWidth,eventDate.headerWidth)// Dynamic Width
 
232
            EventDetailsInfo{
 
233
                id: eventDate
 
234
                xMargin:column.timeLabelMaxLen
 
235
                header: i18n.tr("Date")
 
236
            }
156
237
            EventDetailsInfo{
157
238
                id: startHeader
158
239
                xMargin:column.timeLabelMaxLen
278
359
                id: recurrentHeader
279
360
                xMargin: column.recurranceAreaMaxWidth
280
361
                header: i18n.tr("This happens")
281
 
                value :"Only once" //Neds to change
282
362
            }
283
363
            EventDetailsInfo{
284
364
                id: reminderHeader