mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 01:33:19 +00:00
first commit
This commit is contained in:
commit
3e7d8b4b70
43 changed files with 2681 additions and 0 deletions
56
src/core/TasksView.cpp
Normal file
56
src/core/TasksView.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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 "TasksView.h"
|
||||
|
||||
namespace mirai {
|
||||
|
||||
|
||||
TasksView::TasksView(std::shared_ptr<std::vector<TasksFile>> files) : files(files) {
|
||||
update();
|
||||
}
|
||||
|
||||
TaskItem& TasksView::operator[](int index) {
|
||||
return *(tasksToShow.at(index));
|
||||
}
|
||||
|
||||
int TasksView::count() const { return tasksToShow.size(); }
|
||||
|
||||
void TasksView::update() {
|
||||
tasksToShow.clear();
|
||||
for (auto& file : *files) {
|
||||
for (auto& task : file.getTasks()) {
|
||||
if (tagsFilter.size() != 0
|
||||
&& std::find_if(tagsFilter.begin(), tagsFilter.end(), [&](const std::string& tag) {
|
||||
return task->getText().find(tag) != std::string::npos;
|
||||
}) == tagsFilter.end())
|
||||
continue;
|
||||
tasksToShow.push_back(task.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TasksView::addTagFilter(const std::string& tag) {
|
||||
tagsFilter.push_back(tag);
|
||||
update();
|
||||
}
|
||||
|
||||
void TasksView::removeTagFilter(const std::string& tag) {
|
||||
tagsFilter.erase(std::remove_if(tagsFilter.begin(), tagsFilter.end(), [&] (const auto& tagInFilter){
|
||||
return tag == tagInFilter;
|
||||
}));
|
||||
update();
|
||||
}
|
||||
|
||||
void TasksView::removeFilters() {
|
||||
tagsFilter.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
const std::vector<std::string>& TasksView::getActiveTagsFilter() {
|
||||
return tagsFilter;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue