| 486 | } |
| 487 | |
| 488 | bool ModFolderModel::deleteResources(const QModelIndexList& indexes) |
| 489 | { |
| 490 | auto deleteInvalid = [](QSet<Mod*>& mods) { |
| 491 | for (auto it = mods.begin(); it != mods.end();) { |
| 492 | auto mod = *it; |
| 493 | // the QFileInfo::exists is used instead of mod->fileinfo().exists |
| 494 | // because the later somehow caches that the file exists |
| 495 | if (!mod || !QFileInfo::exists(mod->fileinfo().absoluteFilePath())) { |
| 496 | it = mods.erase(it); |
| 497 | } else { |
| 498 | ++it; |
| 499 | } |
| 500 | } |
| 501 | }; |
| 502 | auto rsp = ResourceFolderModel::deleteResources(indexes); |
| 503 | for (auto mod : allMods()) { |
| 504 | auto id = mod->mod_id(); |
| 505 | deleteInvalid(m_requiredBy[id]); |
| 506 | deleteInvalid(m_requires[id]); |
| 507 | if (mod->requiredByCount() != m_requiredBy[id].count() || mod->requiresCount() != m_requires[id].count()) { |
| 508 | mod->setRequiredByCount(m_requiredBy[id].count()); |
| 509 | mod->setRequiresCount(m_requires[id].count()); |
| 510 | int row = m_resources_index[mod->internal_id()]; |
| 511 | emit dataChanged(index(row, RequiresColumn), index(row, RequiredByColumn)); |
| 512 | } |
| 513 | } |
| 514 | return rsp; |
| 515 | } |
no test coverage detected