Support multiple files

This commit is contained in:
Vyn 2024-04-14 14:11:41 +02:00
parent f8f49233dc
commit 689eea07a7
22 changed files with 528 additions and 131 deletions

View file

@ -5,68 +5,86 @@
*/
#include "TaskItem.h"
#include "cpp-utils/vector.h"
#include "TasksFile.h"
#include "core/utils.h"
#include <iostream>
namespace mirai
{
TaskItem::TaskItem(TasksFile *parent, TaskItemData data) : parent(parent), data(data)
{
}
void TaskItem::markAsDone()
{
state = DONE;
data.state = DONE;
onChange();
}
void TaskItem::markAsUndone()
{
state = TODO;
data.state = TODO;
onChange();
}
void TaskItem::setDate(const std::string &date)
{
this->date = date;
this->data.date = date;
onChange();
}
void TaskItem::setText(const std::string &text)
{
this->text = text;
this->data.text = text;
onChange();
}
const std::string &TaskItem::getText() const
{
return text;
return data.text;
}
const TaskItemState &TaskItem::getState() const
{
return state;
return data.state;
}
const std::string &TaskItem::getDate() const
{
return date;
return data.date;
}
const std::string &TaskItem::getStartTime() const
{
return startTime;
return data.startTime;
}
const std::string &TaskItem::getEndTime() const
{
return endTime;
return data.endTime;
}
const Tags &TaskItem::getTags() const
{
return tags;
return data.tags;
}
bool TaskItem::hasDate() const
{
return isDate(date);
return isDate(data.date);
}
bool TaskItem::hasTag(const std::string &tag) const
{
return vectorUtils::contains(tags, tag);
return vectorUtils::contains(data.tags, tag);
}
void TaskItem::onChange()
{
if (parent) {
parent->setDirty(true);
}
}
} // namespace mirai