| 423 | } |
| 424 | |
| 425 | COperate* CManager::LoadOperate(const QString &szFile) |
| 426 | { |
| 427 | COperate* pOperate = nullptr; |
| 428 | if(szFile.isEmpty()) return nullptr; |
| 429 | qDebug(log) << "Load operate configure file:"<< szFile; |
| 430 | if(m_pParameterPlugin->GetGlobalParameters()->GetSaveSettingsType() |
| 431 | == CParameterGlobal::SaveSettingsType::Database && m_pDatabaseFile) { |
| 432 | qDebug(log) << "Load file from database"; |
| 433 | QByteArray content = m_pDatabaseFile->Load(szFile); |
| 434 | if(!content.isEmpty()) { |
| 435 | QFile f(szFile); |
| 436 | if(!f.open(QFile::WriteOnly | QFile::Text)) return nullptr; |
| 437 | f.write(content.data(), content.length()); |
| 438 | f.close(); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | QSettings set(szFile, QSettings::IniFormat); |
| 443 | m_FileVersion = set.value("Manage/FileVersion", m_FileVersion).toInt(); |
| 444 | QString id = set.value("Plugin/ID").toString(); |
| 445 | QString protocol = set.value("Plugin/Protocol").toString(); |
| 446 | QString name = set.value("Plugin/Name").toString(); |
| 447 | qDebug(log) << "LoadOperate protocol:" << protocol |
| 448 | << "name:" << name << "id:" << id; |
| 449 | pOperate = CreateOperate(id); |
| 450 | if(pOperate) { |
| 451 | int nRet = false; |
| 452 | //bRet = pOperate->Load(szFile); |
| 453 | bool bRet = QMetaObject::invokeMethod( |
| 454 | pOperate, |
| 455 | "Load", |
| 456 | Qt::DirectConnection, |
| 457 | Q_RETURN_ARG(int, nRet), |
| 458 | Q_ARG(QString, szFile)); |
| 459 | if(!bRet) { |
| 460 | qCritical(log) << "Call pOperate->Load(szFile) fail."; |
| 461 | return nullptr; |
| 462 | } |
| 463 | if(nRet) { |
| 464 | qCritical(log) << "Load parameter fail" << nRet; |
| 465 | DeleteOperate(pOperate); |
| 466 | return nullptr; |
| 467 | } |
| 468 | pOperate->SetSettingsFile(szFile); |
| 469 | } |
| 470 | else |
| 471 | qCritical(log) << "Don't create Operate:" << name << protocol << id << szFile; |
| 472 | |
| 473 | return pOperate; |
| 474 | } |
| 475 | |
| 476 | int CManager::SaveOperate(COperate *pOperate) |
| 477 | { |
no test coverage detected