QtNovelUI/WordsIDE/DocsManager.h

197 lines
5.3 KiB
C
Raw Normal View History

2022-12-31 13:05:58 +00:00
#ifndef DOCSMANAGER_H
#define DOCSMANAGER_H
2022-11-17 08:26:05 +00:00
#include "ContentPresent.h"
2022-11-17 08:26:05 +00:00
#include <QHash>
#include <QObject>
#include <StoryTool.h>
namespace MakeTools {
2023-02-26 14:44:00 +00:00
class CompileFeature : public QObject
{
Q_OBJECT
public:
explicit CompileFeature(QObject *parent = nullptr);
virtual ~CompileFeature() = default;
/**
* @brief
* @return
*/
virtual QString getText() const = 0;
signals:
/**
* @brief
* @param filePath
*/
void dataChanged(const QString &filePath);
};
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
2022-11-17 08:26:05 +00:00
*/
class ContentPresent
2022-11-17 08:26:05 +00:00
{
public:
2023-02-26 14:44:00 +00:00
virtual ~ContentPresent() = default;
enum class Feature{
HighLight = 0x01,
Compile = 0x02,
};
Q_DECLARE_FLAGS(Features, Feature)
virtual Features features() = 0;
2023-02-26 14:44:00 +00:00
/**
* @brief
* @return
*/
virtual QList<QString> suffixes() const = 0;
/**
* @brief
* @param target
* @param name
* @param suffix
* @return
*/
virtual std::tuple<bool, QString> create(const QDir& target,
const QString &name,
const QString &suffix) = 0;
/**
* @brief
* @return
*/
virtual ContentPresent* newInst() const = 0;
/**
* @brief widget
* @return
*/
virtual QWidget* widget() const = 0;
/**
* @brief
* @param core
* @param name
*/
virtual void applySetting(const QString &name, Core::AppCore *core = nullptr) = 0;
/**
* @brief
* @return
*/
virtual QString name() const = 0;
/**
* @brief 使
* @param target_file info
*/
virtual void load(const QFileInfo &target_file) = 0;
/**
* @brief
* @param path
*/
virtual void saveAs(const QString &path = QString()) = 0;
/**
* @brief
* @return
*/
virtual QString relativeTargetPath(const QDir &base) const = 0;
2023-02-26 14:44:00 +00:00
/**
* @brief
* @return
*/
virtual QString absoluteTargetPath() const = 0;
2023-02-26 14:44:00 +00:00
/**
* @brief
* @return
*/
virtual bool isModified() const = 0;
2022-11-17 08:26:05 +00:00
2023-02-26 14:44:00 +00:00
/**
* @brief
* @param path
*/
virtual void jumpTo(const QList<QString> &path) = 0;
2022-11-17 08:26:05 +00:00
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ContentPresent::Features);
2022-11-17 08:26:05 +00:00
enum class SensitiveType
{
DoNothing,
CompileAtChanged
};
/**
* @brief
*/
2023-03-10 13:01:19 +00:00
// class DocsManager : public QObject
// {
// Q_OBJECT
// public:
// /**
// * @brief 内容自动构建和管理核心
// * @param tool
// */
// DocsManager(StoryTool *tool, Core::AppCore *host, MainWindow *views);
// /**
// * @brief 保存当前所有文档内容
// */
// void saveAll() const;
// void closeAll();
// /**
// * @brief 文档打开状态查询
// * @param target
// * @return
// */
// bool activedContains(const QFileInfo &target) const;
// /**
// * @brief 获取文档内存实例
// * @param child_view
// * @return
// */
// ContentPresent *queryTextComponent(const QWidget *child_view) const;
// /**
// * @brief 获取文档内存实例
// * @param target
// * @return
// */
// ContentPresent *queryTextComponent(const QFileInfo &target) const;
// /**
// * @brief 关闭文档内存实例,关闭之前保存内容
// * @param target
// */
// void closeTextComponent(const QFileInfo &target);
// /**
// * @brief 打开指定路径的文档
// * @param src
// * @param name
// */
// void openTextDocument(const QString &src, const QString &name);
// void addPerceptionList(ContentPresent *ins, SensitiveType type = SensitiveType::CompileAtChanged);
// void addProcTrigger(std::function<void()> exc);
// private:
// Core::AppCore *const host_core;
// MainWindow *const views_holder;
// StoryTool *const make_core;
// QHash<QString, ContentPresent*> sourcecode_map;
// QHash<QString, ContentPresent*> plaintext_map;
// QList<std::function<void()>> trigger_list;
// void recompile(const QString &file_path, const QString &doc_name);
// };
2022-11-17 08:26:05 +00:00
}
2022-12-31 13:05:58 +00:00
#endif // DOCSMANAGER_H