| 58 | } |
| 59 | |
| 60 | std::pair<int, bool> Resource::compare(const Resource& other, SortType type) const |
| 61 | { |
| 62 | switch (type) { |
| 63 | default: |
| 64 | case SortType::ENABLED: |
| 65 | if (enabled() && !other.enabled()) |
| 66 | return { 1, type == SortType::ENABLED }; |
| 67 | if (!enabled() && other.enabled()) |
| 68 | return { -1, type == SortType::ENABLED }; |
| 69 | [[fallthrough]]; |
| 70 | case SortType::NAME: { |
| 71 | QString this_name{ name() }; |
| 72 | QString other_name{ other.name() }; |
| 73 | |
| 74 | removeThePrefix(this_name); |
| 75 | removeThePrefix(other_name); |
| 76 | |
| 77 | auto compare_result = QString::compare(this_name, other_name, Qt::CaseInsensitive); |
| 78 | if (compare_result != 0) |
| 79 | return { compare_result, type == SortType::NAME }; |
| 80 | [[fallthrough]]; |
| 81 | } |
| 82 | case SortType::DATE: |
| 83 | if (dateTimeChanged() > other.dateTimeChanged()) |
| 84 | return { 1, type == SortType::DATE }; |
| 85 | if (dateTimeChanged() < other.dateTimeChanged()) |
| 86 | return { -1, type == SortType::DATE }; |
| 87 | } |
| 88 | |
| 89 | return { 0, false }; |
| 90 | } |
| 91 | |
| 92 | bool Resource::applyFilter(QRegularExpression filter) const |
| 93 | { |
nothing calls this directly
no test coverage detected