Improve const correctness in Library

This makes getBookIds(), listBookIds(), and getBookmarks() const member functions
This commit is contained in:
Nikhil Tanwar 2022-02-03 20:02:23 +05:30 committed by Emmanuel Engelhart
parent e1472b2a47
commit 324ffbb326
No known key found for this signature in database
GPG Key ID: 120B30D020B553D3
2 changed files with 5 additions and 5 deletions

View File

@ -76,7 +76,7 @@ std::shared_ptr<kiwix::Searcher> Library::getSearcher(const QString &zimId)
return searcher;
}
QStringList Library::getBookIds()
QStringList Library::getBookIds() const
{
QStringList list;
for(auto& id: m_library.getBooksIds()) {
@ -85,7 +85,7 @@ QStringList Library::getBookIds()
return list;
}
QStringList Library::listBookIds(const kiwix::Filter& filter, kiwix::supportedListSortBy sortBy, bool ascending)
QStringList Library::listBookIds(const kiwix::Filter& filter, kiwix::supportedListSortBy sortBy, bool ascending) const
{
QStringList list;
auto bookIds = m_library.filter(filter);

View File

@ -30,9 +30,9 @@ public:
QString openBookFromPath(const QString& zimPath);
std::shared_ptr<kiwix::Reader> getReader(const QString& zimId);
std::shared_ptr<kiwix::Searcher> getSearcher(const QString& zimId);
QStringList getBookIds();
QStringList listBookIds(const kiwix::Filter& filter, kiwix::supportedListSortBy sortBy, bool ascending);
const std::vector<kiwix::Bookmark> getBookmarks(bool onlyValidBookmarks = false) { return m_library.getBookmarks(onlyValidBookmarks); }
QStringList getBookIds() const;
QStringList listBookIds(const kiwix::Filter& filter, kiwix::supportedListSortBy sortBy, bool ascending) const;
const std::vector<kiwix::Bookmark> getBookmarks(bool onlyValidBookmarks = false) const { return m_library.getBookmarks(onlyValidBookmarks); }
void addBookToLibrary(kiwix::Book& book);
void removeBookFromLibraryById(const QString& id);
void addBookmark(kiwix::Bookmark& bookmark);