MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / compare

Method compare

launcher/minecraft/mod/Resource.cpp:60–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60std::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
92bool Resource::applyFilter(QRegularExpression filter) const
93{

Callers

nothing calls this directly

Calls 4

removeThePrefixFunction · 0.85
enabledMethod · 0.80
dateTimeChangedMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected