mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
67 lines
1.3 KiB
C
67 lines
1.3 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
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include "mirai-core/DateTime.h"
|
||
|
#include "mirai-core/Event.h"
|
||
|
#include "mirai-core/TaskItem.h"
|
||
|
#include "using.h"
|
||
|
#include <memory>
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace mirai
|
||
|
{
|
||
|
|
||
|
class BaseResource;
|
||
|
|
||
|
struct DayData {
|
||
|
Date date;
|
||
|
std::vector<EventData> events;
|
||
|
std::vector<TaskItemData> tasks;
|
||
|
};
|
||
|
|
||
|
class Day
|
||
|
{
|
||
|
public:
|
||
|
Day(BaseResource *source, const DayData &data);
|
||
|
void setDate(const Date &date);
|
||
|
|
||
|
Event *createEvent(const EventData &eventData);
|
||
|
TaskItem *createTask(const TaskItemData &taskData);
|
||
|
void deleteTask(const TaskItem &taskToDelete);
|
||
|
void deleteEvent(const Event &eventToDelete);
|
||
|
std::vector<std::unique_ptr<Event>> *events();
|
||
|
std::vector<std::unique_ptr<TaskItem>> *tasks();
|
||
|
|
||
|
const Date &getDate() const;
|
||
|
|
||
|
Event *getEventById(int eventId)
|
||
|
{
|
||
|
for (auto &event : events_) {
|
||
|
if (event->id() == eventId) {
|
||
|
return event.get();
|
||
|
}
|
||
|
}
|
||
|
return nullptr;
|
||
|
}
|
||
|
|
||
|
BaseResource *source()
|
||
|
{
|
||
|
return source_;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
void onChange();
|
||
|
|
||
|
BaseResource *source_;
|
||
|
std::vector<std::unique_ptr<Event>> events_;
|
||
|
std::vector<std::unique_ptr<TaskItem>> tasks_;
|
||
|
DayData data_;
|
||
|
};
|
||
|
} // namespace mirai
|