mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 01:33:19 +00:00
Refactor TasksView, Mirai instance doesn't depend on it anymore
This commit is contained in:
parent
d1a4858504
commit
841c87752f
7 changed files with 39 additions and 57 deletions
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "TaskItem.h"
|
||||
#include "TasksFile.h"
|
||||
#include "TasksView.h"
|
||||
#include "TodoMd.h"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
@ -33,22 +32,12 @@ class Mirai
|
|||
std::optional<std::reference_wrapper<TasksFile>> getFileByPath(const std::string &path);
|
||||
|
||||
std::vector<std::unique_ptr<TasksFile>> &getFiles();
|
||||
std::weak_ptr<TasksView> getTasks();
|
||||
const std::vector<std::string> &getTags();
|
||||
|
||||
void reloadTags();
|
||||
|
||||
private:
|
||||
// The `TasksFile`s are shared to the views, their lifetime can outlive
|
||||
// this (Mirai) object
|
||||
// because we can't control if the caller will keep the main object alive.
|
||||
std::shared_ptr<std::vector<std::unique_ptr<TasksFile>>> files =
|
||||
std::make_shared<std::vector<std::unique_ptr<TasksFile>>>();
|
||||
|
||||
// We keep a vector of shared_ptr because we need the ref counting mechanism to know
|
||||
// if we have to remove the view (not used) or tell the view to update() on
|
||||
// some changes.
|
||||
std::vector<std::shared_ptr<TasksView>> views;
|
||||
std::vector<std::unique_ptr<TasksFile>> files = std::vector<std::unique_ptr<TasksFile>>();
|
||||
std::vector<std::string> tags;
|
||||
};
|
||||
} // namespace mirai
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue