From f053ded6f8f8638a0b3d44fd1d24cd45f5e780f4 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 23 Feb 2022 17:28:44 +0100 Subject: [PATCH] Fix content-type filtering The commit cb63bb2 was buggy and deactivate filtering by contentType. We now handle two different lists to store tags we want and tags we don't. --- src/contentmanager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 07042a3..0071fda 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -392,30 +392,30 @@ void ContentManager::setSearch(const QString &search) QStringList ContentManager::getBookIds() { kiwix::Filter filter; - std::vector tags; + std::vector acceptTags, rejectTags; if (m_categoryFilter != "all" && m_categoryFilter != "other") { - tags.push_back("_category:"+m_categoryFilter.toStdString()); - filter.acceptTags(tags); + acceptTags.push_back("_category:"+m_categoryFilter.toStdString()); } if (m_categoryFilter == "other") { for (auto& category: S_CATEGORIES) { if (category.first != "other" && category.first != "all") { - tags.push_back("_category:"+category.first.toStdString()); + rejectTags.push_back("_category:"+category.first.toStdString()); } } - filter.rejectTags(tags); } for (auto &contentTypeFilter : m_contentTypeFilters) { auto state = contentTypeFilter->checkState(); auto filter = contentTypeFilter->getName(); if (state == Qt::PartiallyChecked) { - tags.push_back("_" + filter.toStdString() +":yes"); + acceptTags.push_back("_" + filter.toStdString() +":yes"); } else if (state == Qt::Checked) { - tags.push_back("_" + filter.toStdString() +":no"); + acceptTags.push_back("_" + filter.toStdString() +":no"); } } + filter.acceptTags(acceptTags); + filter.rejectTags(rejectTags); filter.query(m_searchQuery.toStdString()); if (m_currentLanguage != "*") filter.lang(m_currentLanguage.toStdString());