format the code

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-06-28 13:41:07 +03:00 committed by Rachel Powers
parent c4cc1cfe4f
commit 492c78a570
No known key found for this signature in database
GPG Key ID: E10E321EB160949B
2 changed files with 96 additions and 93 deletions

View File

@ -181,8 +181,8 @@ void ComponentUpdateTask::loadComponents()
} }
result = composeLoadResult(result, singleResult); result = composeLoadResult(result, singleResult);
if (loadTask) { if (loadTask) {
qCDebug(instanceProfileResolveC) << d->m_profile->d->m_instance->name() << "|" << "Remote loading is being run for" qCDebug(instanceProfileResolveC) << d->m_profile->d->m_instance->name() << "|"
<< component->getName(); << "Remote loading is being run for" << component->getName();
connect(loadTask.get(), &Task::succeeded, this, [this, taskIndex]() { remoteLoadSucceeded(taskIndex); }); connect(loadTask.get(), &Task::succeeded, this, [this, taskIndex]() { remoteLoadSucceeded(taskIndex); });
connect(loadTask.get(), &Task::failed, this, [this, taskIndex](const QString& error) { remoteLoadFailed(taskIndex, error); }); connect(loadTask.get(), &Task::failed, this, [this, taskIndex](const QString& error) { remoteLoadFailed(taskIndex, error); });
connect(loadTask.get(), &Task::aborted, this, [this, taskIndex]() { remoteLoadFailed(taskIndex, tr("Aborted")); }); connect(loadTask.get(), &Task::aborted, this, [this, taskIndex]() { remoteLoadFailed(taskIndex, tr("Aborted")); });
@ -392,8 +392,8 @@ ComponentContainer ComponentUpdateTask::collectTreeLinked(const QString& uid)
auto& componentIndex = d->m_profile->d->componentIndex; auto& componentIndex = d->m_profile->d->componentIndex;
auto& instance = d->m_profile->d->m_instance; auto& instance = d->m_profile->d->m_instance;
for (auto comp : components) { for (auto comp : components) {
qCDebug(instanceProfileResolveC) << instance->name() << "|" << "scanning" << comp->getID() << ":" << comp->getVersion() qCDebug(instanceProfileResolveC) << instance->name() << "|"
<< "for tree link"; << "scanning" << comp->getID() << ":" << comp->getVersion() << "for tree link";
auto dep = std::find_if(comp->m_cachedRequires.cbegin(), comp->m_cachedRequires.cend(), auto dep = std::find_if(comp->m_cachedRequires.cbegin(), comp->m_cachedRequires.cend(),
[uid](const Meta::Require& req) -> bool { return req.uid == uid; }); [uid](const Meta::Require& req) -> bool { return req.uid == uid; });
if (dep != comp->m_cachedRequires.cend()) { if (dep != comp->m_cachedRequires.cend()) {
@ -559,94 +559,98 @@ void ComponentUpdateTask::performUpdateActions()
continue; continue;
} }
auto action = component->getUpdateAction(); auto action = component->getUpdateAction();
auto visitor = overload{ auto visitor =
[](const UpdateActionNone&) { overload{ [](const UpdateActionNone&) {
// noop // noop
}, },
[&component, &instance](const UpdateActionChangeVersion& cv) { [&component, &instance](const UpdateActionChangeVersion& cv) {
qCDebug(instanceProfileResolveC) << instance->name() << "|" << "UpdateActionChangeVersion" << component->getID() << ":" qCDebug(instanceProfileResolveC) << instance->name() << "|"
<< component->getVersion() << "change to" << cv.targetVersion; << "UpdateActionChangeVersion" << component->getID() << ":"
component->setVersion(cv.targetVersion); << component->getVersion() << "change to" << cv.targetVersion;
component->waitLoadMeta(); component->setVersion(cv.targetVersion);
}, component->waitLoadMeta();
[&component, &instance](const UpdateActionLatestRecommendedCompatable lrc) { },
qCDebug(instanceProfileResolveC) [&component, &instance](const UpdateActionLatestRecommendedCompatable lrc) {
<< instance->name() << "|" << "UpdateActionLatestRecommendedCompatable" << component->getID() << ":" qCDebug(instanceProfileResolveC)
<< component->getVersion() << "updating to latest recommend or compatible with" << lrc.parentUid << lrc.version; << instance->name() << "|"
auto versionList = APPLICATION->metadataIndex()->get(component->getID()); << "UpdateActionLatestRecommendedCompatable" << component->getID() << ":" << component->getVersion()
versionList->waitToLoad(); << "updating to latest recommend or compatible with" << lrc.parentUid << lrc.version;
if (versionList) { auto versionList = APPLICATION->metadataIndex()->get(component->getID());
auto recommended = versionList->getRecommendedForParent(lrc.parentUid, lrc.version); versionList->waitToLoad();
if (recommended) { if (versionList) {
component->setVersion(recommended->version()); auto recommended = versionList->getRecommendedForParent(lrc.parentUid, lrc.version);
component->waitLoadMeta(); if (recommended) {
return; component->setVersion(recommended->version());
} component->waitLoadMeta();
return;
}
auto latest = versionList->getLatestForParent(lrc.parentUid, lrc.version); auto latest = versionList->getLatestForParent(lrc.parentUid, lrc.version);
if (latest) { if (latest) {
component->setVersion(latest->version()); component->setVersion(latest->version());
component->waitLoadMeta(); component->waitLoadMeta();
} else { } else {
component->addComponentProblem(ProblemSeverity::Error, component->addComponentProblem(ProblemSeverity::Error,
QObject::tr("No compatible version of %1 found for %2 %3") QObject::tr("No compatible version of %1 found for %2 %3")
.arg(component->getName(), lrc.parentName, lrc.version)); .arg(component->getName(), lrc.parentName, lrc.version));
} }
} else { } else {
component->addComponentProblem(ProblemSeverity::Error, component->addComponentProblem(
QObject::tr("No version list in metadata index for %1").arg(component->getID())); ProblemSeverity::Error,
} QObject::tr("No version list in metadata index for %1").arg(component->getID()));
}, }
[&component, &instance, &toRemove](const UpdateActionRemove&) { },
qCDebug(instanceProfileResolveC) << instance->name() << "|" << "UpdateActionRemove" << component->getID() << ":" [&component, &instance, &toRemove](const UpdateActionRemove&) {
<< component->getVersion() << "removing"; qCDebug(instanceProfileResolveC)
toRemove.append(component->getID()); << instance->name() << "|"
}, << "UpdateActionRemove" << component->getID() << ":" << component->getVersion() << "removing";
[this, &component, &instance, &addedActions, &componentIndex](const UpdateActionImportantChanged& ic) { toRemove.append(component->getID());
qCDebug(instanceProfileResolveC) },
<< instance->name() << "|" << "UpdateImportantChanged" << component->getID() << ":" << component->getVersion() [this, &component, &instance, &addedActions, &componentIndex](const UpdateActionImportantChanged& ic) {
<< "was changed from" << ic.oldVersion << "updating linked components"; qCDebug(instanceProfileResolveC)
auto oldVersion = APPLICATION->metadataIndex()->getLoadedVersion(component->getID(), ic.oldVersion); << instance->name() << "|"
for (auto oldReq : oldVersion->requiredSet()) { << "UpdateImportantChanged" << component->getID() << ":" << component->getVersion() << "was changed from"
auto currentlyRequired = component->m_cachedRequires.find(oldReq); << ic.oldVersion << "updating linked components";
if (currentlyRequired == component->m_cachedRequires.cend()) { auto oldVersion = APPLICATION->metadataIndex()->getLoadedVersion(component->getID(), ic.oldVersion);
auto oldReqComp = componentIndex.find(oldReq.uid); for (auto oldReq : oldVersion->requiredSet()) {
if (oldReqComp != componentIndex.cend()) { auto currentlyRequired = component->m_cachedRequires.find(oldReq);
(*oldReqComp)->setUpdateAction(UpdateAction{ UpdateActionRemove{} }); if (currentlyRequired == component->m_cachedRequires.cend()) {
addedActions = true; auto oldReqComp = componentIndex.find(oldReq.uid);
} if (oldReqComp != componentIndex.cend()) {
} (*oldReqComp)->setUpdateAction(UpdateAction{ UpdateActionRemove{} });
} addedActions = true;
auto linked = collectTreeLinked(component->getID()); }
for (auto comp : linked) { }
if (comp->isCustom()) { }
continue; auto linked = collectTreeLinked(component->getID());
} for (auto comp : linked) {
auto compUid = comp->getID(); if (comp->isCustom()) {
auto parentReq = std::find_if(component->m_cachedRequires.begin(), component->m_cachedRequires.end(), continue;
[compUid](const Meta::Require& req) { return req.uid == compUid; }); }
if (parentReq != component->m_cachedRequires.end()) { auto compUid = comp->getID();
auto newVersion = parentReq->equalsVersion.isEmpty() ? parentReq->suggests : parentReq->equalsVersion; auto parentReq = std::find_if(component->m_cachedRequires.begin(), component->m_cachedRequires.end(),
if (!newVersion.isEmpty()) { [compUid](const Meta::Require& req) { return req.uid == compUid; });
comp->setUpdateAction(UpdateAction{ UpdateActionChangeVersion{ newVersion } }); if (parentReq != component->m_cachedRequires.end()) {
} else { auto newVersion = parentReq->equalsVersion.isEmpty() ? parentReq->suggests : parentReq->equalsVersion;
comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatable{ if (!newVersion.isEmpty()) {
component->getID(), comp->setUpdateAction(UpdateAction{ UpdateActionChangeVersion{ newVersion } });
component->getName(), } else {
component->getVersion(), comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatable{
} }); component->getID(),
} component->getName(),
} else { component->getVersion(),
comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatable{ } });
component->getID(), }
component->getName(), } else {
component->getVersion(), comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatable{
} }); component->getID(),
} component->getName(),
addedActions = true; component->getVersion(),
} } });
} }
}; addedActions = true;
}
} };
std::visit(visitor, action); std::visit(visitor, action);
component->clearUpdateAction(); component->clearUpdateAction();
for (auto uid : toRemove) { for (auto uid : toRemove) {
@ -690,7 +694,7 @@ void ComponentUpdateTask::finalizeComponents()
auto found = componentIndex.find(conflict); auto found = componentIndex.find(conflict);
if (found != componentIndex.cend()) { if (found != componentIndex.cend()) {
auto foundComp = *found; auto foundComp = *found;
if (foundComp ->isCustom()) { if (foundComp->isCustom()) {
continue; continue;
} }
component->addComponentProblem( component->addComponentProblem(

View File

@ -71,7 +71,6 @@
#include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/CustomMessageBox.h"
PackProfile::PackProfile(MinecraftInstance* instance) : QAbstractListModel() PackProfile::PackProfile(MinecraftInstance* instance) : QAbstractListModel()
{ {
d.reset(new PackProfileData); d.reset(new PackProfileData);