|
|
|
@ -133,7 +133,6 @@ bool Solution::DeleteTask(QString strName)
|
|
|
|
QMap<QString, IDetectorTask*>::iterator its = m_TaskMapByName.find(strName);
|
|
|
|
QMap<QString, IDetectorTask*>::iterator its = m_TaskMapByName.find(strName);
|
|
|
|
if (its != m_TaskMapByName.end())
|
|
|
|
if (its != m_TaskMapByName.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int nID = (*its)->GetID();
|
|
|
|
|
|
|
|
(*its)->RemoveFile();
|
|
|
|
(*its)->RemoveFile();
|
|
|
|
delete *its;
|
|
|
|
delete *its;
|
|
|
|
m_TaskMapByName.erase(its);
|
|
|
|
m_TaskMapByName.erase(its);
|
|
|
|
@ -211,6 +210,7 @@ bool Solution::SaveFileEx(const QString& strPath, QStringList sTaskNames)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString strTaskFilePath = taskPath + "/taskinfo.json";
|
|
|
|
QString strTaskFilePath = taskPath + "/taskinfo.json";
|
|
|
|
|
|
|
|
p->SetPath(taskPath);
|
|
|
|
if (!p->SaveFile(strTaskFilePath))
|
|
|
|
if (!p->SaveFile(strTaskFilePath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qWarning("save task:%s fail", p->GetTaskInfo()->strName);
|
|
|
|
qWarning("save task:%s fail", p->GetTaskInfo()->strName);
|
|
|
|
@ -240,7 +240,8 @@ bool Solution::SaveFileEx(const QString& strPath)
|
|
|
|
dir.mkpath(taskPath);
|
|
|
|
dir.mkpath(taskPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString strTaskFilePath = taskPath + "/" + "taskinfo.json";
|
|
|
|
QString strTaskFilePath = taskPath + "/taskinfo.json";
|
|
|
|
|
|
|
|
p->SetPath(taskPath);
|
|
|
|
if (!p->SaveFile(strTaskFilePath))
|
|
|
|
if (!p->SaveFile(strTaskFilePath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qWarning("save task:%s fail", p->GetTaskInfo()->strName);
|
|
|
|
qWarning("save task:%s fail", p->GetTaskInfo()->strName);
|
|
|
|
@ -248,12 +249,6 @@ bool Solution::SaveFileEx(const QString& strPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
|
|
|
|
|
|
|
dir.setSorting(QDir::Size | QDir::Reversed);
|
|
|
|
|
|
|
|
QFileInfoList fileList = dir.entryInfoList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonObject infoObj;
|
|
|
|
QJsonObject infoObj;
|
|
|
|
infoObj.insert("solution_name", m_tSolutionInfo.strName);
|
|
|
|
infoObj.insert("solution_name", m_tSolutionInfo.strName);
|
|
|
|
infoObj.insert("solution_type", m_tSolutionInfo.nType);
|
|
|
|
infoObj.insert("solution_type", m_tSolutionInfo.nType);
|
|
|
|
@ -278,40 +273,63 @@ bool Solution::SaveFileEx(const QString& strPath)
|
|
|
|
infoFile.write(byteArray);
|
|
|
|
infoFile.write(byteArray);
|
|
|
|
infoFile.flush();
|
|
|
|
infoFile.flush();
|
|
|
|
infoFile.close();
|
|
|
|
infoFile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Solution::SaveTaskByName(QString strName)
|
|
|
|
/*
|
|
|
|
|
|
|
|
for (int i = 0; i < fileList.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (fileList.at(i).fileName() == "." || fileList.at(i).fileName() == "..")
|
|
|
|
QDir dir;
|
|
|
|
continue;
|
|
|
|
if (!dir.exists(m_curRootPath))
|
|
|
|
|
|
|
|
|
|
|
|
QString strFileName = fileList.at(i).fileName();
|
|
|
|
|
|
|
|
QString strSolutionFile = strPath + "/" + strFileName;
|
|
|
|
|
|
|
|
if (fileList.at(i).fileName() == "info.json")
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
dir.mkdir(m_curRootPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nID = strFileName.mid(0, strFileName.indexOf("_")).toInt();
|
|
|
|
dir.setPath(m_curRootPath);
|
|
|
|
QString strTaskName = strFileName.mid(strFileName.indexOf("_") + 1, strFileName.lastIndexOf(".") - strFileName.indexOf("_") - 1);
|
|
|
|
//保存指定的task
|
|
|
|
|
|
|
|
QMap<QString, IDetectorTask*>::iterator iter = m_TaskMapByName.find(strName);
|
|
|
|
|
|
|
|
if (iter!=m_TaskMapByName.end()) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!CheckTask(nID, strTaskName))
|
|
|
|
CDetectorTask *p = (CDetectorTask*)*iter;
|
|
|
|
|
|
|
|
QString taskPath = m_curRootPath + "/" + p->GetTaskName();
|
|
|
|
|
|
|
|
if (!dir.exists(taskPath)) {
|
|
|
|
|
|
|
|
dir.mkpath(taskPath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString strTaskFilePath = taskPath + "/taskinfo.json";
|
|
|
|
|
|
|
|
p->SetPath(taskPath);
|
|
|
|
|
|
|
|
if (!p->SaveFile(strTaskFilePath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QFile::remove(strSolutionFile);
|
|
|
|
qWarning("save task:%s fail", p->GetTaskName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
//更新solution指定的info文件,包括是否使用对于的模板
|
|
|
|
|
|
|
|
QJsonObject infoObj;
|
|
|
|
*/
|
|
|
|
infoObj.insert("solution_name", m_tSolutionInfo.strName);
|
|
|
|
|
|
|
|
infoObj.insert("solution_type", m_tSolutionInfo.nType);
|
|
|
|
|
|
|
|
infoObj.insert("solution_description", m_tSolutionInfo.strDescription);
|
|
|
|
|
|
|
|
infoObj.insert("solution_id", m_nID);
|
|
|
|
|
|
|
|
QJsonArray tasklist;
|
|
|
|
|
|
|
|
m_tasklist = m_TaskMapByName.keys();
|
|
|
|
|
|
|
|
foreach(QString var, m_tasklist)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tasklist.append(var);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
infoObj.insert("tasklist", tasklist);
|
|
|
|
|
|
|
|
QJsonDocument document;
|
|
|
|
|
|
|
|
document.setObject(infoObj);
|
|
|
|
|
|
|
|
QByteArray byteArray = document.toJson();
|
|
|
|
|
|
|
|
|
|
|
|
bool Solution::SaveFileEx()
|
|
|
|
QString strInfoFile = m_curRootPath + "/info.json";
|
|
|
|
|
|
|
|
QFile infoFile(strInfoFile);
|
|
|
|
|
|
|
|
if (infoFile.open(QFile::WriteOnly | QFile::Text))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return SaveFileEx(m_curRootPath);
|
|
|
|
infoFile.write(byteArray);
|
|
|
|
|
|
|
|
infoFile.flush();
|
|
|
|
|
|
|
|
infoFile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
@ -328,6 +346,7 @@ solution_1 ---------- info.json //
|
|
|
|
-----param.ts //标定模板参数
|
|
|
|
-----param.ts //标定模板参数
|
|
|
|
---------- 。。。。
|
|
|
|
---------- 。。。。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
bool Solution::LoadFileEx(const QString& strPath)
|
|
|
|
bool Solution::LoadFileEx(const QString& strPath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDir dir(strPath);
|
|
|
|
QDir dir(strPath);
|
|
|
|
|