Commit 4b25ad7f authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Offer completion of todos

parent 43aa39a9
Pipeline #2245 passed with stage
in 13 minutes and 45 seconds
......@@ -35,6 +35,7 @@ Kirigami.Page {
property alias startMinute: startTimeSelector.startMinutes
property alias allDay: allDaySelector.checked
property alias location: location.text
property alias completed: completed.checked
property var calendar
property var todoData
property alias timePicker: timePickerSheet
......@@ -58,6 +59,7 @@ Kirigami.Page {
Kirigami.FormLayout {
id: todoCard
enabled: !root.completed
Kirigami.Separator {
Kirigami.FormData.isSection: true
......@@ -133,6 +135,7 @@ Kirigami.Page {
Controls2.TextArea {
id: description
enabled: !root.completed
Layout.fillWidth: true
Layout.minimumWidth: Kirigami.Units.gridUnit * 4
Layout.minimumHeight: Kirigami.Units.gridUnit * 4
......@@ -140,6 +143,17 @@ Kirigami.Page {
text: todoData ? todoData.description : ""
placeholderText: qsTr("Description")
}
Kirigami.Separator {
Layout.fillWidth: true
}
Controls2.CheckBox {
id: completed
text: qsTr("Completed")
checked: todoData ? todoData.completed: false
}
}
actions {
......@@ -176,7 +190,7 @@ Kirigami.Page {
onTriggered: {
if(summary.text) {
console.log("Saving task");
root.calendar.addEditTask(root.uid, root.startdt, root.summary, root.description, root.startHour, root.startMinute, root.allDay, root.location); //TODO: Pass a Todo object
root.calendar.addEditTask(root.uid, root.startdt, root.summary, root.description, root.startHour, root.startMinute, root.allDay, root.location, root.completed); //TODO: Pass a Todo object
taskeditcompleted();
}
else {
......
......@@ -93,6 +93,8 @@ Kirigami.Page {
contentItem: Column {
enabled: !model.completed
Controls2.Label {
wrapMode: Text.WordWrap
text: model.description
......
......@@ -91,7 +91,7 @@ void LocalCalendar::setCalendarstorage(FileStorage::Ptr calendarStorage)
}
}
void LocalCalendar::addEditTask(QString uid, QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location)
void LocalCalendar::addEditTask(QString uid, QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location, bool completed)
{
if ( m_calendar == nullptr)
{
......@@ -127,6 +127,7 @@ void LocalCalendar::addEditTask(QString uid, QDate startDate, QString summary, Q
todo->setSummary(summary);
todo->setAllDay(allDayFlg);
todo->setLocation(location);
todo->setCompleted(completed);
m_calendar->addTodo(todo);
bool success = m_cal_storage->save();
......
......@@ -47,7 +47,7 @@ public:
void setName(QString calendarName);
public Q_SLOTS:
void addEditTask(QString uid, QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location);
void addEditTask(QString uid, QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location, bool completed);
void deleteTask(QString uid);
int todosCount(const QDate &date) const;
void deleteCalendar();
......
......@@ -44,6 +44,7 @@ QHash< int, QByteArray > TodosModel::roleNames() const
roles.insert(Priority, "priority");
roles.insert(Created, "created");
roles.insert(Secrecy, "secrecy");
roles.insert(Completed, "completed");
return roles;
}
......@@ -76,6 +77,8 @@ QVariant TodosModel::data(const QModelIndex& index, int role) const
return m_todos.at(index.row())->created();
case Secrecy:
return m_todos.at(index.row())->secrecy();
case Completed:
return m_todos.at(index.row())->isCompleted();
}
return QVariant();
}
......
......@@ -46,7 +46,8 @@ public:
Categories,
Priority,
Created,
Secrecy
Secrecy,
Completed
};
explicit TodosModel(QObject* parent = nullptr);
......
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