/* * 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 "Event.h" #include "Task.h" #include namespace mirai { int Event::id() const { return eventData_.id; } int Event::sourceId() const { return data_->id; } std::string Event::title() const { return eventData_.title; } Time Event::startsAt() const { return eventData_.startsAt; } Time Event::endsAt() const { return eventData_.endsAt; } std::vector Event::queryTasks() const { auto tasksData = data_->getTasksByEventId(eventData_.id); std::vector tasks; std::transform( tasksData.begin(), tasksData.end(), std::back_inserter(tasks), [&](const TaskData &taskData) { return Task{data_, taskData}; } ); return tasks; } void Event::setTitle(const std::string &newTitle) { data_->updateEvent(id(), {.title = newTitle}); } void Event::setDay(const Day &day) { data_->updateEvent(id(), {.dayId = day.id()}); } void Event::setStartTime(const Time &time) { data_->updateEvent(id(), {.startsAt = time}); } void Event::setEndTime(const Time &time) { data_->updateEvent(id(), {.endsAt = time}); } } // namespace mirai