Commit 1805d0bd authored by Dimitris Kardarakos's avatar Dimitris Kardarakos
Browse files

Added start time and location to tasks functionality

parent 2a9e623f
......@@ -27,7 +27,13 @@ import org.kde.phone.mobilecalendar 0.1 as MobileCalendar
Kirigami.Page {
id: root
property date startdt
property date startdt;
property alias summary: summary.text;
property alias description: description.text;
property alias startHour: startHourSelector.value;
property alias startMinute: startMinuteSelector.value;
property alias allDay: allDaySelector.checked;
property alias location: location.text;
property var calendar
signal taskeditcompleted
......@@ -38,12 +44,12 @@ Kirigami.Page {
id: todoCard
anchors.fill: parent
// header: Kirigami.Heading {
// text: "New Task"
// }
//
// header: Kirigami.Heading {
// text: "New Task"
// }
//
contentItem: ColumnLayout {
Controls2.Label {
text: startdt.toLocaleDateString(Qt.locale())
}
......@@ -54,14 +60,46 @@ Kirigami.Page {
placeholderText: qsTr("Summary")
}
RowLayout {
Controls2.Label {
text: "Start time"
}
Controls2.SpinBox {
id: startHourSelector
from: 0
to: 23
}
Controls2.SpinBox {
id: startMinuteSelector
from: 0
to: 59
}
}
Controls2.CheckBox {
id: allDaySelector
checked: false
text: qsTr("All day")
}
Controls2.TextArea {
id:description
id: description
placeholderText: qsTr("Description")
}
RowLayout {
Controls2.TextArea {
id: location
placeholderText: qsTr("Location")
}
RowLayout {
Controls2.Button {
id: saveBtn
......@@ -70,7 +108,7 @@ Kirigami.Page {
onClicked: {
if(summary.text) {
console.log("Saving task");
root.calendar.addTask(summary.text, description.text, root.startdt);
root.calendar.addTask(root.startdt, root.summary, root.description, root.startHour, root.startMinute, root.allDay, root.location); //TODO: Pass a Todo object
taskeditcompleted();
}
else {
......
......@@ -29,19 +29,19 @@ Kirigami.ScrollablePage {
property date todoDt
property var calendar
property alias todosmodel: cardsListview.model
title: qsTr("Tasks")
Kirigami.CardsListView {
id: cardsListview
model:
MobileCalendar.TodosModel {
id: todosModel
filterdt: todoDt
memorycalendar: root.calendar.memorycalendar
}
MobileCalendar.TodosModel {
id: todosModel
filterdt: todoDt
memorycalendar: root.calendar.memorycalendar
}
delegate: Kirigami.AbstractCard {
header: Kirigami.Heading {
......@@ -49,9 +49,39 @@ Kirigami.ScrollablePage {
level: 2
}
contentItem: Controls2.Label {
wrapMode: Text.WordWrap
contentItem: ColumnLayout {
Controls2.Label {
wrapMode: Text.WordWrap
text: model.description
}
RowLayout {
visible: model.dtstart.toLocaleTimeString(Qt.locale()) != ""
Controls2.Label {
wrapMode: Text.WordWrap
text: "Start Time: "
}
Controls2.Label {
wrapMode: Text.WordWrap
text: model.dtstart.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
}
}
RowLayout {
visible: model.location != ""
Controls2.Label {
wrapMode: Text.WordWrap
text: "Location: "
}
Controls2.Label {
wrapMode: Text.WordWrap
text: model.location
}
}
}
}
}
......
......@@ -50,7 +50,7 @@ QString LocalCalendar::name() const
void LocalCalendar::setName(QString calendarName)
{
if (m_name != calendarName) {
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZone()));
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZoneId()));
FileStorage::Ptr storage(new FileStorage(calendar));
QString fullPathName = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/" + calendarName; //TODO: Consider changing to GenericDataLocation if calendar should be shared with other apps
......@@ -94,16 +94,21 @@ void LocalCalendar::setCalendarstorage(FileStorage::Ptr calendarStorage)
}
}
void LocalCalendar::addTask(QString summary, QString description, QDate startDate)
void LocalCalendar::addTask(QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location)
{
qDebug() << "Creating todo" << "summary:" << summary << ", description:" << description << ", startDate:" << startDate.toString();
qDebug() << "Creating todo" << "summary:" << summary << ", description:" << description << ", startDate:" << startDate.toString() << ", startHour: " << startHour << " , startMinute: " << startMinute << " , allDayFlg: " << allDayFlg;
QDateTime now = QDateTime::currentDateTime();
QDateTime startDateTime = QDateTime(startDate, QTime(startHour, startMinute, 0, 0), QTimeZone::systemTimeZone());
// startDateTime.setTime(QTime(startHour, startMinute, 0, 0));
Todo::Ptr todo(new Todo());
todo->setUid(summary.left(1) + now.toString("yyyyMMddhhmmsszzz"));
todo->setDtStart(QDateTime(startDate));
todo->setDtStart(startDateTime);
todo->setDescription(description);
todo->setSummary(summary);
todo->setAllDay(allDayFlg);
todo->setLocation(location);
m_calendar->addTodo(todo);
bool success = m_cal_storage->save();
qDebug() << "Storage save: " << success;
......
......@@ -46,7 +46,7 @@ public:
void setName(QString calendarName);
public Q_SLOTS:
void addTask(QString summary, QString description, QDate startDate);
void addTask(QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location);
Q_SIGNALS:
void memorycalendarChanged();
......
......@@ -21,7 +21,6 @@
#include "mobilecalendarconfig.h"
#include "localcalendar.h"
#include "todosmodel.h"
#include <QQmlEngine>
#include <QtQml/qqml.h>
......
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