From 8a37a83e8f5df68d8ff955785a2c660f1d156167 Mon Sep 17 00:00:00 2001 From: luddens Date: Fri, 28 Jun 2019 12:11:25 +0200 Subject: [PATCH] add "notag" parameter to the search api The notag parameter is filled with all categories from the category list separated by a ";" --- src/opdsrequestmanager.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/opdsrequestmanager.cpp b/src/opdsrequestmanager.cpp index bf334f0..08e6971 100644 --- a/src/opdsrequestmanager.cpp +++ b/src/opdsrequestmanager.cpp @@ -1,4 +1,5 @@ #include "opdsrequestmanager.h" +#include "kiwixapp.h" OpdsRequestManager::OpdsRequestManager() : mp_reply(nullptr) @@ -14,16 +15,29 @@ void OpdsRequestManager::doUpdate(const QString& currentLanguage, const QString& query.addQueryItem("lang", currentLanguage); } query.addQueryItem("count", QString::number(0)); - if (categoryFilter != "all") { + if (categoryFilter != "all" && categoryFilter != "other") { query.addQueryItem("tag", categoryFilter); } + + if (categoryFilter == "other") { + auto allCategories = KiwixApp::instance()->getMainWindow()->getSideContentManager()->getCategoryList(); + QStringList excludeTags; + for (auto& category:allCategories) { + if (category != "Other") { + excludeTags += category.toLower(); + } + } + query.addQueryItem("notag", excludeTags.join(";")); + } + + QUrl url; url.setScheme("http"); url.setHost(CATALOG_HOST); url.setPort(CATALOG_PORT); url.setPath("/catalog/search"); url.setQuery(query); - + qInfo() << "Downloading" << url.toString(QUrl::FullyEncoded); QNetworkRequest request(url); @@ -42,4 +56,4 @@ void OpdsRequestManager::receiveContent() } mp_reply->deleteLater(); mp_reply = nullptr; -} \ No newline at end of file +}