~popey/ubuntu-calendar-app/new-icon

« back to all changes in this revision

Viewing changes to NewEvent.qml

  • Committer: Tarmac
  • Author(s): Mario Guerriero
  • Date: 2014-02-08 04:53:28 UTC
  • mfrom: (191.2.1 ubuntu-calendar-app)
  • Revision ID: tarmac-20140208045328-09kiywjx2puu39j2
added support for recurrence. Fixes: https://bugs.launchpad.net/bugs/1270242.

Approved by Ubuntu Phone Apps Jenkins Bot, Kunal Parmar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import QtQuick 2.0
 
2
import QtOrganizer 5.0
2
3
import Ubuntu.Components 0.1
3
4
import Ubuntu.Components.Popups 0.1
4
5
import Ubuntu.Components.ListItems 0.1
73
74
                    personEdit.text += ",";
74
75
            }
75
76
        }
 
77
 
 
78
        var index = 0;
 
79
        if(e.recurrence ) {
 
80
            var recurrenceRule = e.recurrence.recurrenceRules;
 
81
            index = ( recurrenceRule.length > 0 ) ? recurrenceRule[0].frequency : 0;
 
82
        }
 
83
        recurrenceOption.selectedIndex = index;
76
84
    }
 
85
 
77
86
    //Save the new or Existing event
78
87
    function saveToQtPim() {
79
88
        internal.clearFocus()
91
100
                attendee.name = personEdit.text;
92
101
                event.setDetail(attendee);
93
102
            }
 
103
 
 
104
            var recurrenceRule = internal.recurrenceValue[ recurrenceOption.selectedIndex ];
 
105
            if( recurrenceRule !== RecurrenceRule.Invalid ) {
 
106
                var rule = Qt.createQmlObject("import QtOrganizer 5.0; RecurrenceRule {}", event.recurrence);
 
107
                rule.frequency = recurrenceRule;
 
108
                event.recurrence.recurrenceRules = [rule];
 
109
            }
 
110
 
94
111
            internal.eventModel.saveItem(event);
95
112
            pageStack.pop();
96
113
        }
274
291
 
275
292
            Item {
276
293
                width: parent.width
277
 
                height: childrenRect.height
 
294
                height: recurrenceOption.height
278
295
                Label{
279
296
                    id: frequencyLabel
280
297
                    text: i18n.tr("This happens");
281
298
                    anchors.verticalCenter: parent.verticalCenter
282
299
                }
283
300
                OptionSelector{
 
301
                    id: recurrenceOption
284
302
                    anchors.right: parent.right
285
303
                    width: parent.width - optionSelectorWidth - units.gu(1)
286
 
                    model:[i18n.tr("Once"),i18n.tr("Daily"),i18n.tr("Weekly"),i18n.tr("Monthly"),i18n.tr("Yearly")]
 
304
                    model: internal.recurrenceLabel
287
305
                }
288
306
            }
289
307
 
316
334
    QtObject {
317
335
        id: internal
318
336
        property var eventModel;
 
337
        property var recurrenceValue: [ RecurrenceRule.Invalid,
 
338
            RecurrenceRule.Daily,
 
339
            RecurrenceRule.Weekly,
 
340
            RecurrenceRule.Monthly,
 
341
            RecurrenceRule.Yearly];
 
342
 
 
343
        property var recurrenceLabel: [ i18n.tr("Once"),
 
344
            i18n.tr("Daily"),
 
345
            i18n.tr("Weekly"),
 
346
            i18n.tr("Monthly"),
 
347
            i18n.tr("Yearly")];
319
348
 
320
349
        function clearFocus() {
321
350
            Qt.inputMethod.hide()