~yohanboniface/ubuntu-calendar-app/DatePicker

« back to all changes in this revision

Viewing changes to NewEvent.qml

  • Committer: Yohan Boniface
  • Date: 2014-03-04 22:05:29 UTC
  • Revision ID: yohanboniface@free.fr-20140304220529-6iltvb3i38ocv1tk
Allow endDate and startDate to have different days

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    property bool isEdit: false
22
22
 
23
23
    onStartDateChanged: {
24
 
        dateInput.text = Qt.formatDateTime(startDate, "dd MMM yyyy");
 
24
        startDateInput.text = Qt.formatDateTime(startDate, "dd MMM yyyy");
25
25
        startTimeInput.text = Qt.formatDateTime(startDate, "hh:mm");
26
 
        // Make sure the endDate is always same day as start date
27
 
        endDate.mergeDate(startDate);
28
26
    }
29
27
 
30
28
    onEndDateChanged: {
 
29
        endDateInput.text = Qt.formatDateTime(endDate, "dd MMM yyyy");
31
30
        endTimeInput.text = Qt.formatDateTime(endDate, "hh:mm");
32
31
    }
33
32
 
88
87
                    personEdit.text += ",";
89
88
            }
90
89
        }
 
90
        allDayEventCheckbox.checked = e.allDay;
91
91
 
92
92
        var index = 0;
93
93
        if(e.recurrence ) {
100
100
    //Save the new or Existing event
101
101
    function saveToQtPim() {
102
102
        internal.clearFocus()
103
 
        if ( startDate >= endDate ) {
 
103
        if ( startDate >= endDate && !allDayEventCheckbox.checked) {
104
104
            PopupUtils.open(errorDlgComponent,root,{"text":i18n.tr("End time can't be before start time")});
105
105
        } else {
106
106
            event.startDateTime = startDate;
215
215
                    anchors.centerIn: parent
216
216
                    spacing: units.gu(1)
217
217
 
218
 
                    NewEventEntryField{
219
 
                        id: dateInput
220
 
                        title: i18n.tr("Date")
 
218
                    Item {
221
219
                        width: parent.width
222
 
                        objectName: "dateInput"
223
 
 
224
 
                        text: "";
225
 
 
226
 
                        MouseArea{
227
 
                            anchors.fill: parent
228
 
                            onClicked: openDatePicker(dateInput, root, "startDate", "Years|Months|Days")
 
220
                        height: startDateInput.height
 
221
 
 
222
                        NewEventEntryField{
 
223
                            id: startDateInput
 
224
                            title: i18n.tr("Start")
 
225
                            objectName: "startTimeInput"
 
226
 
 
227
                            text: ""
 
228
 
 
229
                            width: allDayEventCheckbox.checked ? parent.width : parent.width / 2
 
230
 
 
231
                            MouseArea{
 
232
                                anchors.fill: parent
 
233
                                onClicked: openDatePicker(startDateInput, root, "startDate", "Years|Months|Days")
 
234
                            }
229
235
                        }
230
 
                    }
231
 
 
232
 
                    Item {
233
 
                        id: times
234
 
                        width: parent.width
235
 
                        height: startTimeInput.height
236
236
 
237
237
                        NewEventEntryField{
238
238
                            id: startTimeInput
239
 
                            title: i18n.tr("Start")
 
239
                            title: i18n.tr("at")
240
240
                            objectName: "startTimeInput"
241
241
 
242
242
                            text: ""
243
243
 
 
244
                            width: (parent.width / 2) - units.gu(1)
 
245
                            anchors.right: parent.right
 
246
                            visible: !allDayEventCheckbox.checked
 
247
 
 
248
                            MouseArea{
 
249
                                anchors.fill: parent
 
250
                                onClicked: openDatePicker(startTimeInput, root, "startDate", "Hours|Minutes")
 
251
                            }
 
252
                        }
 
253
                    }
 
254
 
 
255
                    Item {
 
256
                        width: parent.width
 
257
                        height: endDateInput.height
 
258
                        visible: !allDayEventCheckbox.checked
 
259
 
 
260
                        NewEventEntryField{
 
261
                            id: endDateInput
 
262
                            title: i18n.tr("End")
 
263
                            objectName: "endDateInput"
 
264
 
 
265
                            text: ""
 
266
 
244
267
                            width: parent.width / 2
245
268
 
246
269
                            MouseArea{
247
270
                                anchors.fill: parent
248
 
                                onClicked: openDatePicker(startTimeInput, root, "startDate", "Hours|Minutes")
 
271
                                onClicked: openDatePicker(endDateInput, root, "endDate", "Years|Months|Days")
249
272
                            }
250
273
                        }
251
274
 
252
275
                        NewEventEntryField{
253
276
                            id: endTimeInput
254
 
                            title: i18n.tr("End")
 
277
                            title: i18n.tr("at")
255
278
                            objectName: "endTimeInput"
256
279
 
257
280
                            text: ""
282
305
                CheckBox {
283
306
                    id: allDayEventCheckbox
284
307
                    checked: false
285
 
 
286
 
                    onCheckedChanged: {
287
 
                        times.visible = !checked;
288
 
                    }
289
308
                }
290
309
            }
291
310
 
398
417
            titleEdit.focus = false
399
418
            locationEdit.focus = false
400
419
            personEdit.focus = false
 
420
            startDateInput.focus = false
401
421
            startTimeInput.focus = false
 
422
            endDateInput.focus = false
402
423
            endTimeInput.focus = false
403
424
            messageEdit.focus = false
404
425
        }