From 81036b0149eebc9033fd0cc089c1d9237c39cf14 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Wed, 9 Sep 2020 11:25:19 -0500 Subject: Fixes for bulk update check * Check game source for validity * Display name of source when no updates found --- src/modinfo.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/modinfo.cpp') diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 826aa5c9..19621345 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -312,6 +312,22 @@ bool ModInfo::checkAllForUpdate(PluginContainer *pluginContainer, QObject *recei } } + // Detect invalid source games + for (auto itr = games.begin(); itr != games.end(); ++itr) { + auto gamePlugins = pluginContainer->plugins(); + IPluginGame* gamePlugin = qApp->property("managed_game").value(); + for (auto plugin : gamePlugins) { + if (plugin != nullptr && plugin->gameShortName().compare(*itr, Qt::CaseInsensitive) == 0) { + gamePlugin = plugin; + break; + } + } + if (gamePlugin != nullptr && gamePlugin->gameNexusName().isEmpty()) { + log::warn("The update check has found a mod with a Nexus ID and source game of {}, but this game is not a valid Nexus source.", gamePlugin->gameName()); + itr = games.erase(itr); + } + } + if (latest < QDateTime::currentDateTimeUtc().addMonths(-1)) { std::set> organizedGames; for (auto mod : s_Collection) { -- cgit v1.3.1 From 10234e436ad28596fb36dc77440422cd49366b56 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Wed, 9 Sep 2020 12:37:34 -0500 Subject: Traslate lines, use QPair --- src/mainwindow.cpp | 18 +++++++++--------- src/modinfo.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/modinfo.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a4b87690..08eac98c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4199,7 +4199,7 @@ void MainWindow::checkModsForUpdates() m_OrganizerCore.doAfterLogin([this] () { this->checkModsForUpdates(); }); NexusInterface::instance(&m_PluginContainer)->getAccessManager()->apiCheck(apiKey); } else { - log::warn("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus."); + log::warn(tr("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus.").toStdString()); } } @@ -5406,7 +5406,7 @@ void MainWindow::modUpdateCheck(std::multimap IDs) m_OrganizerCore.doAfterLogin([=]() { this->modUpdateCheck(IDs); }); NexusInterface::instance(&m_PluginContainer)->getAccessManager()->apiCheck(apiKey); } else - log::warn("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus."); + log::warn(tr("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus.").toStdString()); } } @@ -5524,10 +5524,10 @@ void MainWindow::nxmUpdateInfoAvailable(QString gameName, QVariant userData, QVa } QVariantList resultList = resultData.toList(); - QFutureWatcher>>> *watcher = new QFutureWatcher>>>(); - QObject::connect(watcher, &QFutureWatcher>>::finished, this, &MainWindow::finishUpdateInfo); - QFuture>>> future = QtConcurrent::run([=]() -> std::pair>> { - return std::make_pair(gameNameReal, ModInfo::filteredMods(gameNameReal, resultList, userData.toBool(), true)); + QFutureWatcher>>> *watcher = new QFutureWatcher>>>(); + QObject::connect(watcher, &QFutureWatcher>>>::finished, this, &MainWindow::finishUpdateInfo); + QFuture>>> future = QtConcurrent::run([=]() -> QPair>> { + return qMakePair(gameNameReal, ModInfo::filteredMods(gameNameReal, resultList, userData.toBool(), true)); }); watcher->setFuture(future); if (m_ModListSortProxy != nullptr) @@ -5536,13 +5536,13 @@ void MainWindow::nxmUpdateInfoAvailable(QString gameName, QVariant userData, QVa void MainWindow::finishUpdateInfo() { - QFutureWatcher>>> *watcher = static_cast>>> *>(sender()); + QFutureWatcher>>> *watcher = static_cast>>> *>(sender()); QString game = watcher->result().first; auto finalMods = watcher->result().second; if (finalMods.empty()) { - log::info("None of your {} mods appear to have had recent file updates.", game); + log::info(tr("None of your {} mods appear to have had recent file updates.").toStdString(), game); } std::set> organizedGames; @@ -5553,7 +5553,7 @@ void MainWindow::finishUpdateInfo() } if (!finalMods.empty() && organizedGames.empty()) - log::warn("All of your mods have been checked recently. We restrict update checks to help preserve your available API requests."); + log::warn(tr("All of your mods have been checked recently. We restrict update checks to help preserve your available API requests.").toStdString()); for (auto game : organizedGames) NexusInterface::instance(&m_PluginContainer)->requestUpdates(game.second, this, QVariant(), game.first, QString()); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 19621345..37ac0827 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -323,7 +323,7 @@ bool ModInfo::checkAllForUpdate(PluginContainer *pluginContainer, QObject *recei } } if (gamePlugin != nullptr && gamePlugin->gameNexusName().isEmpty()) { - log::warn("The update check has found a mod with a Nexus ID and source game of {}, but this game is not a valid Nexus source.", gamePlugin->gameName()); + log::warn(tr("The update check has found a mod with a Nexus ID and source game of {}, but this game is not a valid Nexus source.").toStdString(), gamePlugin->gameName()); itr = games.erase(itr); } } -- cgit v1.3.1 From d30d966500525cfe3137044c97db024230aac802 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Wed, 9 Sep 2020 13:21:56 -0500 Subject: Standardizing --- src/mainwindow.cpp | 18 +++++++++--------- src/modinfo.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/modinfo.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 08eac98c..b3682297 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4199,7 +4199,7 @@ void MainWindow::checkModsForUpdates() m_OrganizerCore.doAfterLogin([this] () { this->checkModsForUpdates(); }); NexusInterface::instance(&m_PluginContainer)->getAccessManager()->apiCheck(apiKey); } else { - log::warn(tr("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus.").toStdString()); + log::warn("{}", tr("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus.")); } } @@ -5406,7 +5406,7 @@ void MainWindow::modUpdateCheck(std::multimap IDs) m_OrganizerCore.doAfterLogin([=]() { this->modUpdateCheck(IDs); }); NexusInterface::instance(&m_PluginContainer)->getAccessManager()->apiCheck(apiKey); } else - log::warn(tr("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus.").toStdString()); + log::warn("{}", tr("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus.")); } } @@ -5524,10 +5524,10 @@ void MainWindow::nxmUpdateInfoAvailable(QString gameName, QVariant userData, QVa } QVariantList resultList = resultData.toList(); - QFutureWatcher>>> *watcher = new QFutureWatcher>>>(); - QObject::connect(watcher, &QFutureWatcher>>>::finished, this, &MainWindow::finishUpdateInfo); - QFuture>>> future = QtConcurrent::run([=]() -> QPair>> { - return qMakePair(gameNameReal, ModInfo::filteredMods(gameNameReal, resultList, userData.toBool(), true)); + QFutureWatcher>>> *watcher = new QFutureWatcher>>>(); + QObject::connect(watcher, &QFutureWatcher>>::finished, this, &MainWindow::finishUpdateInfo); + QFuture>>> future = QtConcurrent::run([=]() -> std::pair>> { + return std::make_pair(gameNameReal, ModInfo::filteredMods(gameNameReal, resultList, userData.toBool(), true)); }); watcher->setFuture(future); if (m_ModListSortProxy != nullptr) @@ -5536,13 +5536,13 @@ void MainWindow::nxmUpdateInfoAvailable(QString gameName, QVariant userData, QVa void MainWindow::finishUpdateInfo() { - QFutureWatcher>>> *watcher = static_cast>>> *>(sender()); + QFutureWatcher>>> *watcher = static_cast>>> *>(sender()); QString game = watcher->result().first; auto finalMods = watcher->result().second; if (finalMods.empty()) { - log::info(tr("None of your {} mods appear to have had recent file updates.").toStdString(), game); + log::info("{}", tr("None of your %1 mods appear to have had recent file updates.").arg(game)); } std::set> organizedGames; @@ -5553,7 +5553,7 @@ void MainWindow::finishUpdateInfo() } if (!finalMods.empty() && organizedGames.empty()) - log::warn(tr("All of your mods have been checked recently. We restrict update checks to help preserve your available API requests.").toStdString()); + log::warn("{}", tr("All of your mods have been checked recently. We restrict update checks to help preserve your available API requests.")); for (auto game : organizedGames) NexusInterface::instance(&m_PluginContainer)->requestUpdates(game.second, this, QVariant(), game.first, QString()); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 37ac0827..b79ed657 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -323,7 +323,7 @@ bool ModInfo::checkAllForUpdate(PluginContainer *pluginContainer, QObject *recei } } if (gamePlugin != nullptr && gamePlugin->gameNexusName().isEmpty()) { - log::warn(tr("The update check has found a mod with a Nexus ID and source game of {}, but this game is not a valid Nexus source.").toStdString(), gamePlugin->gameName()); + log::warn("{}", tr("The update check has found a mod with a Nexus ID and source game of %1, but this game is not a valid Nexus source.").arg(gamePlugin->gameName())); itr = games.erase(itr); } } -- cgit v1.3.1