| 498 | } |
| 499 | |
| 500 | ModListView::ModCounters ModListView::counters() const |
| 501 | { |
| 502 | ModCounters c; |
| 503 | |
| 504 | auto hasFlag = [](std::vector<ModInfo::EFlag> flags, ModInfo::EFlag filter) { |
| 505 | return std::find(flags.begin(), flags.end(), filter) != flags.end(); |
| 506 | }; |
| 507 | |
| 508 | for (unsigned int index = 0; index < ModInfo::getNumMods(); ++index) { |
| 509 | auto info = ModInfo::getByIndex(index); |
| 510 | const auto flags = info->getFlags(); |
| 511 | |
| 512 | const bool enabled = m_core->currentProfile()->modEnabled(index); |
| 513 | const bool visible = m_sortProxy->filterMatchesMod(info, enabled); |
| 514 | |
| 515 | if (info->isBackup()) { |
| 516 | c.backup++; |
| 517 | if (visible) |
| 518 | c.visible.backup++; |
| 519 | } else if (info->isForeign()) { |
| 520 | c.foreign++; |
| 521 | if (visible) |
| 522 | c.visible.foreign++; |
| 523 | } else if (info->isSeparator()) { |
| 524 | c.separator++; |
| 525 | if (visible) |
| 526 | c.visible.separator++; |
| 527 | } else if (!info->isOverwrite()) { |
| 528 | c.regular++; |
| 529 | if (visible) |
| 530 | c.visible.regular++; |
| 531 | if (enabled) { |
| 532 | c.active++; |
| 533 | if (visible) |
| 534 | c.visible.active++; |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | return c; |
| 540 | } |
| 541 | |
| 542 | void ModListView::updateModCount() |
| 543 | { |
no test coverage detected