mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-04 02:33:19 +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
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* 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 "Mirai.h"
|
||||
#include "TaskItem.h"
|
||||
#include "cpp-utils/debug.h"
|
||||
#include "utils.h"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
namespace mirai
|
||||
{
|
||||
|
||||
void Mirai::loadResource(std::unique_ptr<BaseResource> &&resource)
|
||||
{
|
||||
resource->load();
|
||||
resources.push_back(std::move(resource));
|
||||
reloadTags();
|
||||
};
|
||||
|
||||
void Mirai::unloadAllResources()
|
||||
{
|
||||
resources.clear();
|
||||
}
|
||||
|
||||
void Mirai::save()
|
||||
{
|
||||
for (auto &resource : resources) {
|
||||
if (resource->isDirty()) {
|
||||
resource->save();
|
||||
resource->setDirty(false);
|
||||
}
|
||||
}
|
||||
reloadTags();
|
||||
}
|
||||
|
||||
void Mirai::removeTask(const TaskItem *taskItem)
|
||||
{
|
||||
for (auto &resource : resources) {
|
||||
resource->removeTask(taskItem);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<BaseResource>> &Mirai::getResources()
|
||||
{
|
||||
return resources;
|
||||
}
|
||||
|
||||
std::optional<std::reference_wrapper<BaseResource>> Mirai::getResourceByName(const std::string &name
|
||||
)
|
||||
{
|
||||
auto resourceIterator =
|
||||
std::ranges::find_if(resources, [&](const std::unique_ptr<BaseResource> &resource) {
|
||||
return resource->getName() == name;
|
||||
});
|
||||
|
||||
if (resourceIterator == resources.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return *(resourceIterator->get());
|
||||
}
|
||||
|
||||
const std::vector<std::string> &Mirai::getTags()
|
||||
{
|
||||
return tags;
|
||||
}
|
||||
|
||||
void Mirai::reloadTags()
|
||||
{
|
||||
cpputils::debug::Timer reloadingTagsDuration;
|
||||
tags.clear();
|
||||
for (auto &resource : resources) {
|
||||
for (auto &task : resource->getTasks()) {
|
||||
for (auto &tag : task->getTags()) {
|
||||
if (!vectorUtils::contains(tags, tag)) {
|
||||
tags.push_back(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
reloadingTagsDuration.printTimeElapsed("ReloadingTags");
|
||||
}
|
||||
|
||||
} // namespace mirai
|
Loading…
Add table
Add a link
Reference in a new issue