mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
Be able to filter the books by name.
This commit is contained in:
@ -57,6 +57,7 @@ class Filter {
|
|||||||
std::string _creator;
|
std::string _creator;
|
||||||
size_t _maxSize;
|
size_t _maxSize;
|
||||||
std::string _query;
|
std::string _query;
|
||||||
|
std::string _name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Filter();
|
Filter();
|
||||||
@ -100,6 +101,7 @@ class Filter {
|
|||||||
Filter& creator(std::string creator);
|
Filter& creator(std::string creator);
|
||||||
Filter& maxSize(size_t size);
|
Filter& maxSize(size_t size);
|
||||||
Filter& query(std::string query);
|
Filter& query(std::string query);
|
||||||
|
Filter& name(std::string name);
|
||||||
|
|
||||||
bool accept(const Book& book) const;
|
bool accept(const Book& book) const;
|
||||||
};
|
};
|
||||||
|
@ -378,6 +378,7 @@ enum filterTypes {
|
|||||||
_CREATOR = FLAG(10),
|
_CREATOR = FLAG(10),
|
||||||
MAXSIZE = FLAG(11),
|
MAXSIZE = FLAG(11),
|
||||||
QUERY = FLAG(12),
|
QUERY = FLAG(12),
|
||||||
|
NAME = FLAG(13),
|
||||||
};
|
};
|
||||||
|
|
||||||
Filter& Filter::local(bool accept)
|
Filter& Filter::local(bool accept)
|
||||||
@ -465,6 +466,13 @@ Filter& Filter::query(std::string query)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Filter& Filter::name(std::string name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
activeFilters |= NAME;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#define ACTIVE(X) (activeFilters & (X))
|
#define ACTIVE(X) (activeFilters & (X))
|
||||||
#define FILTER(TAG, TEST) if (ACTIVE(TAG) && !(TEST)) { return false; }
|
#define FILTER(TAG, TEST) if (ACTIVE(TAG) && !(TEST)) { return false; }
|
||||||
bool Filter::accept(const Book& book) const
|
bool Filter::accept(const Book& book) const
|
||||||
@ -485,6 +493,7 @@ bool Filter::accept(const Book& book) const
|
|||||||
FILTER(LANG, book.getLanguage() == _lang)
|
FILTER(LANG, book.getLanguage() == _lang)
|
||||||
FILTER(_PUBLISHER, book.getPublisher() == _publisher)
|
FILTER(_PUBLISHER, book.getPublisher() == _publisher)
|
||||||
FILTER(_CREATOR, book.getCreator() == _creator)
|
FILTER(_CREATOR, book.getCreator() == _creator)
|
||||||
|
FILTER(NAME, book.getName() == _name)
|
||||||
|
|
||||||
if (ACTIVE(ACCEPTTAGS)) {
|
if (ACTIVE(ACCEPTTAGS)) {
|
||||||
if (!_acceptTags.empty()) {
|
if (!_acceptTags.empty()) {
|
||||||
|
Reference in New Issue
Block a user