QtNovelUI/WordsIDE/appcore.h

151 lines
3.3 KiB
C
Raw Normal View History

2022-11-18 23:47:32 +00:00
#ifndef APPCORE_H
#define APPCORE_H
#include <QObject>
#include <libConfig.h>
#include <libParse.h>
#include <libProjectManager.h>
class MainWindow;
namespace MakeTools {
class StoryTool;
2022-12-31 13:05:58 +00:00
class DocsManager;
}
2022-11-18 23:47:32 +00:00
namespace Core {
2022-11-25 01:18:54 +00:00
class Extension;
class AppCore;
2022-11-18 23:47:32 +00:00
enum class Scale
{
Global,
Project,
File,
};
2022-11-25 01:26:52 +00:00
/**
* @brief
*/
class ExtensionFactory
{
public:
2022-11-25 01:18:54 +00:00
virtual ~ExtensionFactory() = default;
/**
* @brief
* @param core
* @return
*/
2022-11-25 01:18:54 +00:00
virtual Extension* 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;
/**
* @brief
* @return
*/
virtual QString extensionName() const = 0;
2022-11-25 01:18:54 +00:00
};
2022-11-25 01:26:52 +00:00
/**
* @brief
*/
2022-11-25 01:18:54 +00:00
class Extension
{
public:
virtual ~Extension() = default;
/**
* @brief
* @return
*/
virtual ExtensionFactory* factory() const = 0;
/**
* @brief
* @param suffix
*/
virtual void resetProcsType(const QString &suffix) = 0;
2022-11-25 01:18:54 +00:00
/**
* @brief
* @param configs
*/
2022-11-29 03:47:12 +00:00
virtual void reloadConfigrations(QList<Config::Configration*> configs) = 0;
2022-11-25 01:18:54 +00:00
};
2022-11-25 01:26:52 +00:00
/**
* @brief
*/
2022-11-25 01:18:54 +00:00
class FileExtensionFactory : public ExtensionFactory
{
public:
virtual ~FileExtensionFactory() = default;
/**
* @brief
* @return
*/
2022-11-25 01:32:42 +00:00
virtual QList<QString> suffixPeers() const = 0;
};
2022-12-31 13:05:58 +00:00
/**
* @brief
*/
class AppCore : public QObject
{
public:
AppCore(MainWindow *win, QObject *parent = nullptr);
2022-11-18 23:47:32 +00:00
virtual ~AppCore() = default;
2022-12-31 13:05:58 +00:00
/**
* @brief
*/
void save();
2022-12-31 13:05:58 +00:00
/**
* @brief
* @return
*/
Config::Configration * globalConfig() const;
void setCurrentProject(Project::ProjectManager *project);
Project::ProjectManager* currentProject() const;
2022-11-18 23:47:32 +00:00
QList<Config::Configration*> getConfigs(QList<Scale> types) const;
Parse::Result::ParseCore * parseCore() const;
QList<Core::FileExtensionFactory*> extensions(const QString &suffix = QString()) const;
2022-12-31 13:05:58 +00:00
MakeTools::StoryTool *getMakeCore() const;
2022-12-31 13:05:58 +00:00
MakeTools::DocsManager *getDocsManager() const;
private:
2022-11-29 03:47:12 +00:00
MainWindow *const views_holder;
Config::Configration *const global_config;
Project::ProjectManager * current_project;
QList<Core::FileExtensionFactory*> extensions_list;
2022-11-18 23:47:32 +00:00
2022-12-31 13:05:58 +00:00
MakeTools::StoryTool *const makes_core;
MakeTools::DocsManager *const docs_manager;
2022-11-18 23:47:32 +00:00
};
}
#endif // APPCORE_H