Enter Book::getIllustrations()

This commit is contained in:
Veloman Yunkan 2021-11-18 14:25:03 +04:00
parent e2544799a1
commit eb6a0d6456
3 changed files with 13 additions and 4 deletions

View File

@ -59,6 +59,8 @@ class Book
mutable std::string data;
};
typedef std::vector<std::shared_ptr<const Illustration>> Illustrations;
public: // functions
Book();
~Book();
@ -95,6 +97,8 @@ class Book
const std::string& getFaviconUrl() const;
const std::string& getFaviconMimeType() const;
Illustrations getIllustrations() const;
const std::string& getDownloadId() const { return m_downloadId; }
void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
@ -142,7 +146,7 @@ class Book
uint64_t m_mediaCount = 0;
bool m_readOnly = false;
uint64_t m_size = 0;
std::vector<std::shared_ptr<const Illustration>> m_illustrations;
Illustrations m_illustrations;
// Used as the return value of getDefaultIllustration() when no default
// illustration is found in the book

View File

@ -47,6 +47,11 @@ Book::~Book()
{
}
Book::Illustrations Book::getIllustrations() const
{
return m_illustrations;
}
bool Book::update(const kiwix::Book& other)
{
if (m_readOnly)

View File

@ -58,10 +58,10 @@ IllustrationInfo getBookIllustrationInfo(const Book& book)
{
kainjow::mustache::list illustrations;
if ( book.isPathValid() ) {
for ( auto illustration_size : zim::Archive(book.getPath()).getIllustrationSizes() ) {
for ( const auto& illustration : book.getIllustrations() ) {
illustrations.push_back(kainjow::mustache::object{
{"icon_width", to_string(illustration_size)},
{"icon_height", to_string(illustration_size)},
{"icon_width", to_string(illustration->width)},
{"icon_height", to_string(illustration->height)},
{"icon_scale", "1"},
});
}