mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 19:46:12 -04:00
Merge pull request #175 from kiwix/filter-category-other
fix local category other
This commit is contained in:
commit
86f92569f5
@ -313,12 +313,32 @@ void ContentManager::setSearch(const QString &search)
|
||||
emit(booksChanged());
|
||||
}
|
||||
|
||||
QStringList ContentManager::getBookIds() {
|
||||
QStringList ContentManager::getBookIds()
|
||||
{
|
||||
kiwix::Filter filter;
|
||||
std::vector<std::string> tags;
|
||||
if (m_categoryFilter != "all" && m_categoryFilter != "other") {
|
||||
tags.push_back(m_categoryFilter.toStdString());
|
||||
filter.acceptTags(tags);
|
||||
}
|
||||
if (m_categoryFilter == "other") {
|
||||
auto categoryList = KiwixApp::instance()->getMainWindow()->getSideContentManager()->getCategoryList();
|
||||
for (auto& category: categoryList) {
|
||||
if (category != "Other") {
|
||||
tags.push_back(category.toLower().toStdString());
|
||||
}
|
||||
}
|
||||
filter.rejectTags(tags);
|
||||
}
|
||||
filter.query(m_searchQuery.toStdString());
|
||||
|
||||
if (m_local) {
|
||||
return mp_library->listBookIds(m_searchQuery, m_categoryFilter);
|
||||
filter.local(true);
|
||||
filter.valid(true);
|
||||
return mp_library->listBookIds(filter);
|
||||
} else {
|
||||
auto bookIds = m_remoteLibrary.listBooksIds(kiwix::REMOTE, kiwix::UNSORTED,
|
||||
m_searchQuery.toStdString());
|
||||
filter.remote(true);
|
||||
auto bookIds = m_remoteLibrary.filter(filter);
|
||||
QStringList list;
|
||||
for(auto& bookId:bookIds) {
|
||||
list.append(QString::fromStdString(bookId));
|
||||
|
@ -224,6 +224,7 @@ ContentManagerSide::ContentManagerSide(QWidget *parent) :
|
||||
})
|
||||
{
|
||||
auto c = QString(category);
|
||||
m_categoryList.append(c);
|
||||
auto item = new KListWidgetItem(c);
|
||||
mp_categorySelector->addItem(item);
|
||||
if (c == "All")
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
~ContentManagerSide();
|
||||
|
||||
void setContentManager(ContentManager* contentManager);
|
||||
QStringList getCategoryList() { return m_categoryList;};
|
||||
|
||||
private:
|
||||
Ui::contentmanagerside *mp_ui;
|
||||
@ -27,6 +28,7 @@ private:
|
||||
QListWidget* mp_languageSelector;
|
||||
QCheckBox* mp_categoryButton;
|
||||
QListWidget* mp_categorySelector;
|
||||
QStringList m_categoryList;
|
||||
};
|
||||
|
||||
#endif // CONTENTMANAGERSIDE_H
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "kiwixapp.h"
|
||||
|
||||
#include <kiwix/manager.h>
|
||||
#include "kiwixapp.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
@ -90,20 +91,11 @@ QStringList Library::getBookIds()
|
||||
return list;
|
||||
}
|
||||
|
||||
QStringList Library::listBookIds(const QString &query, const QString &categoryFilter)
|
||||
QStringList Library::listBookIds(const kiwix::Filter& filter)
|
||||
{
|
||||
QStringList list;
|
||||
std::vector<std::string> tags;
|
||||
if (categoryFilter != "all") {
|
||||
tags.push_back(categoryFilter.toStdString());
|
||||
}
|
||||
for(auto& id: m_library.listBooksIds(kiwix::VALID|kiwix::LOCAL,
|
||||
kiwix::UNSORTED,
|
||||
query.toStdString(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
tags)) {
|
||||
auto bookIds = m_library.filter(filter);
|
||||
for(auto& id: bookIds) {
|
||||
list.append(QString::fromStdString(id));
|
||||
}
|
||||
return list;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
QString openBookFromPath(const QString& zimPath);
|
||||
std::shared_ptr<kiwix::Reader> getReader(const QString& zimId);
|
||||
QStringList getBookIds();
|
||||
QStringList listBookIds(const QString& query, const QString &categoryFilter);
|
||||
QStringList listBookIds(const kiwix::Filter& filter);
|
||||
const std::vector<kiwix::Bookmark>& getBookmarks() { return m_library.getBookmarks(); }
|
||||
void addBookToLibrary(kiwix::Book& book);
|
||||
void removeBookFromLibraryById(const QString& id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user