MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / nxmUpdatesAvailable

Method nxmUpdatesAvailable

src/mainwindow.cpp:3160–3302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3158}
3159
3160void MainWindow::nxmUpdatesAvailable(QString gameName, int modID, QVariant userData,
3161 QVariant resultData, int requestID)
3162{
3163 QVariantMap resultInfo = resultData.toMap();
3164 QList files = resultInfo["files"].toList();
3165 QList fileUpdates = resultInfo["file_updates"].toList();
3166 QString gameNameReal;
3167
3168 for (IPluginGame* game : m_PluginContainer.plugins<IPluginGame>()) {
3169 if (game->gameNexusName() == gameName) {
3170 gameNameReal = game->gameShortName();
3171 break;
3172 }
3173 }
3174
3175 std::vector<ModInfo::Ptr> modsList = ModInfo::getByModID(gameNameReal, modID);
3176
3177 bool requiresInfo = false;
3178
3179 for (auto mod : modsList) {
3180 QString validNewVersion;
3181 int newModStatus = -1;
3182 QString installedFile = QFileInfo(mod->installationFile()).fileName();
3183
3184 if (!installedFile.isEmpty()) {
3185 QVariantMap foundFileData;
3186
3187 // update the file status
3188 for (auto& file : files) {
3189 QVariantMap fileData = file.toMap();
3190
3191 if (fileData["file_name"].toString().compare(installedFile,
3192 Qt::CaseInsensitive) == 0) {
3193 foundFileData = fileData;
3194 newModStatus = foundFileData["category_id"].toInt();
3195
3196 if (newModStatus != NexusInterface::FileStatus::OLD_VERSION &&
3197 newModStatus != NexusInterface::FileStatus::REMOVED &&
3198 newModStatus != NexusInterface::FileStatus::ARCHIVED) {
3199
3200 // since the file is still active if there are no updates for it, use this
3201 // as current version
3202 validNewVersion = foundFileData["version"].toString();
3203 }
3204 break;
3205 }
3206 }
3207
3208 if (foundFileData.isEmpty()) {
3209 // The file was not listed, the file is likely archived and archived files are
3210 // being hidden on the mod
3211 newModStatus = NexusInterface::FileStatus::ARCHIVED_HIDDEN;
3212 }
3213
3214 // look for updates of the file
3215 int currentUpdateId = -1;
3216
3217 // find installed file ID from the updates list since old filenames are not

Callers

nothing calls this directly

Calls 10

QStringClass · 0.85
compareMethod · 0.80
invalidateFilterMethod · 0.80
installationFileMethod · 0.45
isEmptyMethod · 0.45
toStringMethod · 0.45
setNexusFileStatusMethod · 0.45
setNewestVersionMethod · 0.45
setLastNexusUpdateMethod · 0.45
requestModInfoMethod · 0.45

Tested by

no test coverage detected