Fixed code qulity

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-04-22 22:27:33 +03:00
parent 460e83207f
commit f738d7566e
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318

View File

@ -337,9 +337,9 @@ void ResourceModel::searchRequestSucceeded(QJsonDocument& doc)
ModPlatform::IndexedPack pack; ModPlatform::IndexedPack pack;
try { try {
loadIndexedPack(pack, packObj); loadIndexedPack(pack, packObj);
if (auto sel = if (auto sel = std::find_if(
std::find_if(m_selected.begin(), m_selected.end(), m_selected.begin(), m_selected.end(),
[&pack](ModPlatform::IndexedPack& i) { return i.provider == pack.provider && i.addonId == pack.addonId; }); [&pack](const ModPlatform::IndexedPack& i) { return i.provider == pack.provider && i.addonId == pack.addonId; });
sel != m_selected.end()) { sel != m_selected.end()) {
pack.versionsLoaded = sel->versionsLoaded; pack.versionsLoaded = sel->versionsLoaded;
pack.versions = sel->versions; pack.versions = sel->versions;
@ -409,8 +409,9 @@ void ResourceModel::versionRequestSucceeded(QJsonDocument& doc, ModPlatform::Ind
auto arr = doc.isObject() ? Json::ensureArray(doc.object(), "data") : doc.array(); auto arr = doc.isObject() ? Json::ensureArray(doc.object(), "data") : doc.array();
loadIndexedPackVersions(current_pack, arr); loadIndexedPackVersions(current_pack, arr);
if (current_pack.loadedFileId.isValid()) if (current_pack.loadedFileId.isValid())
if (auto ver = std::find_if(current_pack.versions.begin(), current_pack.versions.end(), if (auto ver =
[&current_pack](ModPlatform::IndexedVersion v) { return v.fileId == current_pack.loadedFileId; }); std::find_if(current_pack.versions.begin(), current_pack.versions.end(),
[&current_pack](const ModPlatform::IndexedVersion& v) { return v.fileId == current_pack.loadedFileId; });
ver != current_pack.versions.end()) ver != current_pack.versions.end())
ver->is_currently_selected = true; ver->is_currently_selected = true;
} catch (const JSONValidationError& e) { } catch (const JSONValidationError& e) {
@ -458,7 +459,7 @@ void ResourceModel::infoRequestSucceeded(QJsonDocument& doc, ModPlatform::Indexe
void ResourceModel::removePack(QString& rem) void ResourceModel::removePack(QString& rem)
{ {
auto pred = [&rem](ModPlatform::IndexedPack i) { return rem == i.name; }; auto pred = [&rem](const ModPlatform::IndexedPack& i) { return rem == i.name; };
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
m_selected.removeIf(pred); m_selected.removeIf(pred);
#else #else
@ -491,7 +492,7 @@ void ResourceModel::removePack(QString& rem)
} }
#endif #endif
// m_selected.removeAt(qsizetype i) // m_selected.removeAt(qsizetype i)
auto pack = std::find_if(m_packs.begin(), m_packs.end(), [&rem](ModPlatform::IndexedPack i) { return rem == i.name; }); auto pack = std::find_if(m_packs.begin(), m_packs.end(), [&rem](const ModPlatform::IndexedPack& i) { return rem == i.name; });
if (pack == m_packs.end()) { // ignore it if is not in the current search if (pack == m_packs.end()) { // ignore it if is not in the current search
return; return;
} }