|
|
/**
|
|
|
*
|
|
|
* @file FITKGUIRepo.h
|
|
|
* @brief 声明GUI仓库
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*
|
|
|
*/
|
|
|
#ifndef __FITKGUI_REPO_H___
|
|
|
#define __FITKGUI_REPO_H___
|
|
|
|
|
|
#include "FITKCoreAPI.h"
|
|
|
#include "FITKCoreMacros.h"
|
|
|
#include "FITKAbstractObject.hpp"
|
|
|
#include <QMutex>
|
|
|
#include <QList>
|
|
|
#include <QHash>
|
|
|
|
|
|
namespace Core
|
|
|
{
|
|
|
class FITKAbstractGUIObject;
|
|
|
class FITKGUIRepoDeleator;
|
|
|
/**
|
|
|
* @brief GUI仓库,软件生命周期的全部界面都在仓库中
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
class FITKCoreAPI FITKGUIRepo : public FITKAbstractObject
|
|
|
{
|
|
|
friend FITKAbstractGUIObject;
|
|
|
friend FITKGUIRepoDeleator;
|
|
|
|
|
|
DeclSingleton(FITKGUIRepo);
|
|
|
|
|
|
public:
|
|
|
/**
|
|
|
* @brief 根据ID获取UI
|
|
|
* @param[i] id Ui的ID
|
|
|
* @return FITKAbstractGUIObject*
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
FITKAbstractGUIObject* getFITKGUIObject(const int id);
|
|
|
/**
|
|
|
* @brief 根据ID关闭GUI
|
|
|
* @param[i] objID ID
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
void closeGUIObject(const int objID);
|
|
|
/**
|
|
|
* @brief 关闭UI对象
|
|
|
* @param[i] obj 关闭对象
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
void closeGUIObject(FITKAbstractGUIObject* obj);
|
|
|
/**
|
|
|
* @brief 关闭全部对话框对象
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-04-07
|
|
|
*/
|
|
|
void closeAllDialog();
|
|
|
/**
|
|
|
* @brief 仓库中是否包含对象
|
|
|
* @param[i] obj 判断的obj
|
|
|
* @return true
|
|
|
* @return false
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
bool isContains(FITKAbstractGUIObject* obj);
|
|
|
|
|
|
template <class T>
|
|
|
/**
|
|
|
* @brief 根据id获取对象并转换类型
|
|
|
* @param[i] id 界面对象id
|
|
|
* @return T*
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
T* getFITKGUIObjectT(const int id)
|
|
|
{
|
|
|
return dynamic_cast<T*>(this->getFITKGUIObject(id));
|
|
|
}
|
|
|
|
|
|
template<class T>
|
|
|
/**
|
|
|
* @brief 获取T类型的全部对象
|
|
|
* @return QList<T*>
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
QList<T*> getGUIObjects()
|
|
|
{
|
|
|
QList<T*> tobjs;
|
|
|
auto guiObjects = _idObjectHash.values();
|
|
|
for (auto obj : guiObjects)
|
|
|
{
|
|
|
auto t = dynamic_cast<T*>(obj);
|
|
|
if (t) tobjs.append(t);
|
|
|
}
|
|
|
return tobjs;
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
/**
|
|
|
* @brief 插入对象
|
|
|
* @param[i] obj 插入的对象
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
void insertGUIObject(FITKAbstractGUIObject* obj);
|
|
|
/**
|
|
|
* @brief 移除对象
|
|
|
* @param[i] obj 移除的对象
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
void removeGUIObject(FITKAbstractGUIObject* obj);
|
|
|
/**
|
|
|
* @brief 初始化
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
void initialize();
|
|
|
/**
|
|
|
* @brief 结束,析构函数调用
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-07-17
|
|
|
*/
|
|
|
void finalize();
|
|
|
|
|
|
private:
|
|
|
/**
|
|
|
* @brief GUI对象管理hash,键是GUI的ID
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
QHash<int, FITKAbstractGUIObject*> _idObjectHash{};
|
|
|
};
|
|
|
|
|
|
class FITKGUIRepoDeleator
|
|
|
{
|
|
|
public:
|
|
|
explicit FITKGUIRepoDeleator() = default;
|
|
|
virtual ~FITKGUIRepoDeleator();
|
|
|
};
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* @brief 定义快速访问
|
|
|
* @author LiBaojun (libaojunqd@foxmail.com)
|
|
|
* @date 2024-03-02
|
|
|
*/
|
|
|
#ifndef FITKGUIREPO
|
|
|
#define FITKGUIREPO (Core::FITKGUIRepo::getInstance())
|
|
|
#endif
|
|
|
|
|
|
#endif |