mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
81 lines
1.5 KiB
C
81 lines
1.5 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/TaskItem.h"
|
||
|
#include "using.h"
|
||
|
#include <memory>
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace mirai
|
||
|
{
|
||
|
|
||
|
class BaseResource;
|
||
|
|
||
|
struct EventData {
|
||
|
std::string description;
|
||
|
Date date;
|
||
|
Time startTime;
|
||
|
Time endTime;
|
||
|
Tags tags;
|
||
|
std::vector<TaskItemData> tasks;
|
||
|
};
|
||
|
|
||
|
class Day;
|
||
|
|
||
|
class Event
|
||
|
{
|
||
|
private:
|
||
|
public:
|
||
|
Event(BaseResource *source, Day *parent, const EventData &data);
|
||
|
|
||
|
Event &operator=(const EventData &newData)
|
||
|
{
|
||
|
data = newData;
|
||
|
onChange();
|
||
|
return *this;
|
||
|
};
|
||
|
|
||
|
void setText(const std::string &text);
|
||
|
void setStartTime(const Time &time);
|
||
|
void setEndTime(const Time &time);
|
||
|
|
||
|
TaskItem *createTask(const TaskItemData &taskData);
|
||
|
void deleteTask(const TaskItem &taskToDelete);
|
||
|
std::vector<std::unique_ptr<TaskItem>> *tasks();
|
||
|
|
||
|
const std::string &getText() const;
|
||
|
const Date &getDate() const;
|
||
|
const Time &getStartTime() const;
|
||
|
const Time &getEndTime() const;
|
||
|
const Tags &getTags() const;
|
||
|
bool hasTag(const std::string &tag) const;
|
||
|
|
||
|
int id() const
|
||
|
{
|
||
|
return id_;
|
||
|
}
|
||
|
|
||
|
Day *day()
|
||
|
{
|
||
|
return day_;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
void onChange();
|
||
|
|
||
|
static int nextId;
|
||
|
int id_ = nextId++;
|
||
|
Day *day_;
|
||
|
EventData data;
|
||
|
std::vector<std::unique_ptr<TaskItem>> tasks_;
|
||
|
BaseResource *source_;
|
||
|
};
|
||
|
} // namespace mirai
|