~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

Viewing changes to NewEvent.qml

  • Committer: Kunal Parmar
  • Date: 2014-10-21 18:58:31 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: pkunal.parmar@gmail.com-20141021185831-9pqmtt38wdbdhi6x
Moved TimeComponent to seperate comp

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    property bool isEdit: false
44
44
 
45
45
    onStartDateChanged: {
46
 
        startDateInput.text = startDate.toLocaleDateString();
47
 
        startTimeInput.text = Qt.formatTime(startDate);
 
46
        startDateTimeInput.dateTime = startDate;
48
47
        adjustEndDateToStartDate()
49
48
    }
50
49
 
51
50
    onEndDateChanged: {
52
 
        endDateInput.text = endDate.toLocaleDateString();
53
 
        endTimeInput.text = Qt.formatTime(endDate);
 
51
        endDateTimeInput.dateTime = endDate;
54
52
    }
55
53
 
56
54
    head.actions: Action {
229
227
        return daysOfWeek;
230
228
    }
231
229
 
232
 
    function openDatePicker (element, caller, callerProperty, mode) {
233
 
        element.highlighted = true;
234
 
        var picker = PickerPanel.openDatePicker(caller, callerProperty, mode);
235
 
        if (!picker) return;
236
 
        picker.closed.connect(function () {
237
 
            element.highlighted = false;
238
 
        });
239
 
    }
240
 
 
241
230
    // Calucate default hour and minute for start and end time on event
242
231
    function roundDate(date) {
243
232
        var tempDate = new Date(date)
336
325
 
337
326
            width: parent.width
338
327
 
339
 
            ListItem.Header {
340
 
                text: i18n.tr("From")
341
 
            }
342
 
 
343
 
            Item {
344
 
                anchors {
345
 
                    left: parent.left
346
 
                    right: parent.right
347
 
                    margins: units.gu(2)
348
 
                }
349
 
 
350
 
                height: startDateInput.height
351
 
 
352
 
                NewEventEntryField{
353
 
                    id: startDateInput
354
 
                    objectName: "startDateInput"
355
 
 
356
 
                    text: ""
357
 
                    anchors.left: parent.left
358
 
                    width: allDayEventCheckbox.checked ? parent.width : 4 * parent.width / 5
359
 
 
360
 
                    MouseArea{
361
 
                        anchors.fill: parent
362
 
                        onClicked: openDatePicker(startDateInput, root, "startDate", "Years|Months|Days")
363
 
                    }
364
 
                }
365
 
 
366
 
                NewEventEntryField{
367
 
                    id: startTimeInput
368
 
                    objectName: "startTimeInput"
369
 
 
370
 
                    text: ""
371
 
                    anchors.right: parent.right
372
 
                    width: parent.width / 5
373
 
                    visible: !allDayEventCheckbox.checked
374
 
                    horizontalAlignment: Text.AlignRight
375
 
 
376
 
                    MouseArea{
377
 
                        anchors.fill: parent
378
 
                        onClicked: openDatePicker(startTimeInput, root, "startDate", "Hours|Minutes")
379
 
                    }
380
 
                }
381
 
            }
382
 
 
383
 
            ListItem.Header {
384
 
                text: i18n.tr("To")
385
 
            }
386
 
 
387
 
            Item {
388
 
                anchors {
389
 
                    left: parent.left
390
 
                    right: parent.right
391
 
                    margins: units.gu(2)
392
 
                }
393
 
 
394
 
                height: endDateInput.height
395
 
 
396
 
                NewEventEntryField{
397
 
                    id: endDateInput
398
 
                    objectName: "endDateInput"
399
 
 
400
 
                    text: ""
401
 
                    anchors.left: parent.left
402
 
                    width: allDayEventCheckbox.checked ? parent.width : 4 * parent.width / 5
403
 
 
404
 
                    MouseArea{
405
 
                        anchors.fill: parent
406
 
                        onClicked: openDatePicker(endDateInput, root, "endDate", "Years|Months|Days")
407
 
                    }
408
 
                }
409
 
 
410
 
                NewEventEntryField{
411
 
                    id: endTimeInput
412
 
                    objectName: "endTimeInput"
413
 
                    text: ""
414
 
                    width: parent.width / 5
415
 
                    visible: !allDayEventCheckbox.checked
416
 
                    anchors.right: parent.right
417
 
                    horizontalAlignment: Text.AlignRight
418
 
 
419
 
                    MouseArea{
420
 
                        anchors.fill: parent
421
 
                        onClicked: openDatePicker(endTimeInput, root, "endDate", "Hours|Minutes")
422
 
                    }
 
328
            NewEventTimePicker{
 
329
                id: startDateTimeInput
 
330
                header: i18n.tr("From")
 
331
                showTimePicker: !allDayEventCheckbox.checked
 
332
                anchors {
 
333
                    left: parent.left
 
334
                    right: parent.right
 
335
                }
 
336
                onDateTimeChanged: {
 
337
                    startDate = dateTime;
 
338
                }
 
339
            }
 
340
 
 
341
            NewEventTimePicker{
 
342
                id: endDateTimeInput
 
343
                header: i18n.tr("To")
 
344
                showTimePicker: !allDayEventCheckbox.checked
 
345
                anchors {
 
346
                    left: parent.left
 
347
                    right: parent.right
 
348
                }
 
349
                onDateTimeChanged: {
 
350
                    endDate = dateTime;
423
351
                }
424
352
            }
425
353
 
676
604
            Qt.inputMethod.hide()
677
605
            titleEdit.focus = false
678
606
            locationEdit.focus = false
679
 
            startDateInput.focus = false
680
 
            startTimeInput.focus = false
681
 
            endDateInput.focus = false
682
 
            endTimeInput.focus = false
 
607
            startDateTimeInput.clearFocus();
 
608
            endDateTimeInput.clearFocus();
683
609
            messageEdit.focus = false
684
610
        }
685
611