mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-10-03 03:03:15 -04:00
chore(clang-tidy): modernize the code
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
32 files changed
+598
-527
No files matched your search
@@ -69,12 +69,12 @@ ModFolderModel::ModFolderModel(const QDir& dir, MinecraftInstance* instance, boo
|
||||
tr("Requires"), tr("Required By"), tr("File Name"), tr("Update") });
|
||||
m_columnSortKeys = { SortType::Enabled, SortType::Name, SortType::Name, SortType::Version, SortType::Date,
|
||||
SortType::Provider, SortType::Size, SortType::Side, SortType::Loaders, SortType::McVersions,
|
||||
SortType::ReleaseType, SortType::Requires, SortType::RequiredBy, SortType::Filename, SortType::LOCK_UPDATE };
|
||||
SortType::ReleaseType, SortType::Requires, SortType::RequiredBy, SortType::Filename, SortType::LockUpdate };
|
||||
m_columnResizeModes = { QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::Interactive,
|
||||
QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Interactive,
|
||||
QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Interactive,
|
||||
QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Interactive };
|
||||
m_columnsHideable = { false, true, false, true, true, true, true, true, true, true, true, true, true, true };
|
||||
m_columnsHideable = { false, true, false, true, true, true, true, true, true, true, true, true, true, true, true };
|
||||
|
||||
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files);
|
||||
|
||||
@@ -139,14 +139,14 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
case Qt::ToolTipRole:
|
||||
switch (column) {
|
||||
case RequiredByColumn: {
|
||||
const auto list = requiredByList(at(row).mod_id());
|
||||
const auto list = requiredByList(at(row).modId());
|
||||
if (!list.isEmpty()) {
|
||||
return list.join(QLatin1Char('\n'));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RequiresColumn: {
|
||||
const auto list = requiresList(at(row).mod_id());
|
||||
const auto list = requiresList(at(row).modId());
|
||||
if (!list.isEmpty()) {
|
||||
return list.join(QLatin1Char('\n'));
|
||||
}
|
||||
@@ -160,12 +160,12 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
if (column == ActiveColumn) {
|
||||
return at(row).enabled() ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
return QVariant();
|
||||
return {};
|
||||
case Qt::UserRole:
|
||||
if (column == LockUpdateColumn) {
|
||||
return at(row).lockUpdate();
|
||||
}
|
||||
return QVariant();
|
||||
return {};
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -307,7 +307,7 @@ void ModFolderModel::onParseSucceeded(int ticket, const QString& resourceId)
|
||||
namespace {
|
||||
Mod* findById(QSet<Mod*> mods, const QString& resourceId)
|
||||
{
|
||||
auto found = std::ranges::find_if(mods, [resourceId](Mod* m) { return m->mod_id() == resourceId; });
|
||||
auto found = std::ranges::find_if(mods, [resourceId](Mod* m) { return m->modId() == resourceId; });
|
||||
return found != mods.end() ? *found : nullptr;
|
||||
}
|
||||
} // namespace
|
||||
@@ -325,17 +325,17 @@ void ModFolderModel::onParseFinished()
|
||||
|
||||
auto findByProjectID = [mods](const QVariant& modId, ModPlatform::ResourceProvider provider) -> Mod* {
|
||||
auto found = std::ranges::find_if(mods, [modId, provider](Mod* m) {
|
||||
return m->metadata() && m->metadata()->provider == provider && m->metadata()->project_id == modId;
|
||||
return m->metadata() && m->metadata()->provider == provider && m->metadata()->projectId == modId;
|
||||
});
|
||||
return found != mods.end() ? *found : nullptr;
|
||||
};
|
||||
for (auto* mod : mods) {
|
||||
auto id = mod->mod_id();
|
||||
auto id = mod->modId();
|
||||
for (const auto& dep : mod->dependencies()) {
|
||||
auto* d = findById(mods, dep);
|
||||
if (d) {
|
||||
m_requires[id] << d;
|
||||
m_requiredBy[d->mod_id()] << mod;
|
||||
m_requiredBy[d->modId()] << mod;
|
||||
}
|
||||
}
|
||||
if (mod->metadata()) {
|
||||
@@ -344,17 +344,17 @@ void ModFolderModel::onParseFinished()
|
||||
auto* d = findByProjectID(dep.addonId, mod->metadata()->provider);
|
||||
if (d) {
|
||||
m_requires[id] << d;
|
||||
m_requiredBy[d->mod_id()] << mod;
|
||||
m_requiredBy[d->modId()] << mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto* mod : mods) {
|
||||
auto id = mod->mod_id();
|
||||
auto id = mod->modId();
|
||||
if (mod->requiredByCount() != m_requiredBy[id].count() || mod->requiresCount() != m_requires[id].count()) {
|
||||
mod->setRequiredByCount(m_requiredBy[id].count());
|
||||
mod->setRequiresCount(m_requires[id].count());
|
||||
mod->setRequiredByCount(static_cast<int>(m_requiredBy[id].count()));
|
||||
mod->setRequiresCount(static_cast<int>(m_requires[id].count()));
|
||||
int row = m_resourcesIndex[mod->internalId()];
|
||||
emit dataChanged(index(row), index(row, columnCount(QModelIndex()) - 1));
|
||||
}
|
||||
@@ -368,11 +368,11 @@ QSet<Mod*> collectMods(const QSet<Mod*>& mods, QHash<QString, QSet<Mod*>> relati
|
||||
QSet<Mod*> affectedList = {};
|
||||
QSet<Mod*> needToCheck = {};
|
||||
for (auto* mod : mods) {
|
||||
auto id = mod->mod_id();
|
||||
auto id = mod->modId();
|
||||
if (!seen.contains(id)) {
|
||||
seen.insert(id);
|
||||
for (auto* affected : relation[id]) {
|
||||
auto affectedId = affected->mod_id();
|
||||
auto affectedId = affected->modId();
|
||||
|
||||
if (findById(mods, affectedId) == nullptr && !seen.contains(affectedId)) {
|
||||
if (shouldBeEnabled != affected->enabled()) {
|
||||
@@ -416,7 +416,7 @@ QModelIndexList ModFolderModel::getAffectedMods(const QModelIndexList& indexes,
|
||||
}
|
||||
}
|
||||
for (auto* affected : affectedMods) {
|
||||
auto affectedId = affected->mod_id();
|
||||
auto affectedId = affected->modId();
|
||||
auto row = m_resourcesIndex[affected->internalId()];
|
||||
affectedList << index(row, 0);
|
||||
}
|
||||
@@ -554,12 +554,12 @@ bool ModFolderModel::deleteResources(const QModelIndexList& indexes)
|
||||
};
|
||||
auto res = ResourceFolderModel::deleteResources(indexes);
|
||||
for (auto* mod : allMods()) {
|
||||
auto id = mod->mod_id();
|
||||
auto id = mod->modId();
|
||||
deleteInvalid(m_requiredBy[id]);
|
||||
deleteInvalid(m_requires[id]);
|
||||
if (mod->requiredByCount() != m_requiredBy[id].count() || mod->requiresCount() != m_requires[id].count()) {
|
||||
mod->setRequiredByCount(m_requiredBy[id].count());
|
||||
mod->setRequiresCount(m_requires[id].count());
|
||||
mod->setRequiredByCount(static_cast<int>(m_requiredBy[id].count()));
|
||||
mod->setRequiresCount(static_cast<int>(m_requires[id].count()));
|
||||
int row = m_resourcesIndex[mod->internalId()];
|
||||
emit dataChanged(index(row, RequiresColumn), index(row, RequiredByColumn));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user