2022-11-17 08:26:05 +00:00
|
|
|
#ifndef SENSITIVECORE_H
|
|
|
|
#define SENSITIVECORE_H
|
|
|
|
|
|
|
|
#include <QHash>
|
|
|
|
#include <QObject>
|
|
|
|
#include <StoryTool.h>
|
|
|
|
|
|
|
|
namespace MakeTools {
|
|
|
|
/**
|
|
|
|
* @brief 变化的文本视图
|
|
|
|
*/
|
|
|
|
class VariedTextView : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit VariedTextView(const QFileInfo &file, QObject *parent=nullptr);
|
|
|
|
virtual ~VariedTextView() = default;
|
|
|
|
|
|
|
|
virtual QWidget* textView() const = 0;
|
|
|
|
|
|
|
|
QString filePath() const;
|
|
|
|
void save() const;
|
|
|
|
|
|
|
|
virtual void reset(Parse::Result::DocCore *syntax_base) = 0;
|
|
|
|
virtual QString textContent() const = 0;
|
|
|
|
|
|
|
|
virtual void textContentReset(const QString &value) = 0;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void dataChanged(const QString &filePath);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QFileInfo source_x;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class SensitiveType
|
|
|
|
{
|
|
|
|
DoNothing,
|
|
|
|
CompileAtChanged
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 自动编译管理框架
|
|
|
|
*/
|
|
|
|
class SensitiveCore : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
SensitiveCore(StoryTool *tool);
|
|
|
|
|
|
|
|
void saveAll() const;
|
|
|
|
|
|
|
|
bool contains(const QFileInfo &target) const;
|
2022-11-17 08:52:37 +00:00
|
|
|
VariedTextView * queryComponent(const QFileInfo &target) const;
|
|
|
|
|
2022-11-17 08:26:05 +00:00
|
|
|
void addPerceptionList(VariedTextView *ins, SensitiveType type = SensitiveType::CompileAtChanged);
|
|
|
|
void addProcTrigger(std::function<void()> exc);
|
|
|
|
|
|
|
|
private:
|
|
|
|
StoryTool *const make_core;
|
|
|
|
QHash<QString, VariedTextView*> sourcecode_map;
|
|
|
|
QHash<QString, VariedTextView*> plaintext_map;
|
|
|
|
QList<std::function<void()>> trigger_list;
|
|
|
|
|
|
|
|
void recompile(const QString &file_path);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SENSITIVECORE_H
|