| 316 | } |
| 317 | |
| 318 | QSet<Mod*> collectMods(QSet<Mod*> mods, QHash<QString, QSet<Mod*>> relation, std::set<QString>& seen, bool shouldBeEnabled) |
| 319 | { |
| 320 | QSet<Mod*> affectedList = {}; |
| 321 | QSet<Mod*> needToCheck = {}; |
| 322 | for (auto mod : mods) { |
| 323 | auto id = mod->mod_id(); |
| 324 | if (seen.count(id) == 0) { |
| 325 | seen.insert(id); |
| 326 | for (auto affected : relation[id]) { |
| 327 | auto affectedId = affected->mod_id(); |
| 328 | |
| 329 | if (findById(mods, affectedId) == nullptr && seen.count(affectedId) == 0) { |
| 330 | seen.insert(affectedId); |
| 331 | if (shouldBeEnabled != affected->enabled()) { |
| 332 | affectedList << affected; |
| 333 | } |
| 334 | needToCheck << affected; |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | // collect the affected mods until all of them are included in the list |
| 340 | if (!needToCheck.isEmpty()) { |
| 341 | affectedList += collectMods(needToCheck, relation, seen, shouldBeEnabled); |
| 342 | } |
| 343 | return affectedList; |
| 344 | } |
| 345 | |
| 346 | QModelIndexList ModFolderModel::getAffectedMods(const QModelIndexList& indexes, EnableAction action) |
| 347 | { |