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

Method setVersions

launcher/meta/VersionList.cpp:156–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156void VersionList::setVersions(const QVector<VersionPtr> &versions)
157{
158 beginResetModel();
159 m_versions = versions;
160 std::sort(m_versions.begin(), m_versions.end(), [](const VersionPtr &a, const VersionPtr &b)
161 {
162 return a->rawTime() > b->rawTime();
163 });
164 for (int i = 0; i < m_versions.size(); ++i)
165 {
166 m_lookup.insert(m_versions.at(i)->version(), m_versions.at(i));
167 setupAddedVersion(i, m_versions.at(i));
168 }
169
170 // FIXME: this is dumb, we have 'recommended' as part of the metadata already...
171 auto recommendedIt = std::find_if(m_versions.constBegin(), m_versions.constEnd(), [](const VersionPtr &ptr) { return ptr->type() == "release"; });
172 m_recommended = recommendedIt == m_versions.constEnd() ? nullptr : *recommendedIt;
173 endResetModel();
174}
175
176void VersionList::parse(const QJsonObject& obj)
177{

Callers 1

parseVersionListInternalFunction · 0.80

Calls 8

beginMethod · 0.80
endMethod · 0.80
rawTimeMethod · 0.80
insertMethod · 0.80
sizeMethod · 0.45
versionMethod · 0.45
atMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected