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

Make sure we filter properly the missing backends

Do it from the model rather than the delegate
parent 2bbd9efd
......@@ -242,6 +242,7 @@ DiscoverPage {
id: back
model: ResourcesProxyModel {
extending: "org.kde.discover.desktop"
filterMinimumState: false
}
delegate: Kirigami.BasicListItem {
supportsMouseEvents: false
......
......@@ -109,7 +109,7 @@ bool AbstractResourcesBackend::Filters::shouldFilter(AbstractResource* res) cons
return false;
}
if(res->state() < state)
if(filterMinimumState ? res->state() < state : res->state() == state)
return false;
if(!mimetype.isEmpty() && !res->mimetypes().contains(mimetype)) {
......
......@@ -100,6 +100,7 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
QUrl resourceUrl;
QString origin;
bool allBackends = false;
bool filterMinimumState = true;
bool isEmpty() const { return !category && state == AbstractResource::Broken && mimetype.isEmpty() && search.isEmpty() && extends.isEmpty() && resourceUrl.isEmpty() && origin.isEmpty(); }
......
......@@ -359,6 +359,20 @@ void ResourcesProxyModel::setExtends(const QString& extends)
}
}
void ResourcesProxyModel::setFilterMinimumState(bool filterMinimumState)
{
if (filterMinimumState != m_filters.filterMinimumState) {
m_filters.filterMinimumState = filterMinimumState;
invalidateFilter();
Q_EMIT filterMinimumStateChanged(m_filters.filterMinimumState);
}
}
bool ResourcesProxyModel::filterMinimumState() const
{
return m_filters.filterMinimumState;
}
QUrl ResourcesProxyModel::resourcesUrl() const
{
return m_filters.resourceUrl;
......
......@@ -45,6 +45,7 @@ class DISCOVERCOMMON_EXPORT ResourcesProxyModel : public QAbstractListModel, pub
Q_PROPERTY(Category* filteredCategory READ filteredCategory WRITE setFiltersFromCategory NOTIFY categoryChanged)
Q_PROPERTY(QString originFilter READ originFilter WRITE setOriginFilter)
Q_PROPERTY(AbstractResource::State stateFilter READ stateFilter WRITE setStateFilter NOTIFY stateFilterChanged)
Q_PROPERTY(bool filterMinimumState READ filterMinimumState WRITE setFilterMinimumState NOTIFY filterMinimumStateChanged)
Q_PROPERTY(QString mimeTypeFilter READ mimeTypeFilter WRITE setMimeTypeFilter)
Q_PROPERTY(QString search READ lastSearch WRITE setSearch NOTIFY searchChanged)
Q_PROPERTY(QUrl resourcesUrl READ resourcesUrl WRITE setResourcesUrl NOTIFY resourcesUrlChanged)
......@@ -95,6 +96,8 @@ public:
Roles sortRole() const { return m_sortRole; }
void setSortOrder(Qt::SortOrder sortOrder);
Qt::SortOrder sortOrder() const { return m_sortOrder; }
void setFilterMinimumState(bool filterMinimumState);
bool filterMinimumState() const;
Category* filteredCategory() const;
......@@ -164,6 +167,7 @@ Q_SIGNALS:
void subcategoriesChanged(const QVariantList &subcategories);
void resourcesUrlChanged(const QUrl &url);
void countChanged();
void filterMinimumStateChanged(bool filterMinimumState);
};
#endif
Supports Markdown
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