mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 18:23:19 +00:00
76 lines
1.4 KiB
C++
76 lines
1.4 KiB
C++
/*
|
|
* Mirai. Copyright (C) 2024 Vyn
|
|
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
|
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
|
*/
|
|
|
|
#include "task.h"
|
|
#include "data_provider.h"
|
|
#include "utils.h"
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace mirai
|
|
{
|
|
|
|
int task::id() const
|
|
{
|
|
return task_.id;
|
|
}
|
|
|
|
int task::source_id() const
|
|
{
|
|
return data_->id;
|
|
}
|
|
|
|
std::string task::title() const
|
|
{
|
|
return task_.title;
|
|
}
|
|
|
|
mirai::task_state task::state() const
|
|
{
|
|
return task_.state;
|
|
}
|
|
|
|
bool task::checked() const
|
|
{
|
|
return task_.state == mirai::DONE;
|
|
}
|
|
|
|
bool task::has_due_date() const
|
|
{
|
|
return task_.due_date.has_value();
|
|
}
|
|
|
|
std::optional<class date> task::due_date() const
|
|
{
|
|
if (!task_.due_date.has_value()) {
|
|
return std::nullopt;
|
|
}
|
|
return task_.due_date.value();
|
|
}
|
|
|
|
void task::set_title(const std::string &newTitle)
|
|
{
|
|
data_->update_task(id(), {.title = newTitle});
|
|
}
|
|
|
|
void task::set_date(const date &date)
|
|
{
|
|
auto emptyEventId = std::optional<std::optional<int>>(std::optional<int>(std::nullopt));
|
|
data_->update_task(id(), {.due_date = date});
|
|
}
|
|
|
|
void task::unschedule()
|
|
{
|
|
auto emptyId = std::optional<std::optional<int>>(std::optional<int>(std::nullopt));
|
|
data_->update_task(id(), {.due_date = std::nullopt});
|
|
}
|
|
|
|
void task::set_checked(bool checked)
|
|
{
|
|
data_->update_task(id(), {.state = checked ? DONE : TODO});
|
|
}
|
|
|
|
} // namespace mirai
|