QtNovelUI/WordsIDE/manager_docs.h

193 lines
5.4 KiB
C
Raw Normal View History

2023-03-17 13:58:38 +00:00
#ifndef MANAGER_DOCS_H
#define MANAGER_DOCS_H
2023-03-17 13:58:38 +00:00
#include "DocsManager.h"
2023-03-10 13:01:19 +00:00
#include "route.h"
#include <QList>
#include <QTreeView>
#include <QWidget>
#include <commandsdispatcher.h>
#include <libProjectManager.h>
2023-03-17 13:58:38 +00:00
namespace MakeTools {
class FilePresent;
}
namespace Components {
2023-03-17 13:58:38 +00:00
class PresentHost {
public:
virtual ~PresentHost() = default;
/**
* @brief Widget
* @return
*/
virtual QWidget *hostWidget() const = 0;
/**
* @brief
* @param ins
*/
virtual void append(MakeTools::PresentBase *ins) = 0;
/**
* @brief
* @param ins
*/
virtual bool active(const MakeTools::PresentBase *ins) = 0;
/**
* @brief
* @param ins
*/
virtual void remove(const MakeTools::PresentBase *ins) = 0;
/**
* @brief
* @param ins
* @return
*/
virtual bool contains(const MakeTools::PresentBase *ins) const = 0;
};
2023-03-17 13:58:38 +00:00
} // namespace Components
namespace DataModel {
/**
* @brief
*/
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;
/**
* @brief
* @param container
*/
void setPresent(Components::PresentHost *container);
/**
* @brief
* @return
*/
Project::ProjectManager *projectManager() const;
2023-08-15 14:45:04 +00:00
void registViewPlugins();
// ==========================================================
/**
* @brief
* @param ins
*/
template <class PresentType> void registPresentType(MakeTools::TypedPresentFactory<PresentType> *ins) {
auto suffix = MakeTools::TypedPresentFactory<PresentType>::suffix();
factory_map[suffix] = ins;
}
// ==========================================================
/**
* @brief
* @return {txt, storyboard, }
*/
QList<QString> fileTypes() const;
/**
* @brief
* @param link
* @throw SimpleException
*/
void createPackage(const Core::Route &link);
/**
* @brief
* @param group_path
* @param name
* @param suffix
* @throw SimpleException
*/
void createFile(const Core::Route &group_path, const QString &name, const QString &suffix);
/**
* @brief
* @param node_path
* @param name
* @throw SimpleException
*/
2023-03-10 13:01:19 +00:00
void renameNode(const Core::Route &node_path, const QString &name);
/**
* @brief
* @param node_path
* @throw SimpleException
*/
void deleteNode(const Core::Route &node_path);
/**
* @brief
2023-03-10 13:01:19 +00:00
* @param path_node
* @throw SimpleException
*/
void openFile(const QList<Core::Route> &doc_paths);
/**
* @brief
* @param doc_paths
*/
void closeFile(const QList<Core::Route> &doc_paths = QList<Core::Route>());
/**
* @brief
* @param path
* @return
*/
QModelIndex convertPath(const Core::Route &path);
/**
* @brief
* @param path
* @return
*/
Core::Route convertPath(const QModelIndex &index);
/**
* @brief
* @param ins
* @return
*/
Core::Route convertPresent(MakeTools::FilePresent *ins) const;
/**
* @brief null
* @param node_path
* @return null或打开的展示实例
*/
MakeTools::FilePresent *convertPresent(const Core::Route &node_path);
/**
* @brief
* @return
*/
QList<Core::Route> actives() const;
void active(const Core::Route &node_path);
/**
* @brief
* @param docs
*/
void save();
// AccessibleObject interface
public:
virtual QString name() const override;
private:
Project::ProjectManager *pjtins;
2023-03-17 13:58:38 +00:00
Components::PresentHost *present_ui;
QHash<QString, MakeTools::PresentFactory *> factory_map;
2023-03-17 13:58:38 +00:00
QHash<Core::Route, MakeTools::FilePresent *> doc_openning;
};
2023-03-17 13:58:38 +00:00
} // namespace DataModel
2023-03-17 13:58:38 +00:00
#endif // MANAGER_DOCS_H