QtNovelUI/libProjectManager/libProjectManager.h

256 lines
7.2 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
*/
2023-08-12 13:01:01 +00:00
class ProjectException : public Config::ParseException {};
class FilesOperate {
public:
virtual ~FilesOperate() = default;
/**
* @brief
* @param path_defs
* @return
*/
virtual QModelIndex newPackage(const QList<QString> &path_defs) = 0;
2023-08-14 14:09:23 +00:00
2023-08-12 13:01:01 +00:00
/**
2023-08-14 14:09:23 +00:00
* @brief
2023-08-12 13:01:01 +00:00
* @param package_appoint
2023-08-14 14:09:23 +00:00
* @param node
* @param suffix 使
* @return
2023-08-12 13:01:01 +00:00
* @throw ProjectException
*/
2023-08-14 14:09:23 +00:00
virtual QModelIndex newFile(const QModelIndex &package_appoint, const QString &node, const QString &suffix = "txt") = 0;
2023-08-12 13:01:01 +00:00
/**
* @brief
* @param node
* @param name
*/
virtual void rename(const QModelIndex &node, const QString &name) = 0;
/**
* @brief
* @param node_frompath
* @param target_group
* @return
*/
virtual void moveTo(const QModelIndex &node_frompath, const QModelIndex &target_group, int index = -1) = 0;
/**
* @brief
* @param node_path
* @throw ProjectException
*/
virtual void deleteT(const QModelIndex &node_path) = 0;
};
class FilesQuery {
public:
virtual ~FilesQuery() = default;
/**
* @brief
* @param node
* @return
*/
virtual QList<QModelIndex> filesGather(const QModelIndex &node) const = 0;
/**
* @brief
* @param suffix
* @return
*/
virtual QList<std::tuple<QString, QFileInfo>> filesWithEnds(const QString &suffix) const = 0;
2023-08-13 10:02:21 +00:00
2023-08-12 13:01:01 +00:00
/**
* @brief infoinfo
* @param path
* @return QFileInfo info实例
*/
virtual QFileInfo queryInfo(const QModelIndex &path) = 0;
/**
* @brief ModelIndex
* @param file
* @return
*/
virtual QModelIndex queryIndex(const QFileInfo &file) = 0;
2023-08-14 14:09:23 +00:00
/**
* @brief QModexIndex为逻辑路径
* @param path
* @return
*/
virtual QStringList packagePath(const QModelIndex &path) const = 0;
2023-08-12 13:01:01 +00:00
};
2023-12-24 04:49:58 +00:00
class ManagerListener{
public:
/**
* @brief
* @param project_file
*/
virtual void ProjectNEW(const QString &project_file) = 0;
/**
* @brief
* @param project_file
*/
virtual void ProjectOPEN(const QString &project_file) = 0;
/**
* @brief
*/
virtual void hasBeenSAVE() = 0;
/**
* @brief
*/
virtual void hasBeenCLOSE() = 0;
/**
* @brief
* @param path
* @param new_name
*/
virtual void hasBeenRENAME(const QModelIndex &path, const QString &new_name) = 0;
/**
* @brief
* @param new_path
*/
virtual void hasBeenAPPEND(const QModelIndex &new_path) = 0;
/**
* @brief
* @param new_path
*/
virtual void hasBeenMOVE(const QModelIndex &new_path) = 0;
/**
* @brief
*/
virtual void aboutToBeSAVE() = 0;
/**
* @brief
*/
virtual void aboutToBeCLOSE() = 0;
/**
* @brief
* @param path
*/
virtual void aboutToBeDELETE(const QModelIndex &path) = 0;
/**
* @brief
* @param old_path
*/
virtual void aboutToBeMOVE(const QModelIndex &old_path) = 0;
};
2022-11-17 08:26:05 +00:00
/**
* @brief
*
* ==
* ==
* ==
* ==
*/
class ProjectManager
2022-11-17 08:26:05 +00:00
{
public:
virtual ~ProjectManager() = default;
2023-12-24 04:49:58 +00:00
/**
* @brief ManagerListener实例
* @param inst
*/
virtual void addListener(ManagerListener *inst) = 0;
virtual void removeListener(ManagerListener *inst) = 0;
2023-02-26 14:44:00 +00:00
/**
* @brief
* @return
*/
virtual QStandardItemModel* model() const = 0;
/**
* @brief
* @return
*/
2023-08-12 13:01:01 +00:00
virtual Config::Configration *configraions() const = 0;
2023-02-26 14:44:00 +00:00
2023-08-12 13:01:01 +00:00
virtual FilesOperate *operateAccess() const = 0;
virtual FilesQuery *queryAccess() 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;
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
*/
2023-08-14 14:09:23 +00:00
virtual void newProject(const QDir &project_dir, const QString &name) = 0;
2023-08-12 13:01:01 +00:00
2022-11-17 08:26:05 +00:00
/**
* @brief
*/
virtual void closeProject() = 0;
2023-02-26 14:44:00 +00:00
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
*/
2023-08-12 13:01:01 +00:00
virtual QString name() const = 0;
2022-11-17 08:26:05 +00:00
/**
2023-02-26 14:44:00 +00:00
* @brief
* @param name
2022-11-17 08:26:05 +00:00
*/
2023-08-12 13:01:01 +00:00
virtual void resetName(const QString &name) = 0;
2022-11-17 08:26:05 +00:00
/**
2023-08-12 13:01:01 +00:00
* @brief
2022-11-17 08:26:05 +00:00
* @return
*/
2023-08-12 13:01:01 +00:00
virtual QDir directory() const = 0;
2022-11-17 08:26:05 +00:00
/**
2023-08-12 13:01:01 +00:00
* @brief
* @return
2022-11-17 08:26:05 +00:00
*/
2023-08-12 13:01:01 +00:00
virtual bool isOpenning() const noexcept = 0;
2022-11-17 08:26:05 +00:00
};
2023-08-13 10:02:21 +00:00
2023-08-12 13:01:01 +00:00
} // namespace Project
2022-11-17 08:26:05 +00:00
2022-11-18 23:47:32 +00:00
#endif // LIBPROJECTMANAGER_H