2023-03-17 13:58:38 +00:00
|
|
|
|
#ifndef MANAGER_DOCS_H
|
|
|
|
|
#define MANAGER_DOCS_H
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
|
#include "DocsManager.h"
|
2023-03-10 13:01:19 +00:00
|
|
|
|
#include "route.h"
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
2023-08-15 14:14:00 +00:00
|
|
|
|
#include <QList>
|
2023-03-05 14:32:20 +00:00
|
|
|
|
#include <QTreeView>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <commandsdispatcher.h>
|
2023-08-15 14:14:00 +00:00
|
|
|
|
#include <libProjectManager.h>
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
|
namespace MakeTools {
|
|
|
|
|
class FilePresent;
|
|
|
|
|
}
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
namespace Components {
|
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
|
class PresentHost {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~PresentHost() = default;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 承载内容的Widget
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
virtual QWidget *hostWidget() const = 0;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 添加内容展示实例
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
virtual void append(MakeTools::PresentBase *ins) = 0;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 激活内容展示实例
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
virtual bool active(const MakeTools::PresentBase *ins) = 0;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 移除内容展示实例
|
|
|
|
|
* @param ins
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
virtual void remove(const MakeTools::PresentBase *ins) = 0;
|
|
|
|
|
/**
|
|
|
|
|
* @brief 是否包含指定
|
|
|
|
|
* @param ins
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
virtual bool contains(const MakeTools::PresentBase *ins) const = 0;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
|
} // namespace Components
|
|
|
|
|
|
|
|
|
|
namespace DataModel {
|
|
|
|
|
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 文档管理器,根据项目配置文件,打开、查询、关闭文档实例
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
class DocumentsManager : public Schedule::AccessibleObject {
|
|
|
|
|
public:
|
2023-08-15 14:40:40 +00:00
|
|
|
|
DocumentsManager(Project::ProjectManager *project);
|
2023-03-10 13:01:19 +00:00
|
|
|
|
virtual ~DocumentsManager() = default;
|
|
|
|
|
|
2023-08-15 14:14:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 设置文档呈现窗口
|
|
|
|
|
* @param container
|
|
|
|
|
*/
|
|
|
|
|
void setPresent(Components::PresentHost *container);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 项目获取管理器
|
|
|
|
|
* @return 项目管理器实例
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
Project::ProjectManager *projectManager() const;
|
|
|
|
|
|
2023-08-15 14:45:04 +00:00
|
|
|
|
void registViewPlugins();
|
|
|
|
|
|
2023-08-15 14:14:00 +00:00
|
|
|
|
// ==========================================================
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 注册插件类型
|
|
|
|
|
* @param ins 插件工厂实例
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
template <class PresentType> void registPresentType(MakeTools::TypedPresentFactory<PresentType> *ins) {
|
|
|
|
|
auto suffix = MakeTools::TypedPresentFactory<PresentType>::suffix();
|
|
|
|
|
factory_map[suffix] = ins;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==========================================================
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 获取支持的文件类型
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @return {txt, storyboard, ……}
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
|
|
|
|
QList<QString> fileTypes() const;
|
2023-08-15 14:14:00 +00:00
|
|
|
|
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 提供完整路径创建新包
|
|
|
|
|
* @param link 包路径
|
2023-03-05 14:32:20 +00:00
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
void createPackage(const Core::Route &link);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 在指定的包节点下,创建指定类型的新文件
|
|
|
|
|
* @param group_path 包路径
|
|
|
|
|
* @param name 节点名称
|
|
|
|
|
* @param suffix 通过后缀名,指定文件类型
|
2023-03-05 14:32:20 +00:00
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
void createFile(const Core::Route &group_path, const QString &name, const QString &suffix);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 修改指定节点的名称
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @param node_path 节点路径
|
2023-03-05 14:32:20 +00:00
|
|
|
|
* @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
|
|
|
|
|
2023-08-15 14:14:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 移除指定节点(必须非根节点)
|
|
|
|
|
* @param node_path 文件节点或者包节点
|
|
|
|
|
* @throw SimpleException
|
|
|
|
|
*/
|
|
|
|
|
void deleteNode(const Core::Route &node_path);
|
|
|
|
|
|
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-08-15 14:14:00 +00:00
|
|
|
|
void openFile(const QList<Core::Route> &doc_paths);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 关闭定制的文档节点集合
|
|
|
|
|
* @param doc_paths 关闭指定路径下的打开的文档
|
|
|
|
|
*/
|
|
|
|
|
void closeFile(const QList<Core::Route> &doc_paths = QList<Core::Route>());
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 转换路径和索引
|
|
|
|
|
* @param path
|
2023-03-05 14:32:20 +00:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
QModelIndex convertPath(const Core::Route &path);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 转换路径和索引
|
|
|
|
|
* @param path
|
|
|
|
|
* @return
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
Core::Route convertPath(const QModelIndex &index);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 获取打开的内容展示实例路径
|
|
|
|
|
* @param ins 打开的实例
|
|
|
|
|
* @return 实例路径
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
Core::Route convertPresent(MakeTools::FilePresent *ins) const;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 获取打开的内容展示实例,如果指向未打开的节点或无效文件节点,返回null
|
|
|
|
|
* @param node_path 节点路径
|
|
|
|
|
* @return null或打开的展示实例
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
MakeTools::FilePresent *convertPresent(const Core::Route &node_path);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 获取打开的活跃文档
|
|
|
|
|
* @return
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
QList<Core::Route> actives() const;
|
|
|
|
|
|
|
|
|
|
void active(const Core::Route &node_path);
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-15 14:14:00 +00:00
|
|
|
|
* @brief 保存指定的文档节点集合
|
|
|
|
|
* @param docs
|
2023-03-05 14:32:20 +00:00
|
|
|
|
*/
|
2023-08-15 14:14:00 +00:00
|
|
|
|
void save();
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
|
|
|
|
// AccessibleObject interface
|
2023-08-15 14:14:00 +00:00
|
|
|
|
public:
|
2023-03-05 14:32:20 +00:00
|
|
|
|
virtual QString name() const override;
|
|
|
|
|
|
2023-08-15 14:14:00 +00:00
|
|
|
|
private:
|
2023-03-05 14:32:20 +00:00
|
|
|
|
Project::ProjectManager *pjtins;
|
2023-03-17 13:58:38 +00:00
|
|
|
|
Components::PresentHost *present_ui;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
2023-08-15 14:14:00 +00:00
|
|
|
|
QHash<QString, MakeTools::PresentFactory *> factory_map;
|
2023-03-17 13:58:38 +00:00
|
|
|
|
QHash<Core::Route, MakeTools::FilePresent *> doc_openning;
|
2023-03-05 14:32:20 +00:00
|
|
|
|
};
|
2023-03-17 13:58:38 +00:00
|
|
|
|
} // namespace DataModel
|
2023-03-05 14:32:20 +00:00
|
|
|
|
|
2023-03-17 13:58:38 +00:00
|
|
|
|
#endif // MANAGER_DOCS_H
|