You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Kernel/FITKCore/FITKGUIRepo.h

160 lines
4.2 KiB
C

/**
*
* @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 IDUI
* @param[i] id UiID
* @return FITKAbstractGUIObject*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
FITKAbstractGUIObject* getFITKGUIObject(const int id);
/**
* @brief IDGUI
* @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 GUIhashGUIID
* @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