mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-03 11:27:33 -04:00
change to QSet to remove duplicates
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
7dd1690947
commit
15a5e99a8a
@ -303,24 +303,6 @@ void ModFolderModel::onParseFinished()
|
||||
}
|
||||
}
|
||||
}
|
||||
auto removeDuplicates = [](QList<Mod*>& list) {
|
||||
std::set<QString> seen;
|
||||
auto it = std::remove_if(list.begin(), list.end(), [&seen](Mod* m) {
|
||||
auto id = m->mod_id();
|
||||
if (seen.count(id) > 0) {
|
||||
return true;
|
||||
}
|
||||
seen.insert(id);
|
||||
return false;
|
||||
});
|
||||
list.erase(it, list.end());
|
||||
};
|
||||
for (auto key : m_requiredBy.keys()) {
|
||||
removeDuplicates(m_requiredBy[key]);
|
||||
}
|
||||
for (auto key : m_requires.keys()) {
|
||||
removeDuplicates(m_requires[key]);
|
||||
}
|
||||
for (auto mod : mods) {
|
||||
auto id = mod->mod_id();
|
||||
mod->setRequiredByCount(m_requiredBy[id].count());
|
||||
@ -348,7 +330,7 @@ QModelIndexList ModFolderModel::getAffectedMods(const QModelIndexList& indexes,
|
||||
bool shouldBeEnabled = action == EnableAction::ENABLE;
|
||||
for (auto mod : indexedMods) {
|
||||
auto id = mod->mod_id();
|
||||
QList<Mod*> mods;
|
||||
QSet<Mod*> mods;
|
||||
switch (action) {
|
||||
case EnableAction::DISABLE: {
|
||||
mods = m_requiredBy[id];
|
||||
@ -386,7 +368,7 @@ bool ModFolderModel::setResourceEnabled(const QModelIndexList& indexes, EnableAc
|
||||
return ResourceFolderModel::setResourceEnabled(indexes + affected, action);
|
||||
}
|
||||
|
||||
QStringList reqToList(QList<Mod*> l)
|
||||
QStringList reqToList(QSet<Mod*> l)
|
||||
{
|
||||
QStringList req;
|
||||
for (auto m : l) {
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QDir>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
@ -104,6 +103,6 @@ class ModFolderModel : public ResourceFolderModel {
|
||||
void onParseFinished();
|
||||
|
||||
private:
|
||||
QHash<QString, QList<Mod*>> m_requiredBy;
|
||||
QHash<QString, QList<Mod*>> m_requires;
|
||||
QHash<QString, QSet<Mod*>> m_requiredBy;
|
||||
QHash<QString, QSet<Mod*>> m_requires;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user