2
* Copyright (C) 2013-2014 Canonical Ltd
4
* This file is part of Ubuntu Calendar App
6
* Ubuntu Calendar App is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 3 as
8
* published by the Free Software Foundation.
10
* Ubuntu Calendar App is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
import Ubuntu.Components 1.1
20
import Ubuntu.Components.ListItems 1.0 as ListItem
21
import Ubuntu.Components.Themes.Ambiance 1.0
22
import Ubuntu.Components.Popups 1.0
23
import QtOrganizer 5.0
2
import Ubuntu.Components 0.1
3
import Ubuntu.Components.Popups 0.1
4
import Ubuntu.Components.ListItems 0.1
25
import "Defines.js" as Defines
6
import "dataService.js" as DataService
29
objectName: "eventDetails"
42
title: i18n.tr("Event Details")
14
anchors.margins: units.gu(2)
44
16
Component.onCompleted: {
50
onCurrentPageChanged:{
51
if( pageStack.currentPage === root) {
61
function updateCollection(event) {
62
var collection = model.collection( event.collectionId );
63
calendarIndicator.color = collection.color
64
eventInfo.color=collection.color
65
// TRANSLATORS: the first parameter refers to the name of event calendar.
66
calendarName.text = i18n.tr("%1 Calendar").arg( collection.name)
69
function updateRecurrence( event ) {
71
if (event.recurrence) {
72
if(event.recurrence.recurrenceRules[0] !== undefined){
73
var rule = event.recurrence.recurrenceRules[0];
74
repeatLabel.text = eventUtils.getRecurrenceString(rule)
79
function updateContacts(event) {
80
var attendees = event.attendees;
17
if( pageStack.header )
18
pageStack.header.visible = false;
22
Component.onDestruction: {
23
if( pageStack.header )
24
pageStack.header.visible = true;
27
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)
81
55
contactModel.clear();
82
if( attendees !== undefined ) {
83
for (var j = 0 ; j < attendees.length ; ++j) {
84
contactModel.append( {"name": attendees[j].name,"participationStatus": attendees[j].participationStatus } );
89
function updateReminder(event) {
90
var reminder = event.detail( Detail.VisualReminder)
92
for(var i=0; i<reminderModel.count; i++) {
93
if(reminder.secondsBeforeStart === reminderModel.get(i).value) {
94
reminderHeader.subText = reminderModel.get(i).label
98
reminderHeader.subText = reminderModel.get(0).label
102
function updateLocation(event) {
103
if( event.location ) {
104
locationLabel.text = event.location
108
function showEvent(e) {
109
var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
110
var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
113
if( !e.startDateTime.isSameDay( e.endDateTime) ) {
114
dateLabel.text = i18n.tr("%1 - %2 (All Day)")
115
.arg( e.startDateTime.toLocaleDateString(Qt.locale(), Locale.LongFormat))
116
.arg( e.endDateTime.toLocaleDateString(Qt.locale(), Locale.LongFormat))
118
dateLabel.text = i18n.tr("%1 (All Day)").arg( e.startDateTime.toLocaleDateString(Qt.locale(), Locale.LongFormat))
121
dateLabel.text = e.startDateTime.toLocaleDateString(Qt.locale(), Locale.LongFormat) + ", " +startTime + " - " + endTime;
124
if( e.itemType === Type.EventOccurrence ){
126
model.onItemsFetched.connect( function(id,fetchedItems){
127
if(requestId === id && fetchedItems.length > 0) {
128
internal.parentEvent = fetchedItems[0];
129
updateRecurrence(internal.parentEvent);
130
updateContacts(internal.parentEvent);
133
requestId = model.fetchItems([e.parentId]);
135
// This is the event title
136
if( e.displayLabel) {
137
titleLabel.text = e.displayLabel;
140
if( e.description ) {
141
descLabel.text = e.description;
155
Keys.onEscapePressed: {
160
if ((event.key === Qt.Key_E) && ( event.modifiers & Qt.ControlModifier)) {
161
pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event": root.event});
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 {
167
text: i18n.tr("Delete");
69
text: i18n.tr("Add invite");
171
var dialog = PopupUtils.open(Qt.resolvedUrl("DeleteConfirmationDialog.qml"),root,{"event": event});
172
dialog.deleteEvent.connect( function(eventId){
173
model.removeItem(eventId);
71
print(text + " not implemented");
180
75
text: i18n.tr("Edit");
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});
206
property var parentEvent;
216
flickableItem: flicable
217
align: Qt.AlignTrailing
225
interactive: contentHeight > height
227
contentWidth: parent.width
228
contentHeight: column.height + eventInfo.height + units.gu(3) /*top margin + spacing */
77
print(text + " not implemented");
90
height: timeLabel.height
93
anchors.left: parent.left
94
anchors.verticalCenter: parent.verticalCenter
99
anchors.right: parent.right
100
anchors.verticalCenter: parent.verticalCenter
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
234
height: eventInfoList.height + units.gu(5)
134
wrapMode: Text.WordWrap
240
141
left: parent.left
246
spacing: units.gu(0.5)
250
objectName: "titleLabel"
253
wrapMode: Text.WordWrap
259
objectName: "dateLabel"
263
wrapMode: Text.WordWrap
268
objectName: "repeatLabel"
272
wrapMode: Text.WordWrap
273
visible: repeatLabel.text !== ""
278
objectName: "locationLabel"
282
wrapMode: Text.WordWrap
283
visible: locationLabel.text !== ""
293
top: eventInfo.bottom
303
id: calendarIndicator
306
anchors.verticalCenter: parent.verticalCenter
310
objectName: "calendarName"
311
anchors.verticalCenter: parent.verticalCenter
317
objectName: "descriptionLabel"
320
wrapMode: Text.WordWrap
327
margins: units.gu(-2)
331
text: i18n.tr("Guests")
332
visible: contactModel.count !== 0
335
//Guest Entery Model starts
338
objectName: 'contactList'
351
delegate: ListItem.Standard {
354
objectName: "eventGuest%1".arg(index)
355
color: UbuntuColors.midAubergine
358
leftMargin: units.gu(2)
359
verticalCenter: parent.verticalCenter
365
checked: participationStatus
374
text: i18n.tr("Reminder")
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")