diff --git a/include/library.h b/include/library.h index 3c79fed0e..6425ba63d 100644 --- a/include/library.h +++ b/include/library.h @@ -57,6 +57,7 @@ class Filter { std::string _creator; size_t _maxSize; std::string _query; + std::string _name; public: Filter(); @@ -100,6 +101,7 @@ class Filter { Filter& creator(std::string creator); Filter& maxSize(size_t size); Filter& query(std::string query); + Filter& name(std::string name); bool accept(const Book& book) const; }; diff --git a/src/library.cpp b/src/library.cpp index 12ff5a18d..fc027718d 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -378,6 +378,7 @@ enum filterTypes { _CREATOR = FLAG(10), MAXSIZE = FLAG(11), QUERY = FLAG(12), + NAME = FLAG(13), }; Filter& Filter::local(bool accept) @@ -465,6 +466,13 @@ Filter& Filter::query(std::string query) return *this; } +Filter& Filter::name(std::string name) +{ + _name = name; + activeFilters |= NAME; + return *this; +} + #define ACTIVE(X) (activeFilters & (X)) #define FILTER(TAG, TEST) if (ACTIVE(TAG) && !(TEST)) { return false; } bool Filter::accept(const Book& book) const @@ -485,6 +493,7 @@ bool Filter::accept(const Book& book) const FILTER(LANG, book.getLanguage() == _lang) FILTER(_PUBLISHER, book.getPublisher() == _publisher) FILTER(_CREATOR, book.getCreator() == _creator) + FILTER(NAME, book.getName() == _name) if (ACTIVE(ACCEPTTAGS)) { if (!_acceptTags.empty()) {