From aadce46adf90e5084b9ecf26bf4dd741f341270a Mon Sep 17 00:00:00 2001 From: kelson42 Date: Tue, 11 Oct 2011 22:22:14 +0000 Subject: [PATCH] + improve filter --- src/common/kiwix/manager.cpp | 9 ++++++++- src/common/kiwix/manager.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index 184de56ce..e73247505 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -435,7 +435,8 @@ namespace kiwix { return result; } - bool Manager::listBooks(const supportedListMode mode, const supportedListSortBy sortBy, const unsigned int maxSize) { + bool Manager::listBooks(const supportedListMode mode, const supportedListSortBy sortBy, const unsigned int maxSize, + const string language, const string publisher) { this->bookIdList.clear(); std::vector::iterator itr; @@ -470,6 +471,12 @@ namespace kiwix { if (atoi(itr->size.c_str()) > maxSize * 1024 * 1024) ok = false; + if (!language.empty() && itr->language != language) + ok = false; + + if (!publisher.empty() && itr->creator != publisher) + ok = false; + if (ok == true) this->bookIdList.push_back(itr->id); } diff --git a/src/common/kiwix/manager.h b/src/common/kiwix/manager.h index 171a24ecb..75fe7325d 100644 --- a/src/common/kiwix/manager.h +++ b/src/common/kiwix/manager.h @@ -63,7 +63,8 @@ namespace kiwix { unsigned int getBookCount(const bool localBooks, const bool remoteBooks); bool updateBookLastOpenDateById(const string id); void removeBookPaths(); - bool listBooks(const supportedListMode mode, const supportedListSortBy sortBy, const unsigned int maxSize); + bool listBooks(const supportedListMode mode, const supportedListSortBy sortBy, const unsigned int maxSize, + const string language, const string publisher); vector getBooksLanguages(); vector getBooksPublishers();