Commit cf4a2158 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

FeaturedModel: simplify logic for duplicates

All resources will be coming from the same backend, we will always
prefer the first.
parent 092899c9
......@@ -129,16 +129,13 @@ void FeaturedModel::setUris(const QVector<QUrl>& uris)
static void filterDupes(QVector<AbstractResource *> &resources)
{
const auto m_appsBackend = ResourcesModel::global()->currentApplicationBackend();
QHash<QString, AbstractResource*> resById;
QSet<QString> found;
for(auto it = resources.begin(); it!=resources.end(); ) {
auto id = (*it)->appstreamId();
auto curr = resById.value(id);
if (curr && curr->backend() == m_appsBackend) {
if (found.contains(id)) {
it = resources.erase(it);
} else {
resources.removeAll(curr);
resById[id] = *it;
found.insert(id);
++it;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment