summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2019-01-29 20:10:53 -0600
committerSilarn <jrim@rimpo.org>2019-02-18 21:29:23 -0600
commitf07f6b8904f69a92cd24e3c52eaf1fc6db8e60dd (patch)
tree8433556283b516a4dda97bbae86e6c1855e20272 /src/mainwindow.cpp
parentef286a938d79f74947a392d049068e4818ccf7fd (diff)
Update Process Improvements
* 5 minute batch auto-update of up to 10 mods - Still able to force an update of all 'unchecked' mods - Prioritizes mods with oldest update 'age' * Implemented 1-hour wait between update checks per mod * Fixed issues with update progress display * Only enable update filter automatically if 'force update' * Improved display of version update status in mod list - Italic text when ready to perform update check - Tooltip indicates when next update is available * Fixed remaining issues with update fallback check * Only trigger one update API request for duplicate sources
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 094a44af..b57c62f8 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -400,7 +400,7 @@ MainWindow::MainWindow(QSettings &initSettings
connect(NexusInterface::instance(&pluginContainer), SIGNAL(nxmDownloadURLsAvailable(QString,int,int,QVariant,QVariant,int)), this, SLOT(nxmDownloadURLs(QString,int,int,QVariant,QVariant,int)));
connect(NexusInterface::instance(&pluginContainer), SIGNAL(needLogin()), &m_OrganizerCore, SLOT(nexusApi()));
connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(validateFailed(QString)), this, SLOT(validationFailed(QString)));
- connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const QString&, bool)),
+ connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const QString&, bool, std::tuple<int, int, int, int>)),
this, SLOT(updateWindowTitle(const QString&, bool)));
connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const QString&, bool, std::tuple<int, int, int, int>)),
NexusInterface::instance(&m_PluginContainer), SLOT(setRateMax(const QString&, bool, std::tuple<int, int, int, int>)));
@@ -439,6 +439,10 @@ MainWindow::MainWindow(QSettings &initSettings
connect(&m_SaveMetaTimer, SIGNAL(timeout()), this, SLOT(saveModMetas()));
m_SaveMetaTimer.start(5000);
+ m_ModUpdateTimer.setSingleShot(false);
+ connect(&m_ModUpdateTimer, SIGNAL(timeout()), this, SLOT(modUpdateCheck()));
+ m_ModUpdateTimer.start(300 * 1000);
+
setCategoryListVisible(initSettings.value("categorylist_visible", true).toBool());
FileDialogMemory::restore(initSettings);
@@ -491,6 +495,8 @@ MainWindow::MainWindow(QSettings &initSettings
updatePluginCount();
updateModCount();
+
+ modUpdateCheck();
}
@@ -3996,6 +4002,14 @@ void MainWindow::checkModsForUpdates()
m_ModsToUpdate = ModInfo::checkAllForUpdate(&m_PluginContainer, this);
}
}
+
+ m_ModListSortProxy->setCategoryFilter(boost::assign::list_of(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE));
+ for (int i = 0; i < ui->categoriesList->topLevelItemCount(); ++i) {
+ if (ui->categoriesList->topLevelItem(i)->data(0, Qt::UserRole) == CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE) {
+ ui->categoriesList->setCurrentItem(ui->categoriesList->topLevelItem(i));
+ break;
+ }
+ }
}
void MainWindow::changeVersioningScheme() {
@@ -4399,7 +4413,7 @@ void MainWindow::initModListContextMenu(QMenu *menu)
menu->addAction(tr("Enable all visible"), this, SLOT(enableVisibleMods()));
menu->addAction(tr("Disable all visible"), this, SLOT(disableVisibleMods()));
- menu->addAction(tr("Check all for update"), this, SLOT(checkModsForUpdates()));
+ menu->addAction(tr("Force update check"), this, SLOT(checkModsForUpdates()));
menu->addAction(tr("Refresh"), &m_OrganizerCore, SLOT(profileRefresh()));
menu->addAction(tr("Export to csv..."), this, SLOT(exportModListCSV()));
}
@@ -5427,21 +5441,32 @@ void MainWindow::updateDownloadView()
void MainWindow::modDetailsUpdated(bool)
{
- if (--m_ModsToUpdate == 0) {
+ if (m_ModsToUpdate <= 0) {
statusBar()->hide();
- m_ModListSortProxy->setCategoryFilter(boost::assign::list_of(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE));
- for (int i = 0; i < ui->categoriesList->topLevelItemCount(); ++i) {
- if (ui->categoriesList->topLevelItem(i)->data(0, Qt::UserRole) == CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE) {
- ui->categoriesList->setCurrentItem(ui->categoriesList->topLevelItem(i));
- break;
- }
- }
m_RefreshProgress->setVisible(false);
} else {
m_RefreshProgress->setValue(m_RefreshProgress->maximum() - m_ModsToUpdate);
}
}
+void MainWindow::modUpdateCheck()
+{
+ if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->validated()) {
+ m_ModsToUpdate += ModInfo::autoUpdateCheck(&m_PluginContainer, this);
+ m_RefreshProgress->setRange(0, m_ModsToUpdate);
+ } else {
+ QString apiKey;
+ if (m_OrganizerCore.settings().getNexusApiKey(apiKey)) {
+ m_OrganizerCore.doAfterLogin([this]() { this->checkModsForUpdates(); });
+ NexusInterface::instance(&m_PluginContainer)->getAccessManager()->apiCheck(apiKey);
+ } else { // otherwise there will be no endorsement info
+ MessageDialog::showMessage(tr("Not logged in, endorsement information will be wrong"),
+ this, true);
+ m_ModsToUpdate += ModInfo::autoUpdateCheck(&m_PluginContainer, this);
+ }
+ }
+}
+
void MainWindow::nxmUpdatesAvailable(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID)
{
QVariantMap resultInfo = resultData.toMap();
@@ -5458,12 +5483,7 @@ void MainWindow::nxmUpdatesAvailable(QString gameName, int modID, QVariant userD
}
}
std::vector<ModInfo::Ptr> modsList = ModInfo::getByModID(gameNameReal, modID);
- // Not clear to me what this is accomplishing?
- //if (sameNexus) {
- // std::vector<ModInfo::Ptr> mainInfo = ModInfo::getByModID(m_OrganizerCore.managedGame()->gameShortName(), modID);
- // info.reserve(info.size() + mainInfo.size());
- // info.insert(info.end(), mainInfo.begin(), mainInfo.end());
- //}
+
for (auto mod : modsList) {
QString installedFile = mod->getInstallationFile();
for (auto update : fileUpdates) {
@@ -5511,6 +5531,7 @@ void MainWindow::nxmUpdatesAvailable(QString gameName, int modID, QVariant userD
if (foundUpdate) {
// Just get the standard data updates for endorsements and descriptions
+ mod->setLastNexusUpdate(QDateTime::currentDateTimeUtc());
mod->updateNXMInfo();
} else {
// Scrape mod data here so we can use the mod version if no file update was located
@@ -5518,29 +5539,9 @@ void MainWindow::nxmUpdatesAvailable(QString gameName, int modID, QVariant userD
}
}
- // Old endorsement and mod info updater
- //for
- // if (updateData["old_file_id"].toInt() == mod->readMeta())
- // (*iter)->setNewestVersion(result["version"].toString());
- //(*iter)->setNexusDescription(result["description"].toString());
- //if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->validated() &&
- // result.contains("voted_by_user") &&
- // Settings::instance().endorsementIntegration()) {
- // // don't use endorsement info if we're not logged in or if the response doesn't contain it
- // (*iter)->setIsEndorsed(result["voted_by_user"].toBool());
- //}
-
- if (m_ModsToUpdate <= 0) {
+ if (--m_ModsToUpdate <= 0) {
statusBar()->hide();
- m_ModListSortProxy->setCategoryFilter(boost::assign::list_of(CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE));
- for (int i = 0; i < ui->categoriesList->topLevelItemCount(); ++i) {
- if (ui->categoriesList->topLevelItem(i)->data(0, Qt::UserRole) == CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE) {
- ui->categoriesList->setCurrentItem(ui->categoriesList->topLevelItem(i));
- break;
- }
- }
- }
- else {
+ } else {
m_RefreshProgress->setValue(m_RefreshProgress->maximum() - m_ModsToUpdate);
}
}
@@ -5570,9 +5571,8 @@ void MainWindow::nxmDescriptionAvailable(QString gameName, int modID, QVariant u
else
mod->setIsEndorsed(false);
}
+ mod->saveMeta();
}
- disconnect(sender(), SIGNAL(nxmDescriptionAvailable(QString, int, QVariant, QVariant, int)),
- this, SLOT(nxmDescriptionAvailable(QString, int, QVariant, QVariant, int)));
}
void MainWindow::nxmEndorsementToggled(QString, int, QVariant, QVariant resultData, int)