2
2
import Ubuntu.Components 0.1
3
3
import Ubuntu.Components.Popups 0.1
4
4
import Ubuntu.Components.ListItems 0.1
5
import Ubuntu.Components.Themes.Ambiance 0.1
6
import "dataService.js" as DataService
8
import "Defines.js" as Defines
11
13
property var event;
14
anchors.margins: units.gu(2)
14
property string headerColor :"black"
15
property string detailColor :"grey"
26
title: "Event Details"
16
28
Component.onCompleted: {
17
if( pageStack.header )
18
pageStack.header.visible = false;
22
Component.onDestruction: {
23
if( pageStack.header )
24
pageStack.header.visible = true;
34
onCurrentPageChanged:{
35
if( pageStack.currentPage === root) {
41
function updateRecurrence( event ) {
43
if(event.recurrence ) {
44
var recurrenceRule = event.recurrence.recurrenceRules;
45
if(recurrenceRule.length > 0){
46
if(recurrenceRule[0].limit === undefined)
47
limitHeader.value = i18n.tr("Never");
49
// TRANSLATORS: this is a time & Date formatting string,
50
//see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details
51
var dateFormat = i18n.tr("dd-MMM-yyyy")
52
limitHeader.value = parseInt(recurrenceRule[0].limit) ?
53
i18n.tr("After %1 Occurrences").arg(recurrenceRule[0].limit):
54
i18n.tr("After Date %1").arg(recurrenceRule[0].limit.toLocaleString(Qt.locale(),dateFormat));
57
index = recurrenceRule[0].frequency ;
60
limitHeader.visible = false
64
recurrentHeader.value = Defines.recurrenceLabel[index];
67
function updateContacts(event) {
68
var attendees = event.attendees;
70
if( attendees !== undefined ) {
71
for( var j = 0 ; j < attendees.length ; ++j ) {
72
contactModel.append( {"name": attendees[j].name,"participationStatus": attendees[j].participationStatus } );
77
function updateReminder(event) {
79
var reminder = event.detail( Detail.VisualReminder);
81
var reminderTime = reminder.secondsBeforeStart;
82
var foundIndex = Defines.reminderValue.indexOf(reminderTime);
83
index = foundIndex != -1 ? foundIndex : 0;
85
reminderHeader.value = Defines.reminderLabel[index];
88
function updateLocation(event) {
89
if( event.location ) {
90
locationLabel.text = event.location;
92
// FIXME: need to cache map image to avoid duplicate download every time
93
var imageSrc = "http://maps.googleapis.com/maps/api/staticmap?center="+event.location+
94
"&markers=color:red|"+event.location+"&zoom=15&size="+mapContainer.width+
95
"x"+mapContainer.height+"&sensor=false";
96
mapImage.source = imageSrc;
99
// TODO: use different color for empty text
100
locationLabel.text = i18n.tr("Not specified")
101
mapImage.source = "";
27
105
function showEvent(e) {
29
// FIXME: temp location in case there is no vanue is defined
30
var location="-15.800513,-47.91378";
31
//var location ="Terry' Cafe, 158 Great Suffold St, London, SE1 1PE";
33
timeLabel.text = Qt.formatDateTime(e.startTime,"hh:mm") + " - " + Qt.formatDateTime(e.endTime,"hh:mm");
34
dateLabel.text = Qt.formatDateTime(e.startTime,"ddd, d MMMM");
35
titleLabel.text = e.title;
37
locationLabel.text = location;
39
descLabel.text = e.message;
43
DataService.getVenues(e, venues)
44
if( venues.length > 0 ) {
45
//FIXME: what to do for multiple venue
46
var place = venues[0];
47
locationLabel.text = place.address;
48
if( place.latitude && place.longitude) {
49
location = place.latitude +"," + place.longitude;
54
DataService.getAttendees(e, attendees)
56
for( var j = 0 ; j < attendees.length ; ++j ) {
57
contactModel.append( {"name": attendees[j] } );
60
// FIXME: need to cache map image to avoid duplicate download every time
61
var imageSrc = "http://maps.googleapis.com/maps/api/staticmap?center="+location+
62
"&markers=color:blue|"+location+"&zoom=15&size="+mapContainer.width+
63
"x"+mapContainer.height+"&sensor=false";
64
mapImage.source=imageSrc;
67
tools: ToolbarActions {
69
text: i18n.tr("Add invite");
71
print(text + " not implemented");
75
text: i18n.tr("Edit");
77
print(text + " not implemented");
106
// TRANSLATORS: this is a time formatting string,
107
// see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions
108
var timeFormat = i18n.tr("hh:mm");
109
// TRANSLATORS: this is a time & Date formatting string,
110
//see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details
111
var dateFormat = i18n.tr("dd-MMM-yyyy")
112
eventDate.value = e.startDateTime.toLocaleString(Qt.locale(),dateFormat);
113
var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
114
var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
116
if( e.itemType === Type.EventOccurrence ){
118
model.onItemsFetched.connect( function(id,fetchedItems){
119
if(requestId === id && fetchedItems.length > 0) {
120
internal.parentEvent = fetchedItems[0];
121
updateRecurrence(internal.parentEvent);
122
updateContacts(internal.parentEvent);
125
requestId = model.fetchItems([e.parentId]);
128
allDayEventCheckbox.checked = e.allDay;
130
startHeader.visible = !e.allDay;
131
endHeader.visible = !e.allDay;
133
startHeader.value = startTime;
134
endHeader.value = endTime;
136
// This is the event title
137
if( e.displayLabel) {
138
titleLabel.text = e.displayLabel;
141
if( e.description ) {
142
descLabel.text = e.description;
154
Keys.onEscapePressed: {
159
if ((event.key === Qt.Key_E) && ( event.modifiers & Qt.ControlModifier)) {
160
pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event": root.event});
164
tools: ToolbarItems {
167
text: i18n.tr("Delete");
168
iconSource: "image://theme/delete,edit-delete-symbolic"
170
var dialog = PopupUtils.open(Qt.resolvedUrl("DeleteConfirmationDialog.qml"),root,{"event": event});
171
dialog.deleteEvent.connect( function(eventId){
172
model.removeItem(eventId);
181
text: i18n.tr("Edit");
182
iconSource: Qt.resolvedUrl("edit.svg");
184
if( event.itemType === Type.EventOccurrence ) {
185
var dialog = PopupUtils.open(Qt.resolvedUrl("EditEventConfirmationDialog.qml"),root,{"event": event});
186
dialog.editEvent.connect( function(eventId){
187
if( eventId === event.parentId ) {
188
pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":internal.parentEvent,"model":model});
190
pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event,"model":model});
194
pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event,"model":model});
203
property var parentEvent;
85
209
anchors.fill: parent
90
height: timeLabel.height
213
flickableItem: flicable
214
align: Qt.AlignTrailing
220
height: parent.height
223
contentHeight: column.height + units.gu(3) /*top margin + spacing */
224
contentWidth: parent.width
226
interactive: contentHeight > height
233
topMargin: units.gu(2)
235
rightMargin: units.gu(2)
237
leftMargin: units.gu(2)
239
property int timeLabelMaxLen: Math.max( startHeader.headerWidth, endHeader.headerWidth,eventDate.headerWidth)// Dynamic Width
242
xMargin:column.timeLabelMaxLen
243
header: i18n.tr("Date")
247
xMargin:column.timeLabelMaxLen
248
header: i18n.tr("Start")
252
xMargin: column.timeLabelMaxLen
253
header: i18n.tr("End")
258
anchors.margins: units.gu(0.5)
259
visible: allDayEventCheckbox.checked
262
text: i18n.tr("All Day event:")
263
anchors.verticalCenter: allDayEventCheckbox.verticalCenter
268
id: allDayEventCheckbox
93
anchors.left: parent.left
94
anchors.verticalCenter: parent.verticalCenter
279
wrapMode: Text.WordWrap
99
anchors.right: parent.right
100
anchors.verticalCenter: parent.verticalCenter
284
wrapMode: Text.WordWrap
101
285
fontSize: "small"
109
wrapMode: Text.WordWrap
115
// FIXME: temporaty text, in ui there is no field to enter message
116
text:"Hi both, please turn up on time, it gets really busy by 1pm! Anna x"
117
wrapMode: Text.WordWrap
122
//map control with location
292
header: i18n.tr("Location")
134
298
wrapMode: Text.WordWrap
302
//map control with location
307
visible: mapImage.status == Image.Ready
317
text: i18n.tr("Guests");
135
318
fontSize: "medium"
322
//Guest Entery Model starts
136
326
width: parent.width
142
leftMargin: units.gu(1)
143
bottom: parent.bottom
144
bottomMargin: units.gu(1)
150
text: i18n.tr("People");
160
var height = parent.height;
161
//not considering the list view it self
162
for( var i = 0; i < parent.children.length - 1 ; ++i) {
163
height -= parent.children[i].height;
165
height -= parent.children.length * parent.spacing;
174
visible: contactModel.count <= 0
175
anchors.verticalCenter: parent.verticalCenter
180
icon: Qt.resolvedUrl("dummy.png")
336
checked: participationStatus
341
anchors.verticalCenter: parent.verticalCenter
350
property int recurranceAreaMaxWidth: Math.max( recurrentHeader.headerWidth, reminderHeader.headerWidth,limitHeader.headerWidth) //Dynamic Height
353
xMargin: column.recurranceAreaMaxWidth
354
header: i18n.tr("This happens")
358
xMargin: column.recurranceAreaMaxWidth
359
header: i18n.tr("Remind me")
363
xMargin: column.recurranceAreaMaxWidth
364
header: i18n.tr("Repetition Ends")