Add Source creation/edition + Add missing edit forms for tasks and events

This commit is contained in:
Vyn 2024-11-01 13:43:45 +01:00
parent f1ac8a42d1
commit a15c23bb21
24 changed files with 358 additions and 205 deletions

View file

@ -1,29 +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
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
namespace mirai
{
class ConfigImpl;
class Config
{
public:
Config(const std::string &path);
~Config();
std::vector<std::string> sources() const;
private:
std::unique_ptr<ConfigImpl> impl_;
};
} // namespace mirai

View file

@ -19,7 +19,12 @@ class Mirai
{
public:
void loadSource(std::unique_ptr<DataProvider> &&resource);
Mirai(const std::string &configFilePath);
void addSource(
const std::string &name, const std::string &type, std::unique_ptr<DataProvider> &&source
);
void editSource(int id, const std::string &name, const std::string &path);
void deleteSource(int id);
void unloadAllSources();
void save();
std::optional<std::reference_wrapper<DataProvider>> getSourceByName(const std::string &name);
@ -31,7 +36,9 @@ class Mirai
Source *getSourceById(int id);
private:
void loadConfig(const std::string &path);
void saveConfig();
std::vector<std::unique_ptr<Source>> sources_;
// std::vector<std::string> tags_;
std::string configPath_;
};
} // namespace mirai

View file

@ -31,13 +31,15 @@ struct createEventParams {
};
struct SourceConstructor {
std::string name;
DataProvider *sourceDataProvider;
};
class Source
{
public:
Source(SourceConstructor params) : data(params.sourceDataProvider)
Source(SourceConstructor params)
: data(params.sourceDataProvider), name_(params.name), type_("FileSystemMarkdown")
{
}
@ -56,6 +58,8 @@ class Source
std::string type() const;
DataProvider *dataProvider();
void setName(const std::string &name);
void createTask(const createTaskParams &task);
void removeTask(const Task &task);
std::optional<Task> getTaskById(int taskId);
@ -86,6 +90,8 @@ class Source
return nextId++;
}
std::string name_;
std::string type_;
DataProvider *data;
};
} // namespace mirai