Commit 7e431a22 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make it possible to specify in the query if all backends will be queried

parent c796ffb2
......@@ -160,6 +160,7 @@ DiscoverPage {
ComboBox {
id: sourcesCombo
model: ResourcesProxyModel {
allBackends: true
onIsBusyChanged: if (!isBusy) {
sourcesCombo.currentIndex = indexOf(appInfo.application)
}
......
......@@ -39,6 +39,7 @@ DiscoverPage {
property alias search: appsModel.search
property alias resourcesUrl: appsModel.resourcesUrl
property alias isBusy: appsModel.isBusy
property alias allBackends: appsModel.allBackends
property alias count: apps.count
property alias listHeader: apps.header
property bool compact: page.width < 500 || Helpers.isCompact
......
......@@ -24,12 +24,12 @@ function clearStack()
}
function openApplicationListSource(origin) {
openApplicationList({ originFilter: origin, title: origin })
openApplicationList({ originFilter: origin, title: origin, allBackends: true })
}
function openUrlResources(uri) {
clearStack()
openApplicationList({ resourcesUrl: uri, title: uri })
openApplicationList({ resourcesUrl: uri, title: uri, allBackends: true })
}
function openApplicationMime(mime) {
......
......@@ -99,6 +99,7 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
QString extends;
QUrl resourceUrl;
QHash<QByteArray, QVariant> roles;
bool allBackends = false;
bool shouldFilter(AbstractResource* res) const;
void filterJustInCase(QVector<AbstractResource*>& input) const;
......
......@@ -329,10 +329,11 @@ AggregatedResultsStream* ResourcesModel::search(const AbstractResourcesBackend::
{
QSet<ResultsStream*> streams;
const bool allBackends = search.roles.contains("origin") || !search.resourceUrl.isEmpty();
const bool allBackends = search.allBackends;
foreach(auto backend, m_backends) {
if (!backend->hasApplications() || ResourcesModel::global()->currentApplicationBackend() == backend || allBackends)
if (!backend->hasApplications() || ResourcesModel::global()->currentApplicationBackend() == backend || allBackends) {
streams << backend->search(search);
}
}
return new AggregatedResultsStream(streams);
}
......
......@@ -316,6 +316,16 @@ void ResourcesProxyModel::setResourcesUrl(const QUrl& resourcesUrl)
}
}
bool ResourcesProxyModel::allBackends() const
{
return m_filters.allBackends;
}
void ResourcesProxyModel::setAllBackends(bool allBackends)
{
m_filters.allBackends = allBackends;
}
QVariant ResourcesProxyModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()) {
......
......@@ -49,6 +49,7 @@ class DISCOVERCOMMON_EXPORT ResourcesProxyModel : public QAbstractListModel, pub
Q_PROPERTY(QString search READ lastSearch WRITE setSearch NOTIFY searchChanged)
Q_PROPERTY(QUrl resourcesUrl READ resourcesUrl WRITE setResourcesUrl NOTIFY resourcesUrlChanged)
Q_PROPERTY(QString extends READ extends WRITE setExtends)
Q_PROPERTY(bool allBackends READ allBackends WRITE setAllBackends)
Q_PROPERTY(QVariantList subcategories READ subcategories NOTIFY subcategoriesChanged)
Q_PROPERTY(bool isBusy READ isBusy NOTIFY busyChanged)
public:
......@@ -103,6 +104,9 @@ public:
QUrl resourcesUrl() const;
void setResourcesUrl(const QUrl& resourcesUrl);
bool allBackends() const;
void setAllBackends(bool allBackends);
QVariantList subcategories() const;
QVariant data(const QModelIndex & index, int role) const override;
......
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