Commit 33d0fa4d authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Remove unneeded, redundant interface

parent bf9fe2ad
......@@ -39,7 +39,7 @@ public:
AbstractBackendUpdater* backendUpdater() const override;
AbstractReviewsBackend* reviewsBackend() const override;
ResultsStream* search(const AbstractResourcesBackend::Filters & search) override;
ResultsStream * findResourceByPackageName(const QUrl& search) override;
ResultsStream * findResourceByPackageName(const QUrl& search);
QHash<QString, DummyResource*> resources() const { return m_resources; }
bool isValid() const override { return true; } // No external file dependencies that could cause runtime errors
......
......@@ -187,7 +187,10 @@ void DummyTest::testSort()
void DummyTest::testInstallAddons()
{
const auto resources = fetchResources(m_appBackend->findResourceByPackageName(QUrl(QStringLiteral("dummy://Dummy.1"))));
AbstractResourcesBackend::Filters filter;
filter.resourceUrl = QUrl(QStringLiteral("dummy://Dummy.1"));
const auto resources = fetchResources(m_appBackend->search(filter));
QCOMPARE(resources.count(), 1);
AbstractResource* res = resources.first();
QVERIFY(res);
......@@ -224,7 +227,10 @@ void DummyTest::testInstallAddons()
void DummyTest::testReviewsModel()
{
const auto resources = fetchResources(m_appBackend->findResourceByPackageName(QUrl(QStringLiteral("dummy://Dummy.1"))));
AbstractResourcesBackend::Filters filter;
filter.resourceUrl = QUrl(QStringLiteral("dummy://Dummy.1"));
const auto resources = fetchResources(m_appBackend->search(filter));
QCOMPARE(resources.count(), 1);
AbstractResource* res = resources.first();
QVERIFY(res);
......@@ -242,7 +248,7 @@ void DummyTest::testReviewsModel()
m.markUseful(0, false);
QCOMPARE(ReviewsModel::UserChoice(m.data(m.index(0,0), ReviewsModel::UsefulChoice).toInt()), ReviewsModel::No);
const auto resources2 = fetchResources(m_appBackend->findResourceByPackageName(QUrl(QStringLiteral("dummy://Dummy.1"))));
const auto resources2 = fetchResources(m_appBackend->search(filter));
QCOMPARE(resources2.count(), 1);
res = resources2.first();
m.setResource(res);
......@@ -268,10 +274,13 @@ void DummyTest::testUpdateModel()
void DummyTest::testScreenshotsModel()
{
AbstractResourcesBackend::Filters filter;
filter.resourceUrl = QUrl(QStringLiteral("dummy://Dummy.1"));
ScreenshotsModel m;
new ModelTest(&m, &m);
const auto resources = fetchResources(m_appBackend->findResourceByPackageName(QUrl(QStringLiteral("dummy://Dummy.1"))));
const auto resources = fetchResources(m_appBackend->search(filter));
QCOMPARE(resources.count(), 1);
AbstractResource* res = resources.first();
QVERIFY(res);
......
......@@ -50,7 +50,7 @@ public:
AbstractBackendUpdater * backendUpdater() const override;
AbstractReviewsBackend * reviewsBackend() const override;
ResultsStream * search(const AbstractResourcesBackend::Filters & search) override;
ResultsStream * findResourceByPackageName(const QUrl &search) override;
ResultsStream * findResourceByPackageName(const QUrl &search);
QList<FlatpakResource*> resources() const { return m_resources.values(); }
bool isValid() const override;
......
......@@ -49,7 +49,7 @@ public:
AbstractBackendUpdater* backendUpdater() const override;
bool isFetching() const override;
ResultsStream* search(const AbstractResourcesBackend::Filters & filter) override;
ResultsStream* findResourceByPackageName(const QUrl & search) override;
ResultsStream* findResourceByPackageName(const QUrl & search);
QVector<Category*> category() const override { return m_rootCategories; }
......
......@@ -135,17 +135,12 @@ void KNSBackendTest::reviewsArrived(AbstractResource* r, const QVector<ReviewPtr
void KNSBackendTest::testResourceByUrl()
{
const QUrl url(QStringLiteral("kns://") + m_backend->name() + QStringLiteral("/api.kde-look.org/1136471"));
auto resources = getResources(m_backend->findResourceByPackageName(url));
AbstractResourcesBackend::Filters f;
f.resourceUrl = QUrl(QStringLiteral("kns://") + m_backend->name() + QStringLiteral("/api.kde-look.org/1136471"));
const QVector<AbstractResource*> resources = getResources(m_backend->search(f));
const QVector<QUrl> res = kTransform<QVector<QUrl>>(resources, [](AbstractResource* res){ return res->url(); });
QCOMPARE(res.count(), 1);
QCOMPARE(url, res.constFirst());
AbstractResourcesBackend::Filters f;
f.resourceUrl = url;
const QVector<QUrl> res2 = kTransform<QVector<QUrl>>(getResources(m_backend->search(f)), [](AbstractResource* res){ return res->url(); });
QCOMPARE(res, res2);
QCOMPARE(f.resourceUrl, res.constFirst());
auto resource = resources.constFirst();
QVERIFY(!resource->isInstalled()); //Make sure .qttest is clean before running the test
......@@ -162,9 +157,10 @@ void KNSBackendTest::testResourceByUrl()
void KNSBackendTest::testResourceByUrlResourcesModel()
{
const QUrl url(QStringLiteral("kns://plasmoids.knsrc/store.kde.org/1169537")); //Wrong domain
AbstractResourcesBackend::Filters filter;
filter.resourceUrl = QUrl(QStringLiteral("kns://plasmoids.knsrc/store.kde.org/1169537")); //Wrong domain
auto resources = getResources(ResourcesModel::global()->findResourceByPackageName(url), true);
auto resources = getResources(ResourcesModel::global()->search(filter), true);
const QVector<QUrl> res = kTransform<QVector<QUrl>>(resources, [](AbstractResource* res){ return res->url(); });
QCOMPARE(res.count(), 0);
}
......@@ -48,7 +48,7 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
QSet<AbstractResource*> resourcesByPackageName(const QString& name) const;
ResultsStream* search(const AbstractResourcesBackend::Filters & search) override;
ResultsStream* findResourceByPackageName(const QUrl& search) override;
ResultsStream* findResourceByPackageName(const QUrl& search);
int updatesCount() const override;
bool hasSecurityUpdates() const override;
......
......@@ -113,8 +113,6 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
virtual ResultsStream* search(const Filters &search) = 0;//FIXME: Probably provide a standard implementation?!
virtual ResultsStream* findResourceByPackageName(const QUrl &search) = 0;//FIXME: Probably provide a standard implementation?!
/**
* @returns the reviews backend of this AbstractResourcesBackend (which handles all ratings and reviews of resources)
*/
......
......@@ -310,12 +310,6 @@ void AggregatedResultsStream::clear()
}
}
AggregatedResultsStream * ResourcesModel::findResourceByPackageName(const QUrl& search)
{
auto streams = kTransform<QSet<ResultsStream*>>(m_backends, [search](AbstractResourcesBackend* backend){ return backend->findResourceByPackageName(search); });
return new AggregatedResultsStream(streams);
}
AggregatedResultsStream* ResourcesModel::search(const AbstractResourcesBackend::Filters& search)
{
if (search.isEmpty()) {
......
......@@ -76,7 +76,6 @@ class DISCOVERCOMMON_EXPORT ResourcesModel : public QObject
Q_SCRIPTABLE bool isExtended(const QString &id);
AggregatedResultsStream* findResourceByPackageName(const QUrl& search);
AggregatedResultsStream* search(const AbstractResourcesBackend::Filters &search);
AbstractResource* resourceForFile(const QUrl &/*url*/);
void checkForUpdates();
......
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