2022-06-05 00:52:46 +05:30
|
|
|
#include "ModUpdateDialog.h"
|
|
|
|
#include "ChooseProviderDialog.h"
|
|
|
|
#include "CustomMessageBox.h"
|
|
|
|
#include "ProgressDialog.h"
|
|
|
|
#include "ScrollMessageBox.h"
|
|
|
|
#include "ui_ReviewMessageBox.h"
|
|
|
|
|
|
|
|
#include "FileSystem.h"
|
|
|
|
#include "Json.h"
|
|
|
|
|
|
|
|
#include "minecraft/MinecraftInstance.h"
|
|
|
|
#include "minecraft/PackProfile.h"
|
|
|
|
|
|
|
|
#include "modplatform/EnsureMetadataTask.h"
|
|
|
|
#include "modplatform/flame/FlameCheckUpdate.h"
|
|
|
|
#include "modplatform/modrinth/ModrinthCheckUpdate.h"
|
|
|
|
|
|
|
|
#include <HoeDown.h>
|
2022-06-20 21:31:49 +05:30
|
|
|
#include <QTextBrowser>
|
2022-06-05 00:52:46 +05:30
|
|
|
#include <QTreeWidgetItem>
|
|
|
|
|
|
|
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
|
|
|
|
|
|
|
static std::list<Version> mcVersions(BaseInstance* inst)
|
|
|
|
{
|
|
|
|
return { static_cast<MinecraftInstance*>(inst)->getPackProfile()->getComponent("net.minecraft")->getVersion() };
|
|
|
|
}
|
|
|
|
|
|
|
|
static ModAPI::ModLoaderTypes mcLoaders(BaseInstance* inst)
|
|
|
|
{
|
|
|
|
return { static_cast<MinecraftInstance*>(inst)->getPackProfile()->getModLoaders() };
|
|
|
|
}
|
|
|
|
|
|
|
|
ModUpdateDialog::ModUpdateDialog(QWidget* parent,
|
|
|
|
BaseInstance* instance,
|
2022-06-16 20:15:29 +05:30
|
|
|
const std::shared_ptr<ModFolderModel> mods,
|
2022-06-26 22:47:15 +05:30
|
|
|
std::list<Mod::Ptr>& search_for)
|
2022-06-05 00:52:46 +05:30
|
|
|
: ReviewMessageBox(parent, tr("Confirm mods to update"), "")
|
|
|
|
, m_parent(parent)
|
|
|
|
, m_mod_model(mods)
|
|
|
|
, m_candidates(search_for)
|
2022-06-16 20:15:29 +05:30
|
|
|
, m_second_try_metadata(new SequentialTask())
|
2022-06-05 00:52:46 +05:30
|
|
|
, m_instance(instance)
|
|
|
|
{
|
|
|
|
ReviewMessageBox::setGeometry(0, 0, 800, 600);
|
|
|
|
|
|
|
|
ui->explainLabel->setText(tr("You're about to update the following mods:"));
|
|
|
|
ui->onlyCheckedLabel->setText(tr("Only mods with a check will be updated!"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModUpdateDialog::checkCandidates()
|
|
|
|
{
|
|
|
|
// Ensure mods have valid metadata
|
|
|
|
auto went_well = ensureMetadata();
|
|
|
|
if (!went_well) {
|
|
|
|
m_aborted = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Report failed metadata generation
|
|
|
|
if (!m_failed_metadata.empty()) {
|
|
|
|
QString text;
|
2022-06-20 17:25:35 +05:30
|
|
|
for (const auto& failed : m_failed_metadata) {
|
|
|
|
const auto& mod = std::get<0>(failed);
|
|
|
|
const auto& reason = std::get<1>(failed);
|
2022-06-26 22:47:15 +05:30
|
|
|
text += tr("Mod name: %1<br>File name: %2<br>Reason: %3<br><br>").arg(mod->name(), mod->fileinfo().fileName(), reason);
|
2022-06-05 00:52:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
ScrollMessageBox message_dialog(m_parent, tr("Metadata generation failed"),
|
2022-06-20 21:31:49 +05:30
|
|
|
tr("Could not generate metadata for the following mods:<br>"
|
|
|
|
"Do you wish to proceed without those mods?"),
|
|
|
|
text);
|
2022-06-05 00:52:46 +05:30
|
|
|
message_dialog.setModal(true);
|
|
|
|
if (message_dialog.exec() == QDialog::Rejected) {
|
|
|
|
m_aborted = true;
|
|
|
|
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto versions = mcVersions(m_instance);
|
|
|
|
auto loaders = mcLoaders(m_instance);
|
|
|
|
|
2022-06-20 21:31:49 +05:30
|
|
|
SequentialTask check_task(m_parent, tr("Checking for updates"));
|
2022-06-16 20:15:29 +05:30
|
|
|
|
2022-06-05 00:52:46 +05:30
|
|
|
if (!m_modrinth_to_update.empty()) {
|
|
|
|
m_modrinth_check_task = new ModrinthCheckUpdate(m_modrinth_to_update, versions, loaders, m_mod_model);
|
|
|
|
connect(m_modrinth_check_task, &CheckUpdateTask::checkFailed, this,
|
2022-06-26 22:47:15 +05:30
|
|
|
[this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.emplace_back(mod, reason, recover_url); });
|
2022-06-16 20:15:29 +05:30
|
|
|
check_task.addTask(m_modrinth_check_task);
|
2022-06-05 00:52:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_flame_to_update.empty()) {
|
|
|
|
m_flame_check_task = new FlameCheckUpdate(m_flame_to_update, versions, loaders, m_mod_model);
|
|
|
|
connect(m_flame_check_task, &CheckUpdateTask::checkFailed, this,
|
2022-06-26 22:47:15 +05:30
|
|
|
[this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.emplace_back(mod, reason, recover_url); });
|
2022-06-16 20:15:29 +05:30
|
|
|
check_task.addTask(m_flame_check_task);
|
2022-06-05 00:52:46 +05:30
|
|
|
}
|
|
|
|
|
2022-06-16 20:15:29 +05:30
|
|
|
connect(&check_task, &Task::failed, this,
|
|
|
|
[&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
|
|
|
|
|
|
|
|
connect(&check_task, &Task::succeeded, this, [&]() {
|
|
|
|
QStringList warnings = check_task.warnings();
|
|
|
|
if (warnings.count()) {
|
|
|
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->exec();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-06-05 00:52:46 +05:30
|
|
|
// Check for updates
|
2022-06-16 20:15:29 +05:30
|
|
|
// FIXME: SOMEHOW THIS IS NOT MODAL???????
|
2022-06-05 00:52:46 +05:30
|
|
|
ProgressDialog progress_dialog(m_parent);
|
|
|
|
progress_dialog.setSkipButton(true, tr("Abort"));
|
|
|
|
progress_dialog.setVisible(true);
|
|
|
|
progress_dialog.setWindowTitle(tr("Checking for updates..."));
|
2022-06-16 20:15:29 +05:30
|
|
|
auto ret = progress_dialog.execWithTask(&check_task);
|
2022-06-05 00:52:46 +05:30
|
|
|
|
|
|
|
// If the dialog was skipped / some download error happened
|
|
|
|
if (ret == QDialog::DialogCode::Rejected) {
|
|
|
|
m_aborted = true;
|
|
|
|
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add found updates for Modrinth
|
|
|
|
if (m_modrinth_check_task) {
|
|
|
|
auto modrinth_updates = m_modrinth_check_task->getUpdatable();
|
|
|
|
for (auto& updatable : modrinth_updates) {
|
|
|
|
qDebug() << QString("Mod %1 has an update available!").arg(updatable.name);
|
|
|
|
|
|
|
|
appendMod(updatable);
|
|
|
|
m_tasks.insert(updatable.name, updatable.download);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add found updated for Flame
|
|
|
|
if (m_flame_check_task) {
|
|
|
|
auto flame_updates = m_flame_check_task->getUpdatable();
|
|
|
|
for (auto& updatable : flame_updates) {
|
|
|
|
qDebug() << QString("Mod %1 has an update available!").arg(updatable.name);
|
|
|
|
|
|
|
|
appendMod(updatable);
|
|
|
|
m_tasks.insert(updatable.name, updatable.download);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Report failed update checking
|
|
|
|
if (!m_failed_check_update.empty()) {
|
|
|
|
QString text;
|
|
|
|
for (const auto& failed : m_failed_check_update) {
|
|
|
|
const auto& mod = std::get<0>(failed);
|
|
|
|
const auto& reason = std::get<1>(failed);
|
|
|
|
const auto& recover_url = std::get<2>(failed);
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
qDebug() << mod->name() << " failed to check for updates!";
|
2022-06-05 00:52:46 +05:30
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
text += tr("Mod name: %1").arg(mod->name()) + "<br>";
|
2022-06-05 00:52:46 +05:30
|
|
|
if (!reason.isEmpty())
|
|
|
|
text += tr("Reason: %1").arg(reason) + "<br>";
|
|
|
|
if (!recover_url.isEmpty())
|
|
|
|
text += tr("Possible solution: ") + tr("Getting the latest version manually:") + "<br>" +
|
|
|
|
QString("<a href='%1'>").arg(recover_url.toString()) + recover_url.toString() + "</a><br>";
|
|
|
|
text += "<br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollMessageBox message_dialog(m_parent, tr("Failed to check for updates"),
|
2022-06-20 21:31:49 +05:30
|
|
|
tr("Could not check or get the following mods for updates:<br>"
|
|
|
|
"Do you wish to proceed without those mods?"),
|
|
|
|
text);
|
2022-06-05 00:52:46 +05:30
|
|
|
message_dialog.setModal(true);
|
|
|
|
if (message_dialog.exec() == QDialog::Rejected) {
|
|
|
|
m_aborted = true;
|
|
|
|
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there's no mod to be updated
|
2022-06-20 21:31:49 +05:30
|
|
|
if (ui->modTreeWidget->topLevelItemCount() == 0) {
|
2022-06-05 00:52:46 +05:30
|
|
|
m_no_updates = true;
|
2022-06-20 21:31:49 +05:30
|
|
|
} else {
|
|
|
|
// FIXME: Find a more efficient way of doing this!
|
|
|
|
|
|
|
|
// Sort major items in alphabetical order (also sorts the children unfortunately)
|
|
|
|
ui->modTreeWidget->sortItems(0, Qt::SortOrder::AscendingOrder);
|
|
|
|
|
|
|
|
// Re-sort the children
|
|
|
|
auto* item = ui->modTreeWidget->topLevelItem(0);
|
|
|
|
for (int i = 1; item != nullptr; ++i) {
|
|
|
|
item->sortChildren(0, Qt::SortOrder::DescendingOrder);
|
|
|
|
item = ui->modTreeWidget->topLevelItem(i);
|
|
|
|
}
|
|
|
|
}
|
2022-06-05 00:52:46 +05:30
|
|
|
|
|
|
|
if (m_aborted || m_no_updates)
|
|
|
|
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Part 1: Ensure we have a valid metadata
|
|
|
|
auto ModUpdateDialog::ensureMetadata() -> bool
|
|
|
|
{
|
|
|
|
auto index_dir = indexDir();
|
|
|
|
|
2022-06-16 20:15:29 +05:30
|
|
|
SequentialTask seq(m_parent, tr("Looking for metadata"));
|
|
|
|
|
|
|
|
// A better use of data structures here could remove the need for this QHash
|
|
|
|
QHash<QString, bool> should_try_others;
|
2022-06-26 22:47:15 +05:30
|
|
|
std::list<Mod*> modrinth_tmp;
|
|
|
|
std::list<Mod*> flame_tmp;
|
2022-06-05 00:52:46 +05:30
|
|
|
|
|
|
|
bool confirm_rest = false;
|
|
|
|
bool try_others_rest = false;
|
|
|
|
bool skip_rest = false;
|
|
|
|
ModPlatform::Provider provider_rest = ModPlatform::Provider::MODRINTH;
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
auto addToTmp = [&](Mod* m, ModPlatform::Provider p) {
|
2022-06-16 20:15:29 +05:30
|
|
|
switch (p) {
|
|
|
|
case ModPlatform::Provider::MODRINTH:
|
|
|
|
modrinth_tmp.push_back(m);
|
|
|
|
break;
|
|
|
|
case ModPlatform::Provider::FLAME:
|
|
|
|
flame_tmp.push_back(m);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
for (auto candidate : m_candidates) {
|
|
|
|
auto* candidate_ptr = candidate.get();
|
|
|
|
if (candidate->status() != ModStatus::NoMetadata) {
|
|
|
|
onMetadataEnsured(candidate_ptr);
|
2022-06-05 00:52:46 +05:30
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skip_rest)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (confirm_rest) {
|
2022-06-26 22:47:15 +05:30
|
|
|
addToTmp(candidate_ptr, provider_rest);
|
|
|
|
should_try_others.insert(candidate->internal_id(), try_others_rest);
|
2022-06-05 00:52:46 +05:30
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChooseProviderDialog chooser(this);
|
|
|
|
chooser.setDescription(tr("This mod (%1) does not have a metadata yet. We need to create one in order to keep relevant "
|
|
|
|
"information on how to update this "
|
|
|
|
"mod. To do this, please select a mod provider from which we can search for updates for %1.")
|
2022-06-26 22:47:15 +05:30
|
|
|
.arg(candidate->name()));
|
2022-06-05 00:52:46 +05:30
|
|
|
auto confirmed = chooser.exec() == QDialog::DialogCode::Accepted;
|
|
|
|
|
|
|
|
auto response = chooser.getResponse();
|
|
|
|
|
|
|
|
if (response.skip_all)
|
|
|
|
skip_rest = true;
|
|
|
|
if (response.confirm_all) {
|
|
|
|
confirm_rest = true;
|
|
|
|
provider_rest = response.chosen;
|
|
|
|
try_others_rest = response.try_others;
|
|
|
|
}
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
should_try_others.insert(candidate->internal_id(), response.try_others);
|
2022-06-16 20:15:29 +05:30
|
|
|
|
|
|
|
if (confirmed)
|
2022-06-26 22:47:15 +05:30
|
|
|
addToTmp(candidate_ptr, response.chosen);
|
2022-06-05 00:52:46 +05:30
|
|
|
}
|
|
|
|
|
2022-06-16 20:15:29 +05:30
|
|
|
if (!modrinth_tmp.empty()) {
|
|
|
|
auto* modrinth_task = new EnsureMetadataTask(modrinth_tmp, index_dir, ModPlatform::Provider::MODRINTH);
|
2022-06-26 22:47:15 +05:30
|
|
|
connect(modrinth_task, &EnsureMetadataTask::metadataReady, [this](Mod* candidate) { onMetadataEnsured(candidate); });
|
|
|
|
connect(modrinth_task, &EnsureMetadataTask::metadataFailed, [this, &should_try_others](Mod* candidate) {
|
|
|
|
onMetadataFailed(candidate, should_try_others.find(candidate->internal_id()).value(), ModPlatform::Provider::MODRINTH);
|
2022-06-16 20:15:29 +05:30
|
|
|
});
|
|
|
|
seq.addTask(modrinth_task);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flame_tmp.empty()) {
|
|
|
|
auto* flame_task = new EnsureMetadataTask(flame_tmp, index_dir, ModPlatform::Provider::FLAME);
|
2022-06-26 22:47:15 +05:30
|
|
|
connect(flame_task, &EnsureMetadataTask::metadataReady, [this](Mod* candidate) { onMetadataEnsured(candidate); });
|
|
|
|
connect(flame_task, &EnsureMetadataTask::metadataFailed, [this, &should_try_others](Mod* candidate) {
|
|
|
|
onMetadataFailed(candidate, should_try_others.find(candidate->internal_id()).value(), ModPlatform::Provider::FLAME);
|
2022-06-16 20:15:29 +05:30
|
|
|
});
|
|
|
|
seq.addTask(flame_task);
|
|
|
|
}
|
|
|
|
|
|
|
|
seq.addTask(m_second_try_metadata);
|
|
|
|
|
2022-06-05 00:52:46 +05:30
|
|
|
ProgressDialog checking_dialog(m_parent);
|
|
|
|
checking_dialog.setSkipButton(true, tr("Abort"));
|
|
|
|
checking_dialog.setWindowTitle(tr("Generating metadata..."));
|
2022-06-16 20:15:29 +05:30
|
|
|
auto ret_metadata = checking_dialog.execWithTask(&seq);
|
2022-06-05 00:52:46 +05:30
|
|
|
|
|
|
|
return (ret_metadata != QDialog::DialogCode::Rejected);
|
|
|
|
}
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
void ModUpdateDialog::onMetadataEnsured(Mod* mod)
|
2022-06-05 00:52:46 +05:30
|
|
|
{
|
|
|
|
// When the mod is a folder, for instance
|
2022-06-26 22:47:15 +05:30
|
|
|
if (!mod->metadata())
|
2022-06-05 00:52:46 +05:30
|
|
|
return;
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
switch (mod->metadata()->provider) {
|
2022-06-05 00:52:46 +05:30
|
|
|
case ModPlatform::Provider::MODRINTH:
|
|
|
|
m_modrinth_to_update.push_back(mod);
|
|
|
|
break;
|
|
|
|
case ModPlatform::Provider::FLAME:
|
|
|
|
m_flame_to_update.push_back(mod);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-16 20:15:29 +05:30
|
|
|
ModPlatform::Provider next(ModPlatform::Provider p)
|
2022-06-05 00:52:46 +05:30
|
|
|
{
|
2022-06-16 20:15:29 +05:30
|
|
|
switch (p) {
|
|
|
|
case ModPlatform::Provider::MODRINTH:
|
|
|
|
return ModPlatform::Provider::FLAME;
|
|
|
|
case ModPlatform::Provider::FLAME:
|
|
|
|
return ModPlatform::Provider::MODRINTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ModPlatform::Provider::FLAME;
|
|
|
|
}
|
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
void ModUpdateDialog::onMetadataFailed(Mod* mod, bool try_others, ModPlatform::Provider first_choice)
|
2022-06-16 20:15:29 +05:30
|
|
|
{
|
|
|
|
if (try_others) {
|
|
|
|
auto index_dir = indexDir();
|
|
|
|
|
|
|
|
auto* task = new EnsureMetadataTask(mod, index_dir, next(first_choice));
|
2022-06-26 22:47:15 +05:30
|
|
|
connect(task, &EnsureMetadataTask::metadataReady, [this](Mod* candidate) { onMetadataEnsured(candidate); });
|
|
|
|
connect(task, &EnsureMetadataTask::metadataFailed, [this](Mod* candidate) { onMetadataFailed(candidate, false); });
|
2022-06-16 20:15:29 +05:30
|
|
|
|
|
|
|
m_second_try_metadata->addTask(task);
|
|
|
|
} else {
|
2022-06-20 21:31:49 +05:30
|
|
|
QString reason{ tr("Didn't find a valid version on the selected mod provider(s)") };
|
2022-06-20 17:25:35 +05:30
|
|
|
|
|
|
|
m_failed_metadata.emplace_back(mod, reason);
|
2022-06-16 20:15:29 +05:30
|
|
|
}
|
2022-06-05 00:52:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info)
|
|
|
|
{
|
|
|
|
auto item_top = new QTreeWidgetItem(ui->modTreeWidget);
|
|
|
|
item_top->setCheckState(0, Qt::CheckState::Checked);
|
|
|
|
item_top->setText(0, info.name);
|
|
|
|
item_top->setExpanded(true);
|
|
|
|
|
|
|
|
auto provider_item = new QTreeWidgetItem(item_top);
|
|
|
|
provider_item->setText(0, tr("Provider: %1").arg(ProviderCaps.readableName(info.provider)));
|
|
|
|
|
|
|
|
auto old_version_item = new QTreeWidgetItem(item_top);
|
|
|
|
old_version_item->setText(0, tr("Old version: %1").arg(info.old_version.isEmpty() ? tr("Not installed") : info.old_version));
|
|
|
|
|
|
|
|
auto new_version_item = new QTreeWidgetItem(item_top);
|
|
|
|
new_version_item->setText(0, tr("New version: %1").arg(info.new_version));
|
|
|
|
|
|
|
|
auto changelog_item = new QTreeWidgetItem(item_top);
|
|
|
|
changelog_item->setText(0, tr("Changelog of the latest version"));
|
|
|
|
|
|
|
|
auto changelog = new QTreeWidgetItem(changelog_item);
|
2022-06-20 21:31:49 +05:30
|
|
|
auto changelog_area = new QTextBrowser();
|
2022-06-05 00:52:46 +05:30
|
|
|
|
2022-06-25 05:29:17 +05:30
|
|
|
|
2022-06-20 21:31:49 +05:30
|
|
|
switch (info.provider) {
|
|
|
|
case ModPlatform::Provider::MODRINTH: {
|
|
|
|
HoeDown h;
|
2022-06-25 05:29:17 +05:30
|
|
|
// HoeDown bug?: \n aren't converted to <br>
|
|
|
|
changelog_area->setHtml(h.process(info.changelog.toUtf8()).replace('\n', "<br>"));
|
2022-06-20 21:31:49 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ModPlatform::Provider::FLAME: {
|
|
|
|
changelog_area->setHtml(info.changelog);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-06-05 00:52:46 +05:30
|
|
|
|
2022-06-20 21:31:49 +05:30
|
|
|
changelog_area->setOpenExternalLinks(true);
|
2022-06-05 00:52:46 +05:30
|
|
|
|
2022-06-20 21:31:49 +05:30
|
|
|
ui->modTreeWidget->setItemWidget(changelog, 0, changelog_area);
|
2022-06-05 00:52:46 +05:30
|
|
|
|
|
|
|
ui->modTreeWidget->addTopLevelItem(item_top);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ModUpdateDialog::getTasks() -> const std::list<ModDownloadTask*>
|
|
|
|
{
|
|
|
|
std::list<ModDownloadTask*> list;
|
|
|
|
|
|
|
|
auto* item = ui->modTreeWidget->topLevelItem(0);
|
|
|
|
|
2022-06-11 01:10:39 +05:30
|
|
|
for (int i = 1; item != nullptr; ++i) {
|
2022-06-05 00:52:46 +05:30
|
|
|
if (item->checkState(0) == Qt::CheckState::Checked) {
|
|
|
|
list.push_back(m_tasks.find(item->text(0)).value());
|
|
|
|
}
|
|
|
|
|
|
|
|
item = ui->modTreeWidget->topLevelItem(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|