Commit ea3fe161 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos
Browse files

Proper set of start time when all day is set

parent e660cfa6
......@@ -52,7 +52,7 @@ void LocalCalendar::setName(QString calendarName)
if (m_name != calendarName) {
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZoneId()));
FileStorage::Ptr storage(new FileStorage(calendar));
QString fullPathName = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/" + calendarName + "_mobile_calendar" ; //TODO: Consider changing to GenericDataLocation if calendar should be shared with other apps
QString fullPathName = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/" + calendarName + "_mobile_calendar" ;
QFile calendarFile(fullPathName);
storage->setFileName(fullPathName);
......@@ -94,15 +94,31 @@ void LocalCalendar::setCalendarstorage(FileStorage::Ptr calendarStorage)
}
}
void LocalCalendar::addTask(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)
{
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::Ptr todo;
if (uid == "") {
todo = Todo::Ptr(new Todo());
todo->setUid(summary.left(1) + now.toString("yyyyMMddhhmmsszzz"));
}
else {
todo = m_calendar->todo(uid);
todo->setUid(uid);
}
QDateTime startDateTime;
if(allDayFlg) {
startDateTime = QDateTime(startDate);
}
else {
startDateTime = QDateTime(startDate, QTime(startHour, startMinute, 0, 0), QTimeZone::systemTimeZone());
}
todo->setDtStart(startDateTime);
todo->setDescription(description);
todo->setSummary(summary);
......@@ -111,11 +127,16 @@ void LocalCalendar::addTask(QDate startDate, QString summary, QString descriptio
m_calendar->addTodo(todo);
bool success = m_cal_storage->save();
qDebug() << "Storage save: " << success;
emit todoAdded();
qDebug() << "New todo has been saved";
qDebug() << "Storage save: " << success;
qDebug() << "Todo has been saved";
}
void LocalCalendar::deleteTask(QString uid) {
qDebug() << "Deleting task: " << uid;
Todo::Ptr todo = m_calendar->todo(uid);
m_calendar->deleteTodo(todo);
bool success = m_cal_storage->save();
qDebug() << "Task deleted? " << success;
}
......@@ -46,13 +46,13 @@ public:
void setName(QString calendarName);
public Q_SLOTS:
void addTask(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);
void deleteTask(QString uid);
Q_SIGNALS:
void memorycalendarChanged();
void calendarstorageChanged();
void nameChanged();
void todoAdded();
private:
MemoryCalendar::Ptr m_calendar;
......
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