| 69 | } |
| 70 | |
| 71 | std::pair<int, bool> Mod::compare(const Resource& other, SortType type) const |
| 72 | { |
| 73 | auto cast_other = dynamic_cast<Mod const*>(&other); |
| 74 | if (!cast_other) |
| 75 | return Resource::compare(other, type); |
| 76 | |
| 77 | switch (type) { |
| 78 | default: |
| 79 | case SortType::ENABLED: |
| 80 | case SortType::NAME: |
| 81 | case SortType::DO_UPDATES: |
| 82 | case SortType::DATE: { |
| 83 | auto res = Resource::compare(other, type); |
| 84 | if (res.first != 0) |
| 85 | return res; |
| 86 | // FIXME: Determine if this is a legitimate fallthrough |
| 87 | [[fallthrough]]; |
| 88 | } |
| 89 | case SortType::VERSION: { |
| 90 | auto this_ver = Version(version()); |
| 91 | auto other_ver = Version(cast_other->version()); |
| 92 | if (this_ver > other_ver) |
| 93 | return { 1, type == SortType::VERSION }; |
| 94 | if (this_ver < other_ver) |
| 95 | return { -1, type == SortType::VERSION }; |
| 96 | } |
| 97 | } |
| 98 | return { 0, false }; |
| 99 | } |
| 100 | |
| 101 | bool Mod::applyFilter(QRegularExpression filter) const |
| 102 | { |
no test coverage detected