QtNovelUI/libProjectManager/libProjectManager.h

179 lines
5.3 KiB
C
Raw Normal View History

2022-11-18 23:47:32 +00:00
#ifndef LIBPROJECTMANAGER_H
#define LIBPROJECTMANAGER_H
2022-11-17 08:26:05 +00:00
2022-11-18 23:47:32 +00:00
#include <libConfig.h>
2022-11-17 08:26:05 +00:00
#include <QFileInfo>
#include <QObject>
#include <QStandardItemModel>
namespace Project {
/**
* @brief
*/
class ProjectException : public Config::ParseException { };
2022-11-17 08:26:05 +00:00
/**
* @brief
*
* ==
* ==
* ==
* ==
*/
class ProjectManager
2022-11-17 08:26:05 +00:00
{
public:
virtual ~ProjectManager() = default;
2023-02-26 14:44:00 +00:00
/**
* @brief
* @return
*/
virtual QStandardItemModel* model() const = 0;
/**
* @brief
* @return
*/
virtual Config::Configration* configraions() const = 0;
/**
* @brief
* @return
*/
virtual QDir projectDir() const = 0;
2022-11-17 08:26:05 +00:00
// 项目操作=========================================================
/**
2023-02-26 14:44:00 +00:00
* @brief
2022-11-17 08:26:05 +00:00
* @return
*/
2023-02-26 14:44:00 +00:00
virtual QString suffix() const = 0;
/**
* @brief
* @param project_dir
* @param name
* @return
*/
virtual QString fmtedProjectPath(const QString &project_dir, const QString &name) const = 0;
2022-11-17 08:26:05 +00:00
/**
* @brief
2023-02-26 14:44:00 +00:00
* @param project_file
* @throw ProjectException*, ParseException*
2022-11-17 08:26:05 +00:00
*/
virtual void openProject(const QString &project_file) = 0;
2022-11-17 08:26:05 +00:00
/**
* @brief
* @param project_dir
* @param name
2023-02-26 14:44:00 +00:00
* @throw ProjectException*, ParseException*
2022-11-17 08:26:05 +00:00
*/
virtual void newProject(const QString &project_dir, const QString &name) = 0;
2022-11-17 08:26:05 +00:00
/**
* @brief
*/
virtual void closeProject() = 0;
2023-02-26 14:44:00 +00:00
/**
* @brief
* @return
*/
virtual bool isOpen() const noexcept = 0;
/**
* @brief
* @return
*/
virtual bool isModified() const noexcept = 0;
2022-11-17 08:26:05 +00:00
/**
* @brief save
* @throw ProjectException, ParseException
2022-11-17 08:26:05 +00:00
*/
virtual void save() = 0;
2023-02-26 14:44:00 +00:00
2022-11-17 08:26:05 +00:00
/**
* @brief
* @return
*/
virtual QString projectName() const = 0;
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param name
2022-11-17 08:26:05 +00:00
*/
2023-02-26 14:44:00 +00:00
virtual void resetProjectName(const QString& name) = 0;
2022-11-17 08:26:05 +00:00
2023-02-26 14:44:00 +00:00
// 项目内容管理=======================================================
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param path_defs
2022-11-17 08:26:05 +00:00
* @return
*/
2023-02-26 14:44:00 +00:00
virtual QModelIndex newPackage(const QList<QString> &path_defs) = 0;
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief QModexIndex为逻辑路径
* @param path
* @return
2022-11-17 08:26:05 +00:00
*/
2023-02-26 14:44:00 +00:00
virtual QStringList packagePath(const QModelIndex &path) const = 0;
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param package_appoint
* @throw ProjectException
2022-11-17 08:26:05 +00:00
*/
virtual QModelIndex signFile(const QModelIndex &package_appoint, const QString &name, const QString &path_on_disk) = 0;
/**
* @brief
* @param node
* @param name
*/
virtual void rename(const QModelIndex &node, const QString &name) = 0;
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param node
2022-11-17 08:26:05 +00:00
* @return
*/
virtual QList<QModelIndex> filesGather(const QModelIndex &node) const = 0;
2022-11-17 08:26:05 +00:00
/**
* @brief
2023-02-26 14:44:00 +00:00
* @param node_frompath
* @param target_group
2022-11-17 08:26:05 +00:00
* @return
*/
2023-02-26 14:44:00 +00:00
virtual void moveTo(const QModelIndex &node_frompath, const QModelIndex &target_group, int index=-1) = 0;
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param node_path
* @throw ProjectException
2022-11-17 08:26:05 +00:00
*/
2023-02-26 14:44:00 +00:00
virtual void deleteTarget(const QModelIndex &node_path) = 0;
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param suffix
* @return
*/
virtual QList<std::tuple<QString, QFileInfo>> filesWithEnds(const QString &suffix) const = 0;
/**
* @brief infoinfo
2022-11-17 08:26:05 +00:00
* @param path
2023-02-26 14:44:00 +00:00
* @return QFileInfo info实例
2022-11-17 08:26:05 +00:00
*/
2023-02-26 14:44:00 +00:00
virtual QFileInfo queryInfo(const QModelIndex &path) = 0;
2022-11-17 08:26:05 +00:00
/**
* @brief ModelIndex
* @param file
* @return
*/
virtual QModelIndex queryIndex(const QFileInfo &file) = 0;
2022-11-17 08:26:05 +00:00
};
}
2022-11-18 23:47:32 +00:00
#endif // LIBPROJECTMANAGER_H