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

12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
1
import QtQuick 2.0
191.1.1 by Mario Guerriero
fixed bug #1270242
2
import QtOrganizer 5.0
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
3
import Ubuntu.Components 0.1
4
import Ubuntu.Components.Popups 0.1
110.1.18 by Kunal Parmar
merge from trunk
5
import Ubuntu.Components.ListItems 0.1
6
import Ubuntu.Components.Themes.Ambiance 0.1
211.2.1 by Mihir
Added limit functionality to event
7
import Ubuntu.Components.Pickers 0.1
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
8
import QtOrganizer 5.0
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
9
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
10
import "Defines.js" as Defines
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
11
110.1.18 by Kunal Parmar
merge from trunk
12
Page {
13
    id: root
334.1.2 by Leo Arias
First part of the refactor to the new event test.
14
    objectName: 'newEventPage'
308.2.1 by Mihir Soni
Resolved bug 1328203
15
    property var date;
140.1.4 by Mihir Soni
Merged to branch,added Edit support
16
17
    property var event:null;
233.1.1 by Kunal Parmar
EventView performance improvement
18
    property var model;
140.1.4 by Mihir Soni
Merged to branch,added Edit support
19
252.2.4 by Victor Thompson
Update properties
20
    property var startDate;
21
    property var endDate;
164.2.2 by Riccardo Padovani
Updated optionSelector
22
    property int optionSelectorWidth: frequencyLabel.width > remindLabel.width ? frequencyLabel.width : remindLabel.width
122.2.13 by Riccardo Padovani
Updated to last rev
23
110.1.23 by Kunal Parmar
new event test on device fix
24
    property alias scrollY: flickable.contentY
140.1.1 by Mihir Soni
Added edit functionality
25
    property bool isEdit: false
110.1.18 by Kunal Parmar
merge from trunk
26
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
27
    onStartDateChanged: {
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
28
        startDateInput.text = Qt.formatDateTime(startDate, "dd MMM yyyy");
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
29
        startTimeInput.text = Qt.formatDateTime(startDate, "hh:mm");
30
    }
31
32
    onEndDateChanged: {
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
33
        endDateInput.text = Qt.formatDateTime(endDate, "dd MMM yyyy");
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
34
        endTimeInput.text = Qt.formatDateTime(endDate, "hh:mm");
35
    }
36
124.3.5 by Kunal Parmar
EDS integration done
37
    Component.onCompleted: {
308.2.1 by Mihir Soni
Resolved bug 1328203
38
        //If current date is setted by an argument we don't have to change it.
39
        if(typeof(date) === 'undefined'){
40
            date = new Date();
41
            var newDate = new Date();
42
            date.setHours(newDate.getHours(), newDate.getMinutes());
43
        }
44
122.2.10 by Riccardo Padovani
Updated to last version
45
        // If startDate is setted by argument we have to not change it
259.1.3 by Mihir Soni
current time
46
        //Set the nearest current time.
122.2.10 by Riccardo Padovani
Updated to last version
47
        if (typeof(startDate) === 'undefined')
252.2.3 by Victor Thompson
Fix solution
48
            startDate = new Date(root.roundDate(date))
122.2.10 by Riccardo Padovani
Updated to last version
49
50
        // If endDate is setted by argument we have to not change it
51
        if (typeof(endDate) === 'undefined') {
252.2.3 by Victor Thompson
Fix solution
52
            endDate = new Date(root.roundDate(date))
53
            endDate.setMinutes(endDate.getMinutes() + 30)
308.2.1 by Mihir Soni
Resolved bug 1328203
54
            endTimeInput.text = Qt.formatDateTime(endDate, "hh:mm");
122.2.10 by Riccardo Padovani
Updated to last version
55
        }
124.3.9 by Kunal Parmar
Merged from Trunk
56
140.1.1 by Mihir Soni
Added edit functionality
57
        if(event === null){
197.1.3 by Yohan Boniface
Merge with trunk
58
            isEdit = false;
140.1.1 by Mihir Soni
Added edit functionality
59
            addEvent();
315.1.1 by Mihir Soni
focus to event Title while creating new event
60
            titleEdit.forceActiveFocus();
140.1.1 by Mihir Soni
Added edit functionality
61
        }
140.1.14 by Mihir Soni
Deleted all attendees while editing
62
        else{
140.1.4 by Mihir Soni
Merged to branch,added Edit support
63
            isEdit = true;
140.1.1 by Mihir Soni
Added edit functionality
64
            editEvent(event);
140.1.4 by Mihir Soni
Merged to branch,added Edit support
65
        }
66
    }
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
67
140.1.4 by Mihir Soni
Merged to branch,added Edit support
68
    //Data for Add events
69
    function addEvent() {
140.1.14 by Mihir Soni
Deleted all attendees while editing
70
        event = Qt.createQmlObject("import QtOrganizer 5.0; Event { }", Qt.application,"NewEvent.qml");
110.1.18 by Kunal Parmar
merge from trunk
71
    }
140.1.4 by Mihir Soni
Merged to branch,added Edit support
72
    //Editing Event
73
    function editEvent(e) {
74
        startDate =new Date(e.startDateTime);
75
        endDate = new Date(e.endDateTime);
192.2.1 by Kunal Parmar
Reminder support added
76
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
77
        if(e.displayLabel) {
140.1.4 by Mihir Soni
Merged to branch,added Edit support
78
            titleEdit.text = e.displayLabel;
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
79
        }
297.1.1 by Mihir Soni
All day edit
80
        if(e.allDay){
81
            allDayEventCheckbox.checked =true;
82
        }
264.1.1 by Kunal Parmar
Editing by eventtype
83
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
84
        if(e.location) {
140.1.4 by Mihir Soni
Merged to branch,added Edit support
85
            locationEdit.text = e.location;
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
86
        }
264.1.1 by Kunal Parmar
Editing by eventtype
87
140.1.4 by Mihir Soni
Merged to branch,added Edit support
88
        if( e.description ) {
89
            messageEdit.text = e.description;
90
        }
264.1.1 by Kunal Parmar
Editing by eventtype
91
212.4.20 by Kunal Parmar
error resolved
92
        allDayEventCheckbox.checked = e.allDay;
264.1.4 by Kunal Parmar
parentEvent moved to internal
93
        var index = 0;
212.4.24 by Kunal Parmar
merge from trunk
94
264.1.4 by Kunal Parmar
parentEvent moved to internal
95
        if( e.itemType === Type.Event ) {
264.1.1 by Kunal Parmar
Editing by eventtype
96
            if(e.attendees){
97
                for( var j = 0 ; j < e.attendees.length ; ++j ) {
98
                    personEdit.text += e.attendees[j].name;
99
                    if(j!== e.attendees.length-1)
100
                        personEdit.text += ",";
101
                }
102
            }
103
264.1.4 by Kunal Parmar
parentEvent moved to internal
104
            index = 0;
264.1.1 by Kunal Parmar
Editing by eventtype
105
            if(e.recurrence ) {
106
                var recurrenceRule = e.recurrence.recurrenceRules;
107
                index = ( recurrenceRule.length > 0 ) ? recurrenceRule[0].frequency : 0;
286.1.16 by Mihir Soni
changes as per review comments
108
                if(index > 0 )
109
                {
211.2.32 by Mihir Soni
Merge with trunk
110
                    limit.visible = true;
111
                    if(recurrenceRule[0].limit !== undefined){
112
                        var temp = recurrenceRule[0].limit;
211.2.35 by Mihir Soni
Added display of repetition ends
113
                        if(parseInt(temp)){
211.2.32 by Mihir Soni
Merge with trunk
114
                            limitOptions.selectedIndex = 1;
115
                            limitCount.text = temp;
116
                        }
117
                        else{
118
                            limitOptions.selectedIndex = 2;
119
                            datePick.date= temp;
120
                        }
211.2.4 by Mihir Soni
Edit functionality implemented.
121
                    }
122
                    else{
211.2.32 by Mihir Soni
Merge with trunk
123
                        // If limit is infinite
124
                        limitOptions.selectedIndex = 0;
211.2.4 by Mihir Soni
Edit functionality implemented.
125
                    }
286.1.19 by Mihir Soni
removed hard code values from Enum values
126
                    if(index === RecurrenceRule.Weekly){
286.1.21 by Mihir Soni
Changes as per review comments
127
                            index = getWeekDaysIndex(recurrenceRule[0].daysOfWeek.sort());
286.1.16 by Mihir Soni
changes as per review comments
128
                    }
286.1.9 by Mihir Soni
added more recurrence options
129
                    if(recurrenceRule[0].daysOfWeek.length>0 && index === 5){
286.1.1 by Mihir Soni
Added repeate week days
130
                        for(var j = 0;j<recurrenceRule[0].daysOfWeek.length;++j){
131
                            //Start childern after first element.
132
                            weeksRow.children[recurrenceRule[0].daysOfWeek[j]+1].checked = true;
133
                        }
134
                    }
211.2.2 by Mihir Soni
Added , edit support for limit
135
                }
136
            }
264.1.1 by Kunal Parmar
Editing by eventtype
137
            recurrenceOption.selectedIndex = index;
138
        }
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
139
140
        index = 0;
141
        var reminder = e.detail( Detail.VisualReminder);
142
        if( reminder ) {
143
            var reminderTime = reminder.secondsBeforeStart;
144
            var foundIndex = Defines.reminderValue.indexOf(reminderTime);
145
            index = foundIndex != -1 ? foundIndex : 0;
146
        }
147
        reminderOption.selectedIndex = index;
212.4.3 by Kunal Parmar
Refinement
148
149
        index = 0;
150
        for(var i=0; i < calendarsOption.model.length; ++i){
151
            if(calendarsOption.model[i].collectionId === e.collectionId){
152
                index = i;
153
                break;
154
            }
155
        }
156
        calendarsOption.selectedIndex = index
140.1.4 by Mihir Soni
Merged to branch,added Edit support
157
    }
286.1.21 by Mihir Soni
Changes as per review comments
158
    function getWeekDaysIndex(daysOfWeek){
159
        var index = 0;
160
        if(compareArrays(daysOfWeek,[Qt.Monday,Qt.Tuesday,Qt.Wednesday,Qt.Thursday,Qt.Friday]))
161
            index = 2
162
        else if(compareArrays(daysOfWeek,[Qt.Monday,Qt.Wednesday,Qt.Friday]))
163
            index = 3
164
        else if(compareArrays(daysOfWeek,[Qt.Tuesday,Qt.Thursday]))
165
            index = 4
166
        else
167
            index = 5
168
        return index;
169
    }
170
286.1.9 by Mihir Soni
added more recurrence options
171
    function compareArrays(daysOfWeek, actualArray){
172
        if (daysOfWeek.length !== actualArray.length) return false;
173
        for (var i = 0; i < actualArray.length; i++) {
174
            if (daysOfWeek[i] !== actualArray[i]) return false;
175
        }
176
        return true;
177
    }
140.1.4 by Mihir Soni
Merged to branch,added Edit support
178
    //Save the new or Existing event
124.3.9 by Kunal Parmar
Merged from Trunk
179
    function saveToQtPim() {
286.1.22 by Mihir Soni
resolved typo
180
        internal.clearFocus()
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
181
        if ( startDate >= endDate && !allDayEventCheckbox.checked) {
124.3.10 by Kunal Parmar
error dialog integrated
182
            PopupUtils.open(errorDlgComponent,root,{"text":i18n.tr("End time can't be before start time")});
124.3.9 by Kunal Parmar
Merged from Trunk
183
        } else {
184
            event.startDateTime = startDate;
185
            event.endDateTime = endDate;
186
            event.displayLabel = titleEdit.text;
140.1.9 by Mihir Soni
removed static text
187
            event.description = messageEdit.text;
124.3.9 by Kunal Parmar
Merged from Trunk
188
            event.location = locationEdit.text
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
189
191.4.1 by Kunal Parmar
Applying changes
190
            event.allDay = allDayEventCheckbox.checked;
191
211.2.35 by Mihir Soni
Added display of repetition ends
192
193
            if( event.itemType === Type.Event ) {
194
                event.attendees = []; // if Edit remove all attendes & add them again if any
195
                if( personEdit.text != "") {
196
                    var attendee = Qt.createQmlObject("import QtOrganizer 5.0; EventAttendee{}", event, "NewEvent.qml");
197
                    attendee.name = personEdit.text;
198
                    event.setDetail(attendee);
199
                }
200
286.1.20 by Mihir Soni
Removed typos
201
                var recurrenceRule = Defines.recurrenceValue[ recurrenceOption.selectedIndex ];
211.2.35 by Mihir Soni
Added display of repetition ends
202
                var rule = Qt.createQmlObject("import QtOrganizer 5.0; RecurrenceRule {}", event.recurrence,"NewEvent.qml");
203
                if( recurrenceRule !== RecurrenceRule.Invalid ) {
204
                    rule.frequency = recurrenceRule;
286.1.18 by Mihir Soni
moved daysOfWeek into function
205
                    rule.daysOfWeek = getDaysOfWeek();
211.2.35 by Mihir Soni
Added display of repetition ends
206
                    if(limitOptions.selectedIndex === 1 && recurrenceOption.selectedIndex > 0){
207
                        rule.limit =  parseInt(limitCount.text);
208
                    }
209
                    else if(limitOptions.selectedIndex === 2 && recurrenceOption.selectedIndex > 0){
210
                        rule.limit =  datePick.date;
211
                    }
212
                    else{
213
                        rule.limit = undefined;
214
                    }
215
                }
286.1.19 by Mihir Soni
removed hard code values from Enum values
216
                event.recurrence.recurrenceRules = [rule];
211.2.35 by Mihir Soni
Added display of repetition ends
217
            }
286.1.19 by Mihir Soni
removed hard code values from Enum values
218
211.2.35 by Mihir Soni
Added display of repetition ends
219
            //remove old reminder value
220
            var oldVisualReminder = event.detail(Detail.VisualReminder);
221
            if(oldVisualReminder) {
222
                event.removeDetail(oldVisualReminder);
223
            }
224
225
            var oldAudibleReminder = event.detail(Detail.AudibleReminder);
226
            if(oldAudibleReminder) {
227
                event.removeDetail(oldAudibleReminder);
228
            }
229
230
            var reminderTime = Defines.reminderValue[ reminderOption.selectedIndex ];
231
            if( reminderTime !== 0 ) {
232
                var visualReminder =  Qt.createQmlObject("import QtOrganizer 5.0; VisualReminder{}", event, "NewEvent.qml");
233
                visualReminder.repetitionCount = 3;
234
                visualReminder.repetitionDelay = 120;
235
                visualReminder.message = titleEdit.text
236
                visualReminder.secondsBeforeStart = reminderTime;
237
                event.setDetail(visualReminder);
238
239
                var audibleReminder =  Qt.createQmlObject("import QtOrganizer 5.0; AudibleReminder{}", event, "NewEvent.qml");
240
                audibleReminder.repetitionCount = 3;
241
                audibleReminder.repetitionDelay = 120;
242
                audibleReminder.secondsBeforeStart = reminderTime;
243
                event.setDetail(audibleReminder);
244
            }
245
212.4.3 by Kunal Parmar
Refinement
246
            event.collectionId = calendarsOption.model[calendarsOption.selectedIndex].collectionId;
212.4.35 by Kunal Parmar
merge from trunk
247
211.2.35 by Mihir Soni
Added display of repetition ends
248
            model.saveItem(event);
212.4.3 by Kunal Parmar
Refinement
249
211.2.35 by Mihir Soni
Added display of repetition ends
250
            pageStack.pop();
140.1.1 by Mihir Soni
Added edit functionality
251
        }
124.3.9 by Kunal Parmar
Merged from Trunk
252
    }
253
286.1.18 by Mihir Soni
moved daysOfWeek into function
254
    function getDaysOfWeek(){
255
        var daysOfWeek = [];
256
        switch(recurrenceOption.selectedIndex){
257
        case 2:
258
            daysOfWeek = [Qt.Monday,Qt.Tuesday,Qt.Wednesday,Qt.Thursday,Qt.Friday];
259
            break;
260
        case 3:
261
            daysOfWeek = [Qt.Monday,Qt.Wednesday,Qt.Friday];
262
            break;
263
        case 4:
264
            daysOfWeek = [Qt.Tuesday,Qt.Thursday];
265
            break;
266
        case 5:
286.1.21 by Mihir Soni
Changes as per review comments
267
            daysOfWeek = internal.weekDays.length === 0 ? [date.getDay()] : internal.weekDays;
286.1.18 by Mihir Soni
moved daysOfWeek into function
268
            break;
269
        }
270
        return daysOfWeek;
271
    }
124.3.9 by Kunal Parmar
Merged from Trunk
272
197.1.2 by Yohan Boniface
Highlight datetime input when datepicker is open
273
    function openDatePicker (element, caller, callerProperty, mode) {
274
        element.highlighted = true;
275
        var picker = PickerPanel.openDatePicker(caller, callerProperty, mode);
276
        if (!picker) return;
277
        picker.closed.connect(function () {
278
            element.highlighted = false;
279
        });
221.1.2 by Brian LaRochelle
Move changes from rev 222 into functions of the root of NewEvent {}
280
    }
281
252.2.1 by Victor Thompson
* Use date rounded up to nearest half hour
282
    // Calucate default hour and minute for start and end time on event
283
    function roundDate(date) {
252.2.3 by Victor Thompson
Fix solution
284
        var tempDate = new Date(date)
285
        if(tempDate.getMinutes() < 30)
286
            return tempDate.setMinutes(30)
287
        tempDate.setMinutes(0)
288
        return tempDate.setHours(tempDate.getHours() + 1)
221.1.2 by Brian LaRochelle
Move changes from rev 222 into functions of the root of NewEvent {}
289
    }
290
110.1.20 by Kunal Parmar
setting height to resolve binding error
291
    width: parent.width
292
    height: parent.height
293
140.1.4 by Mihir Soni
Merged to branch,added Edit support
294
    title: isEdit ? i18n.tr("Edit Event"):i18n.tr("New Event")
110.1.18 by Kunal Parmar
merge from trunk
295
183.1.1 by Kunal Parmar
Key Navigation implemented
296
    Keys.onEscapePressed: {
297
        pageStack.pop();
298
    }
299
253.4.1 by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page.
300
    // we use a custom toolbar in this view
110.1.18 by Kunal Parmar
merge from trunk
301
    tools: ToolbarItems {
302
        locked: true
253.4.1 by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page.
303
        opened: false
110.1.18 by Kunal Parmar
merge from trunk
304
    }
140.1.10 by Mihir Soni
Resolved issue showing error
305
306
    Component{
307
        id: errorDlgComponent
308
        Dialog {
309
            id: dialog
310
            title: i18n.tr("Error")
311
            Button {
347.1.1 by Alan Pope
Ok -> OK
312
                text: i18n.tr("OK")
140.1.10 by Mihir Soni
Resolved issue showing error
313
                onClicked: PopupUtils.close(dialog)
314
            }
315
        }
316
    }
191.4.1 by Kunal Parmar
Applying changes
317
110.1.18 by Kunal Parmar
merge from trunk
318
    Flickable{
110.1.23 by Kunal Parmar
new event test on device fix
319
        id: flickable
253.4.1 by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page.
320
321
        property var activeItem: null
322
323
        function makeMeVisible(item) {
324
            if (!item) {
325
                return
326
            }
327
328
            activeItem = item
329
            var position = flickable.contentItem.mapFromItem(item, 0, 0);
330
331
            // check if the item is already visible
332
            var bottomY = flickable.contentY + flickable.height
333
            var itemBottom = position.y + item.height
334
            if (position.y >= flickable.contentY && itemBottom <= bottomY) {
335
                return;
336
            }
337
338
            // if it is not, try to scroll and make it visible
339
            var targetY = position.y + item.height - flickable.height
340
            if (targetY >= 0 && position.y) {
341
                flickable.contentY = targetY;
342
            } else if (position.y < flickable.contentY) {
343
                // if it is hidden at the top, also show it
344
                flickable.contentY = position.y;
345
            }
346
            flickable.returnToBounds()
347
        }
348
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
349
        anchors {
110.1.18 by Kunal Parmar
merge from trunk
350
            top: parent.top
351
            topMargin: units.gu(2)
253.4.1 by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page.
352
            bottom: toolbar.top
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
353
            left: parent.left
354
            right: parent.right
110.1.18 by Kunal Parmar
merge from trunk
355
            leftMargin: units.gu(2)
356
            rightMargin: units.gu(2)
357
        }
358
359
        contentWidth: width
360
        contentHeight: column.height
361
197.1.3 by Yohan Boniface
Merge with trunk
362
        Column {
110.1.18 by Kunal Parmar
merge from trunk
363
            id: column
364
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
365
            width: parent.width
110.1.18 by Kunal Parmar
merge from trunk
366
            spacing: units.gu(1)
367
197.1.3 by Yohan Boniface
Merge with trunk
368
            UbuntuShape {
110.1.18 by Kunal Parmar
merge from trunk
369
                width:parent.width
370
                height: timeColumn.height
371
372
                Column{
373
                    id: timeColumn
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
374
                    width: parent.width
110.1.18 by Kunal Parmar
merge from trunk
375
                    anchors.centerIn: parent
376
                    spacing: units.gu(1)
377
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
378
                    Item {
191.4.1 by Kunal Parmar
Applying changes
379
                        width: parent.width
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
380
                        height: startDateInput.height
381
382
                        NewEventEntryField{
383
                            id: startDateInput
384
                            title: i18n.tr("Start")
197.1.15 by nskaggs
first working version of newevent test
385
                            objectName: "startDateInput"
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
386
387
                            text: ""
388
389
                            width: allDayEventCheckbox.checked ? parent.width : parent.width / 2
390
391
                            MouseArea{
392
                                anchors.fill: parent
393
                                onClicked: openDatePicker(startDateInput, root, "startDate", "Years|Months|Days")
394
                            }
197.1.3 by Yohan Boniface
Merge with trunk
395
                        }
396
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
397
                        NewEventEntryField{
197.1.3 by Yohan Boniface
Merge with trunk
398
                            id: startTimeInput
359.2.6 by Mihir Soni
Added Translator comments
399
                            // TRANSLATORS: This "at" refers to HH:MM of an event. E.g 1st January at 10:30
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
400
                            title: i18n.tr("at")
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
401
                            objectName: "startTimeInput"
402
403
                            text: ""
404
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
405
                            width: (parent.width / 2) - units.gu(1)
406
                            anchors.right: parent.right
407
                            visible: !allDayEventCheckbox.checked
408
409
                            MouseArea{
410
                                anchors.fill: parent
411
                                onClicked: openDatePicker(startTimeInput, root, "startDate", "Hours|Minutes")
412
                            }
413
                        }
414
                    }
415
416
                    Item {
417
                        width: parent.width
418
                        height: endDateInput.height
419
                        visible: !allDayEventCheckbox.checked
420
421
                        NewEventEntryField{
422
                            id: endDateInput
423
                            title: i18n.tr("End")
424
                            objectName: "endDateInput"
425
426
                            text: ""
427
197.1.3 by Yohan Boniface
Merge with trunk
428
                            width: parent.width / 2
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
429
430
                            MouseArea{
431
                                anchors.fill: parent
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
432
                                onClicked: openDatePicker(endDateInput, root, "endDate", "Years|Months|Days")
56.1.4 by Riccardo Padovani
Implemented DatePicker. Thanks to Michael Zanetti
433
                            }
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
434
                        }
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
435
436
                        NewEventEntryField{
197.1.3 by Yohan Boniface
Merge with trunk
437
                            id: endTimeInput
359.2.4 by Mihir Soni
updated as per review comments
438
                            // TRANSLATORS: This "at" refers to HH:MM of an event. E.g 1st January at 10:30
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
439
                            title: i18n.tr("at")
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
440
                            objectName: "endTimeInput"
441
                            text: ""
442
                            width: (parent.width / 2) - units.gu(1)
443
                            anchors.right: parent.right
444
445
                            MouseArea{
446
                                anchors.fill: parent
197.1.2 by Yohan Boniface
Highlight datetime input when datepicker is open
447
                                onClicked: openDatePicker(endTimeInput, root, "endDate", "Hours|Minutes")
197.2.1 by David Planella
Merged from trunk
448
56.1.4 by Riccardo Padovani
Implemented DatePicker. Thanks to Michael Zanetti
449
                            }
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
450
                        }
451
                    }
452
                }
453
            }
191.4.1 by Kunal Parmar
Applying changes
454
212.4.3 by Kunal Parmar
Refinement
455
            Item{
456
                width: parent.width
457
                height: calendarsOption.height
458
                Label{
459
                    id: calendarLabel
460
                    text: i18n.tr("Calendar ");
461
                    anchors.verticalCenter: parent.verticalCenter
462
                }
463
464
                OptionSelector{
465
                    id: calendarsOption
360.1.2 by nskaggs
add calendar selection to tests, helps workaround bug 1347841 and 1347836
466
                    objectName: "calendarsOption"
212.4.3 by Kunal Parmar
Refinement
467
                    anchors.right: parent.right
468
                    width: parent.width - calendarLabel.width - units.gu(1)
469
                    containerHeight: itemHeight * 4
212.4.13 by Kunal Parmar
Newevent fix
470
                    model: root.model.getCollections();
212.4.3 by Kunal Parmar
Refinement
471
                    delegate: OptionSelectorDelegate{
472
                        text: modelData.name
473
474
                        UbuntuShape{
475
                            id: calColor
476
                            width: height
477
                            height: parent.height - units.gu(2)
478
                            color: modelData.color
479
                            anchors.right: parent.right
480
                            anchors.rightMargin: units.gu(1)
481
                            anchors.verticalCenter: parent.verticalCenter
482
                        }
483
                    }
484
                }
485
            }
486
191.4.1 by Kunal Parmar
Applying changes
487
            Row {
488
                width: parent.width
489
                spacing: units.gu(1)
490
                anchors.margins: units.gu(0.5)
491
492
                Label {
493
                    text: i18n.tr("All Day event:")
494
                    anchors.verticalCenter: allDayEventCheckbox.verticalCenter
495
                }
496
497
                CheckBox {
498
                    id: allDayEventCheckbox
499
                    checked: false
500
                }
501
            }
502
197.1.3 by Yohan Boniface
Merge with trunk
503
            ThinDivider{}
504
110.1.18 by Kunal Parmar
merge from trunk
505
            NewEventEntryField{
506
                id: titleEdit
507
                width: parent.width
508
                title: i18n.tr("Event Name")
509
                objectName: "newEventName"
510
            }
511
290.2.1 by Kunal Parmar
removing ubuntu shape from description field
512
            Column{
513
                id: descriptionColumn
514
                width: parent.width
515
                spacing: units.gu(1)
516
517
                Label {
518
                    text: i18n.tr("Description")
519
                    anchors.margins: units.gu(0.5)
520
                    anchors.left: parent.left
521
                }
522
523
                TextArea{
524
                    id: messageEdit
197.1.17 by nskaggs
rebase with trunk, add description and guest input
525
                    objectName: "eventDescriptionInput"
110.1.18 by Kunal Parmar
merge from trunk
526
                    width: parent.width
290.2.1 by Kunal Parmar
removing ubuntu shape from description field
527
                    color: focus ? "#2C001E" : "#5D5D5D"
528
                    // default style
529
                    font {
530
                        pixelSize: focus ? FontUtils.sizeToPixels("large") : FontUtils.sizeToPixels("medium")
110.1.18 by Kunal Parmar
merge from trunk
531
                    }
532
                }
533
            }
534
535
            NewEventEntryField{
536
                id: locationEdit
537
                width: parent.width
538
                title: i18n.tr("Location")
33.1.7 by Omer Akram
add autopilot test for NewEvent dialog
539
                objectName: "eventLocationInput"
110.1.18 by Kunal Parmar
merge from trunk
540
            }
541
110.1.27 by Kunal Parmar
Further modification for new event testcase
542
            NewEventEntryField{
543
                id: personEdit
544
                width: parent.width
545
                title: i18n.tr("Guests")
546
                objectName: "eventPeopleInput"
264.1.3 by Kunal Parmar
Hard coding removed
547
                visible: event.itemType === Type.Event
110.1.27 by Kunal Parmar
Further modification for new event testcase
548
            }
549
164.2.2 by Riccardo Padovani
Updated optionSelector
550
            Item {
110.1.18 by Kunal Parmar
merge from trunk
551
                width: parent.width
191.2.1 by Mario Guerriero
added support for recurrence in edit and display mode
552
                height: recurrenceOption.height
264.1.3 by Kunal Parmar
Hard coding removed
553
                visible: event.itemType === Type.Event
110.1.18 by Kunal Parmar
merge from trunk
554
                Label{
555
                    id: frequencyLabel
556
                    text: i18n.tr("This happens");
557
                    anchors.verticalCenter: parent.verticalCenter
558
                }
559
                OptionSelector{
191.2.1 by Mario Guerriero
added support for recurrence in edit and display mode
560
                    id: recurrenceOption
164.2.2 by Riccardo Padovani
Updated optionSelector
561
                    anchors.right: parent.right
562
                    width: parent.width - optionSelectorWidth - units.gu(1)
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
563
                    model: Defines.recurrenceLabel
564
                    containerHeight: itemHeight * 4
110.1.18 by Kunal Parmar
merge from trunk
565
                }
566
            }
286.1.1 by Mihir Soni
Added repeate week days
567
568
            Row {
569
                id:weeksRow
570
                width: parent.width
286.1.7 by Mihir Soni
Added localization form Qt.locale
571
                spacing: units.gu(4)
286.1.1 by Mihir Soni
Added repeate week days
572
                anchors.margins: units.gu(1)
286.1.9 by Mihir Soni
added more recurrence options
573
                visible: recurrenceOption.selectedIndex == 5
286.1.1 by Mihir Soni
Added repeate week days
574
                Label {
575
                    text: i18n.tr("Repeats On:")
576
                    anchors.verticalCenter: parent.verticalCenter
577
                }
578
                Repeater{
579
                    model: Defines.weekLabel
580
                    width: parent.width
581
                    CheckBox {
582
                        id: weekCheck
583
                        anchors.verticalCenter: parent.verticalCenter
584
                        onCheckedChanged: {
286.1.16 by Mihir Soni
changes as per review comments
585
                            //EDS consider 7 as Sunday index so if the index is 0 then we have to explicitly push Sunday.
286.1.12 by Mihir Soni
Change as per review comments
586
                            if(index === 0)
286.1.21 by Mihir Soni
Changes as per review comments
587
                                (checked) ? internal.weekDays.push(Qt.Sunday) : internal.weekDays.splice(internal.weekDays.indexOf(Qt.Sunday),1);
286.1.12 by Mihir Soni
Change as per review comments
588
                            else
286.1.21 by Mihir Soni
Changes as per review comments
589
                                (checked) ? internal.weekDays.push(index) : internal.weekDays.splice(internal.weekDays.indexOf(index),1);
286.1.1 by Mihir Soni
Added repeate week days
590
                        }
591
                        checked: {
286.1.22 by Mihir Soni
resolved typo
592
                            (internal.weekDays.length === 0 && index === date.getDay() && isEdit== false) ? true : false;
286.1.1 by Mihir Soni
Added repeate week days
593
                        }
594
                        Label{
595
                            id:lbl
596
                            text:modelData
597
                            anchors.centerIn: parent
286.1.7 by Mihir Soni
Added localization form Qt.locale
598
                            width: parent.width + units.gu(7)
286.1.1 by Mihir Soni
Added repeate week days
599
                        }
600
                    }
601
                }
602
            }
211.2.1 by Mihir
Added limit functionality to event
603
            Item {
211.2.2 by Mihir Soni
Added , edit support for limit
604
                id: limit
211.2.7 by Mihir Soni
Modifications as per Review comments.
605
                visible: recurrenceOption.selectedIndex != 0
211.2.1 by Mihir
Added limit functionality to event
606
                width: parent.width
607
                height: limitOptions.height
608
                Label{
211.2.2 by Mihir Soni
Added , edit support for limit
609
                    id: limitLabel
211.2.25 by Mihir Soni
Changed width of label
610
                    text: i18n.tr("Recurring event ends");
211.2.28 by Mihir Soni
Changed width
611
                    anchors{
211.2.32 by Mihir Soni
Merge with trunk
612
                        left: parent.left
613
                        right: limitOptions.left
211.2.28 by Mihir Soni
Changed width
614
                    }
615
                    wrapMode: Text.WordWrap
616
                    maximumLineCount: 2
211.2.1 by Mihir
Added limit functionality to event
617
                    anchors.verticalCenter: parent.verticalCenter
618
                }
619
                OptionSelector{
620
                    id: limitOptions
621
                    anchors.right: parent.right
211.2.28 by Mihir Soni
Changed width
622
                    width: parent.width - optionSelectorWidth - units.gu(3)
211.2.1 by Mihir
Added limit functionality to event
623
                    model: Defines.limitLabel
624
                    containerHeight: itemHeight * 4
625
626
                }
627
            }
628
            NewEventEntryField{
629
                id: limitCount
630
                width: parent.width
359.2.4 by Mihir Soni
updated as per review comments
631
                // TRANSLATORS: This refers to no of occurences of an event.
359.2.1 by Mihir Soni
fixed bug #1342148 && bug #1344362
632
                title: i18n.tr("Recurrence")
211.2.1 by Mihir
Added limit functionality to event
633
                objectName: "eventLimitCount"
211.2.12 by Mihir Soni
Modified as per review comments
634
                visible:  recurrenceOption.selectedIndex != 0 && limitOptions.selectedIndex == 1;
211.2.14 by Mihir Soni
Removed top limit Int Validator
635
                validator: IntValidator{bottom: 1;}
211.2.20 by Mihir Soni
Modifed per the review comments
636
                inputMethodHints: Qt.ImhDialableCharactersOnly
211.2.7 by Mihir Soni
Modifications as per Review comments.
637
                focus: true
211.2.1 by Mihir
Added limit functionality to event
638
            }
639
            Item {
640
                id: limitDate
641
                width: parent.width
642
                height: datePick.height
211.2.12 by Mihir Soni
Modified as per review comments
643
                visible: recurrenceOption.selectedIndex != 0 && limitOptions.selectedIndex===2;
211.2.1 by Mihir
Added limit functionality to event
644
                DatePicker{
645
                    id:datePick;
646
                    width: parent.width
647
                }
648
            }
164.2.2 by Riccardo Padovani
Updated optionSelector
649
            Item{
110.1.18 by Kunal Parmar
merge from trunk
650
                width: parent.width
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
651
                height: reminderOption.height
110.1.18 by Kunal Parmar
merge from trunk
652
                Label{
653
                    id: remindLabel
654
                    text: i18n.tr("Remind me");
655
                    anchors.verticalCenter: parent.verticalCenter
656
                }
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
657
110.1.18 by Kunal Parmar
merge from trunk
658
                OptionSelector{
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
659
                    id: reminderOption
164.2.2 by Riccardo Padovani
Updated optionSelector
660
                    anchors.right: parent.right
661
                    width: parent.width - optionSelectorWidth - units.gu(1)
197.1.7 by Yohan Boniface
Put back reminder management lost in previous merge
662
                    containerHeight: itemHeight * 4
663
                    model: Defines.reminderLabel
110.1.18 by Kunal Parmar
merge from trunk
664
                }
665
            }
88.1.1 by Olivier Tilloy
Dismiss the OSK when a text field looses focus.
666
        }
124.3.5 by Kunal Parmar
EDS integration done
667
    }
668
253.4.1 by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page.
669
    EditToolbar {
670
        id: toolbar
671
        anchors {
672
            left: parent.left
673
            right: parent.right
674
            bottom: parent.bottom
675
        }
676
        height: units.gu(6)
677
        acceptAction: Action {
678
            text: i18n.tr("Save")
679
            onTriggered: saveToQtPim();
680
        }
681
        rejectAction: Action {
682
            text: i18n.tr("Cancel")
683
            onTriggered: pageStack.pop();
684
        }
685
    }
686
687
    // used to keep the field visible when the keyboard appear or dismiss
688
    KeyboardRectangle {
689
        id: keyboard
690
691
        onHeightChanged: {
692
            if (flickable.activeItem) {
693
                flickable.makeMeVisible(flickable.activeItem)
694
            }
695
        }
696
    }
697
88.1.1 by Olivier Tilloy
Dismiss the OSK when a text field looses focus.
698
    QtObject {
286.1.22 by Mihir Soni
resolved typo
699
        id: internal
286.1.21 by Mihir Soni
Changes as per review comments
700
        property var weekDays : [];
88.1.1 by Olivier Tilloy
Dismiss the OSK when a text field looses focus.
701
        function clearFocus() {
702
            Qt.inputMethod.hide()
703
            titleEdit.focus = false
704
            locationEdit.focus = false
705
            personEdit.focus = false
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
706
            startDateInput.focus = false
197.1.3 by Yohan Boniface
Merge with trunk
707
            startTimeInput.focus = false
197.1.5 by Yohan Boniface
Allow endDate and startDate to have different days
708
            endDateInput.focus = false
197.1.1 by Yohan Boniface
First patch to switch to DatePicker
709
            endTimeInput.focus = false
124.3.9 by Kunal Parmar
Merged from Trunk
710
            messageEdit.focus = false
88.1.1 by Olivier Tilloy
Dismiss the OSK when a text field looses focus.
711
        }
712
    }
12.1.3 by Frank Mertens
Added the NewEvent component from the EventAPI_EventView branch
713
}