refactor: move "get versions" task from page to model

This seems more reasonable
This commit is contained in:
flow
2022-03-06 15:23:00 -03:00
parent 5e9d49a910
commit 5a638fa977
8 changed files with 30 additions and 23 deletions

View File

@ -97,6 +97,26 @@ void ListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallbac
}
}
void ListModel::populateVersions(ModPlatform::IndexedPack const& current)
{
auto netJob = new NetJob(QString("%1::ModVersions(%2)").arg(m_parent->debugName()).arg(current.name), APPLICATION->network());
auto response = new QByteArray();
QString addonId = current.addonId.toString();
netJob->addNetAction(Net::Download::makeByteArray(m_parent->apiProvider()->getVersionsURL(addonId), response));
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId]{
m_parent->onGetVersionsSucceeded(m_parent, response, addonId);
});
QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {
netJob->deleteLater();
delete response;
});
netJob->start();
}
void ListModel::performPaginatedSearch()
{
QString mcVersion = ((MinecraftInstance*)((ModPage*)parent())->m_instance)->getPackProfile()->getComponentVersion("net.minecraft");