MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / compare

Method compare

launcher/minecraft/mod/Mod.cpp:82–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82int Mod::compare(const Resource& other, SortType type) const
83{
84 auto cast_other = dynamic_cast<Mod const*>(&other);
85 if (!cast_other)
86 return Resource::compare(other, type);
87
88 switch (type) {
89 default:
90 case SortType::ENABLED:
91 case SortType::NAME:
92 case SortType::DATE:
93 case SortType::SIZE:
94 return Resource::compare(other, type);
95 case SortType::VERSION: {
96 auto this_ver = Version(version());
97 auto other_ver = Version(cast_other->version());
98 if (this_ver > other_ver)
99 return 1;
100 if (this_ver < other_ver)
101 return -1;
102 break;
103 }
104 case SortType::PROVIDER: {
105 return QString::compare(provider().value_or("Unknown"), cast_other->provider().value_or("Unknown"), Qt::CaseInsensitive);
106 }
107 case SortType::SIDE: {
108 if (side() > cast_other->side())
109 return 1;
110 else if (side() < cast_other->side())
111 return -1;
112 break;
113 }
114 case SortType::LOADERS: {
115 if (loaders() > cast_other->loaders())
116 return 1;
117 else if (loaders() < cast_other->loaders())
118 return -1;
119 break;
120 }
121 case SortType::MC_VERSIONS: {
122 auto thisVersion = mcVersions().join(",");
123 auto otherVersion = cast_other->mcVersions().join(",");
124 return QString::compare(thisVersion, otherVersion, Qt::CaseInsensitive);
125 }
126 case SortType::RELEASE_TYPE: {
127 if (releaseType() > cast_other->releaseType())
128 return 1;
129 else if (releaseType() < cast_other->releaseType())
130 return -1;
131 break;
132 }
133 }
134 return 0;
135}
136
137bool Mod::applyFilter(QRegularExpression filter) const
138{

Callers 7

runMethod · 0.45
subSortLessThanMethod · 0.45
pathMethod · 0.45
checkMatchHashMethod · 0.45
checkValidPathMethod · 0.45
lessThanMethod · 0.45

Calls 8

mcVersionsFunction · 0.85
providerMethod · 0.80
sideMethod · 0.80
loadersMethod · 0.80
mcVersionsMethod · 0.80
releaseTypeMethod · 0.80
VersionClass · 0.70
versionMethod · 0.45

Tested by

no test coverage detected