mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
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.
This commit is contained in:
parent
7268d7b15a
commit
f053ded6f8
@ -392,30 +392,30 @@ void ContentManager::setSearch(const QString &search)
|
|||||||
QStringList ContentManager::getBookIds()
|
QStringList ContentManager::getBookIds()
|
||||||
{
|
{
|
||||||
kiwix::Filter filter;
|
kiwix::Filter filter;
|
||||||
std::vector<std::string> tags;
|
std::vector<std::string> acceptTags, rejectTags;
|
||||||
if (m_categoryFilter != "all" && m_categoryFilter != "other") {
|
if (m_categoryFilter != "all" && m_categoryFilter != "other") {
|
||||||
tags.push_back("_category:"+m_categoryFilter.toStdString());
|
acceptTags.push_back("_category:"+m_categoryFilter.toStdString());
|
||||||
filter.acceptTags(tags);
|
|
||||||
}
|
}
|
||||||
if (m_categoryFilter == "other") {
|
if (m_categoryFilter == "other") {
|
||||||
for (auto& category: S_CATEGORIES) {
|
for (auto& category: S_CATEGORIES) {
|
||||||
if (category.first != "other" && category.first != "all") {
|
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) {
|
for (auto &contentTypeFilter : m_contentTypeFilters) {
|
||||||
auto state = contentTypeFilter->checkState();
|
auto state = contentTypeFilter->checkState();
|
||||||
auto filter = contentTypeFilter->getName();
|
auto filter = contentTypeFilter->getName();
|
||||||
if (state == Qt::PartiallyChecked) {
|
if (state == Qt::PartiallyChecked) {
|
||||||
tags.push_back("_" + filter.toStdString() +":yes");
|
acceptTags.push_back("_" + filter.toStdString() +":yes");
|
||||||
} else if (state == Qt::Checked) {
|
} 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());
|
filter.query(m_searchQuery.toStdString());
|
||||||
if (m_currentLanguage != "*")
|
if (m_currentLanguage != "*")
|
||||||
filter.lang(m_currentLanguage.toStdString());
|
filter.lang(m_currentLanguage.toStdString());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user