Commit 43076fa2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Role filters abstraction was only used for origin, simplify

parent 4efed776
......@@ -36,7 +36,7 @@ QDebug operator<<(QDebug debug, const AbstractResourcesBackend::Filters& filters
if (!filters.mimetype.isEmpty()) debug.nospace() << "mimetype: " << filters.mimetype << ',';
if (!filters.search.isEmpty()) debug.nospace() << "search: " << filters.search << ',';
if (!filters.extends.isEmpty()) debug.nospace() << "extends:" << filters.extends << ',';
if (!filters.roles.isEmpty()) debug.nospace() << "roles:" << filters.roles << ',';
if (!filters.origin.isEmpty()) debug.nospace() << "origin:" << filters.origin << ',';
debug.nospace() << ')';
return debug;
......@@ -104,11 +104,8 @@ bool AbstractResourcesBackend::Filters::shouldFilter(AbstractResource* res) cons
return false;
}
for(QHash<QByteArray, QVariant>::const_iterator it=roles.constBegin(), itEnd=roles.constEnd(); it!=itEnd; ++it) {
Q_ASSERT(AbstractResource::staticMetaObject.indexOfProperty(it.key().constData())>=0);
if(res->property(it.key().constData()) != it.value()) {
return false;
}
if(!origin.isEmpty() && res->origin() != origin) {
return false;
}
if(res->state() < state)
......
......@@ -98,7 +98,7 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
QString search;
QString extends;
QUrl resourceUrl;
QHash<QByteArray, QVariant> roles;
QString origin;
bool allBackends = false;
bool shouldFilter(AbstractResource* res) const;
......
......@@ -203,20 +203,17 @@ QString ResourcesProxyModel::lastSearch() const
void ResourcesProxyModel::setOriginFilter(const QString &origin)
{
if (origin == originFilter())
if (origin == m_filters.origin)
return;
if(origin.isEmpty())
m_filters.roles.remove("origin");
else
m_filters.roles.insert("origin", origin);
m_filters.origin = origin;
invalidateFilter();
}
QString ResourcesProxyModel::originFilter() const
{
return m_filters.roles.value("origin").toString();
return m_filters.origin;
}
void ResourcesProxyModel::setFiltersFromCategory(Category *category)
......
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