119 lines
2.7 KiB
C++
119 lines
2.7 KiB
C++
#ifndef APPCORE_H
|
|
#define APPCORE_H
|
|
|
|
#include <QObject>
|
|
#include <libConfig.h>
|
|
#include <libParse.h>
|
|
#include <libProjectManager.h>
|
|
|
|
class MainWindow;
|
|
|
|
namespace MakeTools {
|
|
class StoryTool;
|
|
class SensitiveCore;
|
|
}
|
|
|
|
namespace Core {
|
|
class FileExtensionFactory;
|
|
class AppCore;
|
|
|
|
enum class Scale
|
|
{
|
|
Global,
|
|
Project,
|
|
File,
|
|
};
|
|
|
|
class FileExtension
|
|
{
|
|
public:
|
|
virtual ~FileExtension() = default;
|
|
|
|
/**
|
|
* @brief 获取唯一的关联工厂类
|
|
* @return
|
|
*/
|
|
virtual FileExtensionFactory* factory() const = 0;
|
|
|
|
/**
|
|
* @brief 载入指定的配置端口实例
|
|
* @param configs
|
|
*/
|
|
virtual void reload(QList<Config::Configration*> configs) = 0;
|
|
|
|
};
|
|
|
|
class FileExtensionFactory
|
|
{
|
|
public:
|
|
virtual ~FileExtensionFactory() = default;
|
|
|
|
/**
|
|
* @brief 生成新插件内容实例
|
|
* @param core
|
|
* @return
|
|
*/
|
|
virtual FileExtension* newInstance(AppCore *core) = 0;
|
|
|
|
/**
|
|
* @brief 获取所有指定的配置端口类型
|
|
* @return
|
|
*/
|
|
virtual QList<Core::Scale> configs() const = 0;
|
|
|
|
/**
|
|
* @brief getPanel 获取配置面板,配置内容
|
|
* @param config
|
|
* @return
|
|
*/
|
|
virtual QWidget* getNewPanel(Config::Configration* config) = 0;
|
|
|
|
virtual QString extensionName() const = 0;
|
|
|
|
/**
|
|
* @brief 可以处理的文件类型
|
|
* @return
|
|
*/
|
|
virtual QString suffixPeers() const = 0;
|
|
};
|
|
|
|
|
|
class AppCore : public QObject
|
|
{
|
|
public:
|
|
AppCore(MainWindow *win, QObject *parent = nullptr);
|
|
virtual ~AppCore() = default;
|
|
|
|
void save();
|
|
|
|
Config::Configration * globalConfig() const;
|
|
|
|
void setCurrentProject(Project::ProjectManager *project);
|
|
Project::ProjectManager* currentProject() const;
|
|
QList<Config::Configration*> getConfigs(QList<Scale> types) const;
|
|
Parse::Result::ParseCore * parseCore() const;
|
|
|
|
QList<Core::FileExtensionFactory*> extensions(const QString &suffix = QString()) const;
|
|
|
|
MakeTools::StoryTool *getMake_tool() const;
|
|
|
|
MakeTools::SensitiveCore *getFramework() const;
|
|
|
|
|
|
void openTextDocument(const QString &src, const QString &name);
|
|
|
|
private:
|
|
MainWindow *const views;
|
|
Config::Configration *const global_config;
|
|
Project::ProjectManager * current_project;
|
|
QList<Core::FileExtensionFactory*> extensions_list;
|
|
Parse::Result::ParseCore *const parse_core;
|
|
|
|
MakeTools::StoryTool *const make_tool;
|
|
MakeTools::SensitiveCore *const framework;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // APPCORE_H
|