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 { ...@@ -311,9 +311,8 @@ Kirigami.Page {
if(validation.success) { if(validation.success) {
console.log("Saving event, root.startdt:" + startdt); 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() }; 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(); editcompleted();
} }
else { else {
...@@ -335,13 +334,6 @@ Kirigami.Page { ...@@ -335,13 +334,6 @@ Kirigami.Page {
id: endDatePickerSheet id: endDatePickerSheet
} }
Component {
id: eventController
Calindori.EventController {
}
}
Calindori.IncidenceAlarmsModel { Calindori.IncidenceAlarmsModel {
id: incidenceAlarmsModel id: incidenceAlarmsModel
......
...@@ -44,12 +44,6 @@ Kirigami.Page { ...@@ -44,12 +44,6 @@ Kirigami.Page {
onTriggered: pageStack.push(eventEditor, {startdt: eventStartDt}) onTriggered: pageStack.push(eventEditor, {startdt: eventStartDt})
} }
Component {
id: eventController
Calindori.EventController {}
}
Component { Component {
id: eventEditor id: eventEditor
...@@ -92,9 +86,8 @@ Kirigami.Page { ...@@ -92,9 +86,8 @@ Kirigami.Page {
icon.name: "delete" icon.name: "delete"
onTriggered: { onTriggered: {
var controller = eventController.createObject(parent, {});
var vevent = { uid: model.uid } ; var vevent = { uid: model.uid } ;
controller.remove(root.calendar, vevent); _eventController.remove(root.calendar, vevent);
eventsUpdated(); eventsUpdated();
} }
}, },
......
...@@ -207,9 +207,8 @@ Kirigami.Page { ...@@ -207,9 +207,8 @@ Kirigami.Page {
onTriggered: { onTriggered: {
console.log("Saving task"); 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}; 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(); taskeditcompleted();
} }
} }
...@@ -219,11 +218,4 @@ Kirigami.Page { ...@@ -219,11 +218,4 @@ Kirigami.Page {
TimePickerSheet { TimePickerSheet {
id: startTimePickerSheet id: startTimePickerSheet
} }
Component {
id: todoController
Calindori.TodoController {}
}
} }
...@@ -56,12 +56,6 @@ Kirigami.Page { ...@@ -56,12 +56,6 @@ Kirigami.Page {
} }
} }
Component {
id: todoController
Calindori.TodoController {}
}
Controls2.Label { Controls2.Label {
anchors.fill: parent anchors.fill: parent
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
...@@ -91,9 +85,8 @@ Kirigami.Page { ...@@ -91,9 +85,8 @@ Kirigami.Page {
icon.name: "delete" icon.name: "delete"
onTriggered: { onTriggered: {
var controller = todoController.createObject(parent, {});
var vtodo = { "uid" : model.uid }; var vtodo = { "uid" : model.uid };
controller.remove(root.calendar, vtodo); _todoController.remove(root.calendar, vtodo);
tasksUpdated(); tasksUpdated();
} }
}, },
......
...@@ -51,6 +51,12 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) ...@@ -51,6 +51,12 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
engine.load(QUrl(QStringLiteral("qrc:///Main.qml"))); 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()) { if (engine.rootObjects().isEmpty()) {
return -1; 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