150 lines
4.2 KiB
C
150 lines
4.2 KiB
C
|
#ifndef VISUABLE_PROJECT_CONTROLLER
|
|||
|
#define VISUABLE_PROJECT_CONTROLLER
|
|||
|
|
|||
|
#include "appcore.h"
|
|||
|
|
|||
|
#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 文档管理器,根据项目配置文件,打开、查询、关闭文档实例
|
|||
|
*/
|
|||
|
class DocumentManager : public Schedule::AccessibleObject
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
public:
|
|||
|
DocumentManager(Core::AppCore *src, Project::ProjectManager *project, PresentContainer *con);
|
|||
|
virtual ~DocumentManager() = default;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 提供完整路径创建新包
|
|||
|
* @param path [/x_name]+
|
|||
|
*/
|
|||
|
void newPackage(const QString &path_str);
|
|||
|
/**
|
|||
|
* @brief 提供父节点Index,创建新包
|
|||
|
* @param group
|
|||
|
* @param name
|
|||
|
* @throw SimpleException
|
|||
|
*/
|
|||
|
void newPackage(const QString &group_path, const QString &name);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取支持的文件类型
|
|||
|
* @return {txt, storychain, ……}
|
|||
|
*/
|
|||
|
QList<QString> fileTypes() const;
|
|||
|
/**
|
|||
|
* @brief 在指定的包节点下,创建指定类型的新文件
|
|||
|
* @param group 包节点
|
|||
|
* @param name 文件名称
|
|||
|
* @param suffix 通过后缀名,指定文件类型
|
|||
|
* @throw SimpleException
|
|||
|
*/
|
|||
|
void newFile(const QString &group_path, const QString &name, const QString &suffix);
|
|||
|
|
|||
|
QModelIndex converter(const QString &path);
|
|||
|
QString converter(const QModelIndex &index);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 移除指定节点(必须非根节点)
|
|||
|
* @param node 文件节点或者包节点
|
|||
|
* @throw SimpleException
|
|||
|
*/
|
|||
|
void removeNode(const QString &node_path);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 修改指定节点的名称
|
|||
|
* @param node 节点Index
|
|||
|
* @param name 新名称
|
|||
|
* @throw SimpleException
|
|||
|
*/
|
|||
|
void renameNode(const QString &node_path, const QString &name);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 打开文件节点
|
|||
|
* @param file_node
|
|||
|
* @throw SimpleException
|
|||
|
*/
|
|||
|
void openFile(const QString &file_node);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取打开的活跃文档
|
|||
|
* @return
|
|||
|
*/
|
|||
|
QList<QString> actives() const;
|
|||
|
/**
|
|||
|
* @brief 获取打开的内容展示实例,如果指向未打开的节点或无效文件节点,返回null
|
|||
|
* @param node
|
|||
|
* @return null或打开的展示实例
|
|||
|
*/
|
|||
|
MakeTools::ContentPresent* activePresentOf(const QString &node_path);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 保存指定的文档节点集合
|
|||
|
* @param docs
|
|||
|
*/
|
|||
|
void save(const QList<QString> &docs = QList<QString>());
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 关闭定制的文档节点集合
|
|||
|
* @param docs
|
|||
|
*/
|
|||
|
void close(const QList<QString> &doc_paths = QList<QString>());
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 查询指定实例(打开的)关联的ModelIndex
|
|||
|
* @param ins
|
|||
|
*/
|
|||
|
QString pathOf(MakeTools::ContentPresent *ins) const;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 查询指定实例(打开的)
|
|||
|
* @param target
|
|||
|
* @return
|
|||
|
*/
|
|||
|
QModelIndex pathOf(const QFileInfo &target) const;
|
|||
|
|
|||
|
// AccessibleObject interface
|
|||
|
public:
|
|||
|
virtual QString name() const override;
|
|||
|
|
|||
|
private:
|
|||
|
Core::AppCore *const rtcore;
|
|||
|
Project::ProjectManager *pjtins;
|
|||
|
PresentContainer *front_end;
|
|||
|
|
|||
|
QHash<QString, MakeTools::ContentPresent*> doc_openning;
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
#endif // VISUABLE_PROJECT_CONTROLLER
|