mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 18:23: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
92
lib/mirai-core/Mirai.cpp
Normal file
92
lib/mirai-core/Mirai.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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 "mirai-core/Config.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); // TODO REWORK
|
||||
}
|
||||
}
|
||||
|
||||
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;*/ // TODO REWORK
|
||||
/*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