Commit 51c23c16 authored by Nicolas Fella's avatar Nicolas Fella Committed by Dimitris Kardarakos

Inject todo/event controller via context property

parent c2c8f841
Pipeline #6211 passed with stage
in 5 minutes and 1 second
......@@ -311,9 +311,8 @@ Kirigami.Page {
if(validation.success) {
console.log("Saving event, root.startdt:" + startdt);
var controller = eventController.createObject(parent, {});
var vevent = { "uid" : root.uid, "startDate": root.startdt, "summary": root.summary, "description": root.description, "startHour": root.startHour + (root.startPm ? 12 : 0), "startMinute": root.startMinute, "allDay": root.allDay, "location": root.location, "endDate": (root.allDay ? root.startdt : root.enddt), "endHour": root.endHour + (root.endPm ? 12 : 0), "endMinute": root.endMinute, "alarms": incidenceAlarmsModel.alarms() };
controller.addEdit(root.calendar, vevent);
_eventController.addEdit(root.calendar, vevent);
editcompleted();
}
else {
......@@ -335,13 +334,6 @@ Kirigami.Page {
id: endDatePickerSheet
}
Component {
id: eventController
Calindori.EventController {
}
}
Calindori.IncidenceAlarmsModel {
id: incidenceAlarmsModel
......
......@@ -44,12 +44,6 @@ Kirigami.Page {
onTriggered: pageStack.push(eventEditor, {startdt: eventStartDt})
}
Component {
id: eventController
Calindori.EventController {}
}
Component {
id: eventEditor
......@@ -92,9 +86,8 @@ Kirigami.Page {
icon.name: "delete"
onTriggered: {
var controller = eventController.createObject(parent, {});
var vevent = { uid: model.uid } ;
controller.remove(root.calendar, vevent);
_eventController.remove(root.calendar, vevent);
eventsUpdated();
}
},
......
......@@ -207,9 +207,8 @@ Kirigami.Page {
onTriggered: {
console.log("Saving task");
var controller = todoController.createObject(parent, {});
var vtodo = { "uid": root.uid, "summary":root.summary, "startDate": root.startdt , "startHour": root.startHour + (root.startPm ? 12 : 0), "startMinute": root.startMinute, "allDay": root.allDay, "description": root.description,"location": root.location, "completed": root.completed};
controller.addEdit(root.calendar, vtodo);
_todoController.addEdit(root.calendar, vtodo);
taskeditcompleted();
}
}
......@@ -219,11 +218,4 @@ Kirigami.Page {
TimePickerSheet {
id: startTimePickerSheet
}
Component {
id: todoController
Calindori.TodoController {}
}
}
......@@ -56,12 +56,6 @@ Kirigami.Page {
}
}
Component {
id: todoController
Calindori.TodoController {}
}
Controls2.Label {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
......@@ -91,9 +85,8 @@ Kirigami.Page {
icon.name: "delete"
onTriggered: {
var controller = todoController.createObject(parent, {});
var vtodo = { "uid" : model.uid };
controller.remove(root.calendar, vtodo);
_todoController.remove(root.calendar, vtodo);
tasksUpdated();
}
},
......
......@@ -51,6 +51,12 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
engine.load(QUrl(QStringLiteral("qrc:///Main.qml")));
TodoController todoController;
engine.rootContext()->setContextProperty(QStringLiteral("_todoController"), &todoController);
EventController eventController;
engine.rootContext()->setContextProperty(QStringLiteral("_eventController"), &eventController);
if (engine.rootObjects().isEmpty()) {
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment