mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 17:23:20 +00:00
Switch from Qt6 to Slint
This commit is contained in:
parent
f8be14bcf8
commit
63bf267a22
107 changed files with 27532 additions and 2896 deletions
99
lib/mirai-core/Event.cpp
Normal file
99
lib/mirai-core/Event.cpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* 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 "BaseResource.h"
|
||||
#include "mirai-core/TaskItem.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace mirai
|
||||
{
|
||||
|
||||
Event::Event(BaseResource *source, Day *parent, const EventData &data)
|
||||
: source_(source), day_(parent), data(data)
|
||||
{
|
||||
}
|
||||
|
||||
void Event::setText(const std::string &text)
|
||||
{
|
||||
this->data.description = text;
|
||||
onChange();
|
||||
}
|
||||
|
||||
const std::string &Event::getText() const
|
||||
{
|
||||
return data.description;
|
||||
}
|
||||
|
||||
const Date &Event::getDate() const
|
||||
{
|
||||
return data.date;
|
||||
}
|
||||
|
||||
const Time &Event::getStartTime() const
|
||||
{
|
||||
return data.startTime;
|
||||
}
|
||||
|
||||
const Time &Event::getEndTime() const
|
||||
{
|
||||
return data.endTime;
|
||||
}
|
||||
|
||||
const Tags &Event::getTags() const
|
||||
{
|
||||
return data.tags;
|
||||
}
|
||||
|
||||
bool Event::hasTag(const std::string &tag) const
|
||||
{
|
||||
return vectorUtils::contains(data.tags, tag);
|
||||
}
|
||||
|
||||
TaskItem *Event::createTask(const TaskItemData &taskData)
|
||||
{
|
||||
auto task = std::make_unique<TaskItem>(source_, day_, taskData);
|
||||
mirai::TaskItem *taskPtr = task.get();
|
||||
tasks_.push_back(std::move(task));
|
||||
onChange();
|
||||
return taskPtr;
|
||||
}
|
||||
|
||||
void Event::deleteTask(const TaskItem &taskToDelete)
|
||||
{
|
||||
tasks_.erase(std::remove_if(
|
||||
tasks_.begin(), tasks_.end(),
|
||||
[&](const std::unique_ptr<TaskItem> &task) {
|
||||
return task->id() == taskToDelete.id();
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<TaskItem>> *Event::tasks()
|
||||
{
|
||||
return &tasks_;
|
||||
}
|
||||
|
||||
void Event::setStartTime(const Time &time)
|
||||
{
|
||||
data.startTime = time;
|
||||
onChange();
|
||||
}
|
||||
|
||||
void Event::setEndTime(const Time &time)
|
||||
{
|
||||
data.endTime = time;
|
||||
onChange();
|
||||
}
|
||||
|
||||
void Event::onChange()
|
||||
{
|
||||
source_->setDirty(true);
|
||||
}
|
||||
|
||||
int Event::nextId = 0;
|
||||
|
||||
} // namespace mirai
|
Loading…
Add table
Add a link
Reference in a new issue