2023-03-05 14:32:20 +00:00
|
|
|
|
#ifndef VISUABLE_PROJECT_CONTROLLER
|
|
|
|
|
#define VISUABLE_PROJECT_CONTROLLER
|
|
|
|
|
|
|
|
|
|
#include "appcore.h"
|
2023-03-10 13:01:19 +00:00
|
|
|
|
#include "route.h"
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <libProjectManager.h>
|
|
|
|
|
#include <commandsdispatcher.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Components {
|
|
|
|
|
|
|
|
|
|
class PresentContainer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~PresentContainer() = default;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 添加内容展示实例
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
|
|
|
|
virtual void append(MakeTools::ContentPresent *ins) = 0;
|
|
|
|
|
/**
|
|
|
|
|
* @brief 激活内容展示实例
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
|
|
|
|
virtual void active(MakeTools::ContentPresent *ins) = 0;
|
|
|
|
|
/**
|
|
|
|
|
* @brief 移除内容展示实例
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
|
|
|
|
virtual void remove(MakeTools::ContentPresent *ins) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 文档管理器,根据项目配置文件,打开、查询、关闭文档实例
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
class DocumentsManager : public Schedule::AccessibleObject
|
2023-03-05 14:32:20 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
2023-03-10 13:01:19 +00:00
|
|
|
|
DocumentsManager(Core::AppCore *src, Project::ProjectManager *project, PresentContainer *con);
|
|
|
|
|
virtual ~DocumentsManager() = default;
|
|
|
|
|
|
|
|
|
|
Project::ProjectManager* projectManager() const;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 提供完整路径创建新包
|
|
|
|
|
* @param path [/x_name]+
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void newPackage(const Core::Route &link);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 提供父节点Index,创建新包
|
|
|
|
|
* @param group
|
|
|
|
|
* @param name
|
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void newPackage(const Core::Route &group, const QString &name);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 获取支持的文件类型
|
|
|
|
|
* @return {txt, storychain, ……}
|
|
|
|
|
*/
|
|
|
|
|
QList<QString> fileTypes() const;
|
|
|
|
|
/**
|
|
|
|
|
* @brief 在指定的包节点下,创建指定类型的新文件
|
|
|
|
|
* @param group 包节点
|
|
|
|
|
* @param name 文件名称
|
|
|
|
|
* @param suffix 通过后缀名,指定文件类型
|
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void newFile(const Core::Route &group_path, const QString &name, const QString &suffix);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
2023-03-10 13:01:19 +00:00
|
|
|
|
QModelIndex converter(const Core::Route &path);
|
|
|
|
|
Core::Route converter(const QModelIndex &index);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 移除指定节点(必须非根节点)
|
|
|
|
|
* @param node 文件节点或者包节点
|
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void removeNode(const Core::Route &node_path);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 修改指定节点的名称
|
|
|
|
|
* @param node 节点Index
|
|
|
|
|
* @param name 新名称
|
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void renameNode(const Core::Route &node_path, const QString &name);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 打开文件节点
|
2023-03-10 13:01:19 +00:00
|
|
|
|
* @param path_node
|
2023-03-05 14:32:20 +00:00
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void openFile(const Core::Route &path_node);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 获取打开的活跃文档
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
QList<Core::Route> actives() const;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 获取打开的内容展示实例,如果指向未打开的节点或无效文件节点,返回null
|
|
|
|
|
* @param node
|
|
|
|
|
* @return null或打开的展示实例
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
MakeTools::ContentPresent* activePresentOf(const Core::Route &node_path);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 保存指定的文档节点集合
|
|
|
|
|
* @param docs
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void save(const QList<Core::Route> &docs = QList<Core::Route>());
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 关闭定制的文档节点集合
|
|
|
|
|
* @param docs
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void close(const QList<Core::Route> &doc_paths = QList<Core::Route>());
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 查询指定实例(打开的)关联的ModelIndex
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
Core::Route pathOf(MakeTools::ContentPresent *ins) const;
|
|
|
|
|
Core::Route pathOf(const QModelIndex &p) const;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-03-10 13:01:19 +00:00
|
|
|
|
* @brief 构建所有源代码
|
|
|
|
|
* @param disk
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-03-10 13:01:19 +00:00
|
|
|
|
void build(bool disk);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
// AccessibleObject interface
|
|
|
|
|
public:
|
|
|
|
|
virtual QString name() const override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Core::AppCore *const rtcore;
|
|
|
|
|
Project::ProjectManager *pjtins;
|
2023-03-10 13:01:19 +00:00
|
|
|
|
PresentContainer *present_ui;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
QHash<QString, MakeTools::ContentPresent*> doc_openning;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // VISUABLE_PROJECT_CONTROLLER
|