Part 1: Ensure we have a valid metadata
| 201 | |
| 202 | // Part 1: Ensure we have a valid metadata |
| 203 | auto ModUpdateDialog::ensureMetadata() -> bool |
| 204 | { |
| 205 | auto index_dir = indexDir(); |
| 206 | |
| 207 | SequentialTask seq(m_parent, tr("Looking for metadata")); |
| 208 | |
| 209 | // A better use of data structures here could remove the need for this QHash |
| 210 | QHash<QString, bool> should_try_others; |
| 211 | QList<Mod*> modrinth_tmp; |
| 212 | QList<Mod*> flame_tmp; |
| 213 | |
| 214 | bool confirm_rest = false; |
| 215 | bool try_others_rest = false; |
| 216 | bool skip_rest = false; |
| 217 | ModPlatform::Provider provider_rest = ModPlatform::Provider::MODRINTH; |
| 218 | |
| 219 | auto addToTmp = [&](Mod* m, ModPlatform::Provider p) { |
| 220 | switch (p) { |
| 221 | case ModPlatform::Provider::MODRINTH: |
| 222 | modrinth_tmp.push_back(m); |
| 223 | break; |
| 224 | case ModPlatform::Provider::FLAME: |
| 225 | flame_tmp.push_back(m); |
| 226 | break; |
| 227 | } |
| 228 | }; |
| 229 | |
| 230 | for (auto candidate : m_candidates) { |
| 231 | if (candidate->status() != ModStatus::NoMetadata) { |
| 232 | onMetadataEnsured(candidate); |
| 233 | continue; |
| 234 | } |
| 235 | |
| 236 | if (skip_rest) |
| 237 | continue; |
| 238 | |
| 239 | if (confirm_rest) { |
| 240 | addToTmp(candidate, provider_rest); |
| 241 | should_try_others.insert(candidate->internal_id(), try_others_rest); |
| 242 | continue; |
| 243 | } |
| 244 | |
| 245 | ChooseProviderDialog chooser(this); |
| 246 | chooser.setDescription(tr("The mod '%1' does not have a metadata yet. We need to generate it in order to track relevant " |
| 247 | "information on how to update this mod. " |
| 248 | "To do this, please select a mod provider which we can use to check for updates for this mod.") |
| 249 | .arg(candidate->name())); |
| 250 | auto confirmed = chooser.exec() == QDialog::DialogCode::Accepted; |
| 251 | |
| 252 | auto response = chooser.getResponse(); |
| 253 | |
| 254 | if (response.skip_all) |
| 255 | skip_rest = true; |
| 256 | if (response.confirm_all) { |
| 257 | confirm_rest = true; |
| 258 | provider_rest = response.chosen; |
| 259 | try_others_rest = response.try_others; |
| 260 | } |
no test coverage detected