diff --git a/include/library.h b/include/library.h index b56dab896..4a859086d 100644 --- a/include/library.h +++ b/include/library.h @@ -122,6 +122,9 @@ class Library std::map> m_readers; std::vector m_bookmarks; + public: + typedef std::vector BookIdCollection; + public: Library(); ~Library(); @@ -224,7 +227,7 @@ class Library * * @return A list of book ids. */ - std::vector getBooksIds(); + BookIdCollection getBooksIds(); /** * Filter the library and generate a new one with the keep elements. @@ -234,7 +237,7 @@ class Library * @param search List only books with search in the title or description. * @return The list of bookIds corresponding to the query. */ - DEPRECATED std::vector filter(const std::string& search); + DEPRECATED BookIdCollection filter(const std::string& search); /** @@ -243,7 +246,7 @@ class Library * @param filter The filter to use. * @return The list of bookIds corresponding to the filter. */ - std::vector filter(const Filter& filter); + BookIdCollection filter(const Filter& filter); /** @@ -253,7 +256,7 @@ class Library * @param comparator how to sort the books * @return The sorted list of books */ - void sort(std::vector& bookIds, supportedListSortBy sortBy, bool ascending); + void sort(BookIdCollection& bookIds, supportedListSortBy sortBy, bool ascending); /** * List books in the library. @@ -277,7 +280,7 @@ class Library * Set to 0 to cancel this filter. * @return The list of bookIds corresponding to the query. */ - DEPRECATED std::vector listBooksIds( + DEPRECATED BookIdCollection listBooksIds( int supportedListMode = ALL, supportedListSortBy sortBy = UNSORTED, const std::string& search = "", diff --git a/src/library.cpp b/src/library.cpp index b16c4b9d6..920d93eda 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -211,9 +211,9 @@ const std::vector Library::getBookmarks(bool onlyValidBookmarks return validBookmarks; } -std::vector Library::getBooksIds() +Library::BookIdCollection Library::getBooksIds() { - std::vector bookIds; + BookIdCollection bookIds; for (auto& pair: m_books) { bookIds.push_back(pair.first); @@ -222,7 +222,7 @@ std::vector Library::getBooksIds() return bookIds; } -std::vector Library::filter(const std::string& search) +Library::BookIdCollection Library::filter(const std::string& search) { if (search.empty()) { return getBooksIds(); @@ -232,16 +232,16 @@ std::vector Library::filter(const std::string& search) } -std::vector Library::filter(const Filter& filter) +Library::BookIdCollection Library::filter(const Filter& filter) { - std::vector bookIds; + BookIdCollection bookIds; for(auto& pair:m_books) { if(filter.acceptByQueryOnly(pair.second)) { bookIds.push_back(pair.first); } } - std::vector result; + BookIdCollection result; for(auto id : bookIds) { if(filter.acceptByNonQueryCriteria(m_books[id])) { result.push_back(id); @@ -309,7 +309,7 @@ std::string Comparator::get_key(const std::string& id) return lib->getBookById(id).getPublisher(); } -void Library::sort(std::vector& bookIds, supportedListSortBy sort, bool ascending) +void Library::sort(BookIdCollection& bookIds, supportedListSortBy sort, bool ascending) { switch(sort) { case TITLE: @@ -333,7 +333,7 @@ void Library::sort(std::vector& bookIds, supportedListSortBy sort, } -std::vector Library::listBooksIds( +Library::BookIdCollection Library::listBooksIds( int mode, supportedListSortBy sortBy, const std::string& search,