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.
85 lines
1.9 KiB
C++
85 lines
1.9 KiB
C++
#include "FITKGUIRepo.h"
|
|
#include "FITKAbstractGUIObject.h"
|
|
#include <QDialog>
|
|
|
|
namespace Core
|
|
{
|
|
//静态变量初始化
|
|
FITKGUIRepo* FITKGUIRepo::_instance = nullptr;
|
|
QMutex FITKGUIRepo::m_mutex;
|
|
|
|
FITKAbstractGUIObject* FITKGUIRepo::getFITKGUIObject(const int id)
|
|
{
|
|
//不存在则返回空指针
|
|
return _idObjectHash.value(id);
|
|
}
|
|
|
|
void FITKGUIRepo::closeGUIObject(const int objID)
|
|
{
|
|
FITKAbstractGUIObject* guiObj = _idObjectHash.value(objID);
|
|
//delete会关闭
|
|
if (guiObj != nullptr)
|
|
delete guiObj;
|
|
}
|
|
|
|
void FITKGUIRepo::closeGUIObject(FITKAbstractGUIObject* obj)
|
|
{
|
|
if (!isContains(obj)) return;
|
|
//delete会关闭
|
|
delete obj;
|
|
}
|
|
|
|
void FITKGUIRepo::closeAllDialog()
|
|
{
|
|
QList<QDialog*> dlgs = this->getGUIObjects<QDialog>();
|
|
for (auto d : dlgs)
|
|
delete d;
|
|
}
|
|
|
|
bool FITKGUIRepo::isContains(FITKAbstractGUIObject* obj)
|
|
{
|
|
if (obj == nullptr) return false;
|
|
const int id = obj->getGUIObjectID();
|
|
return _idObjectHash.contains(id);
|
|
}
|
|
|
|
void FITKGUIRepo::insertGUIObject(FITKAbstractGUIObject* obj)
|
|
{
|
|
if (obj == nullptr) return;
|
|
const int id = obj->getGUIObjectID();
|
|
//纳入到管理
|
|
_idObjectHash.insert(id, obj);
|
|
}
|
|
|
|
void FITKGUIRepo::removeGUIObject(FITKAbstractGUIObject* obj)
|
|
{
|
|
//FITKAbstractGUIObject析构调用
|
|
if (obj == nullptr) return;
|
|
const int id = obj->getGUIObjectID();
|
|
//不能重复delete
|
|
_idObjectHash.remove(id);
|
|
}
|
|
|
|
void FITKGUIRepo::initialize()
|
|
{
|
|
}
|
|
|
|
void FITKGUIRepo::finalize()
|
|
{
|
|
|
|
}
|
|
|
|
FITKGUIRepoDeleator::~FITKGUIRepoDeleator()
|
|
{
|
|
if (FITKGUIRepo::_instance)
|
|
delete FITKGUIRepo::_instance;
|
|
FITKGUIRepo::_instance = nullptr;
|
|
}
|
|
|
|
static FITKGUIRepoDeleator _DELEATOR__;
|
|
|
|
}
|
|
|
|
|
|
|