| 196 | } |
| 197 | |
| 198 | void ModFolderPage::updateMods() |
| 199 | { |
| 200 | auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); |
| 201 | auto mods_list = m_model->selectedMods(selection); |
| 202 | |
| 203 | bool use_all = mods_list.empty(); |
| 204 | if (use_all) { |
| 205 | mods_list = m_model->allMods(); |
| 206 | } |
| 207 | |
| 208 | auto tempModList = mods_list; |
| 209 | for(auto mod : tempModList) { |
| 210 | if (mod->metadata() && mod->metadata()->hasDoUpdates() && mod->metadata()->do_updates == "false") { |
| 211 | mods_list.removeAll(mod); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | ModUpdateDialog update_dialog(this, m_instance, m_model, mods_list); |
| 216 | update_dialog.checkCandidates(); |
| 217 | |
| 218 | if (update_dialog.aborted()) { |
| 219 | CustomMessageBox::selectable(this, tr("Aborted"), tr("The mod updater was aborted!"), QMessageBox::Warning)->show(); |
| 220 | return; |
| 221 | } |
| 222 | if (update_dialog.noUpdates()) { |
| 223 | QString message{ tr("'%1' is up-to-date! :)").arg(mods_list.front()->name()) }; |
| 224 | if (mods_list.size() > 1) { |
| 225 | if (use_all) { |
| 226 | message = tr("All mods are up-to-date! :)"); |
| 227 | } else { |
| 228 | message = tr("All selected mods are up-to-date! :)"); |
| 229 | } |
| 230 | } |
| 231 | CustomMessageBox::selectable(this, tr("Update checker"), message) |
| 232 | ->exec(); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | if (update_dialog.exec()) { |
| 237 | ConcurrentTask* tasks = new ConcurrentTask(this); |
| 238 | connect(tasks, &Task::failed, [this, tasks](QString reason) { |
| 239 | CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); |
| 240 | tasks->deleteLater(); |
| 241 | }); |
| 242 | connect(tasks, &Task::aborted, [this, tasks]() { |
| 243 | CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show(); |
| 244 | tasks->deleteLater(); |
| 245 | }); |
| 246 | connect(tasks, &Task::succeeded, [this, tasks]() { |
| 247 | QStringList warnings = tasks->warnings(); |
| 248 | if (warnings.count()) { |
| 249 | CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show(); |
| 250 | } |
| 251 | tasks->deleteLater(); |
| 252 | }); |
| 253 | |
| 254 | for (auto task : update_dialog.getTasks()) { |
| 255 | tasks->addTask(task); |
nothing calls this directly
no test coverage detected