From f4bc3c8ced2a4b8954e2b8cb2b334d514c19ec9f Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 31 Oct 2021 17:02:42 +0400 Subject: [PATCH] Book::Illustration got dimensions --- include/book.h | 2 ++ src/book.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/book.h b/include/book.h index 0f21bc481..04d71b1a3 100644 --- a/include/book.h +++ b/include/book.h @@ -48,6 +48,8 @@ class Book { friend class Book; public: + uint16_t width = 48; + uint16_t height = 48; std::string mimeType; std::string url; diff --git a/src/book.cpp b/src/book.cpp index faee20dfe..50a144bb6 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -226,8 +226,12 @@ void Book::setPath(const std::string& path) const Book::Illustration& Book::getDefaultIllustration() const { - assert(m_illustrations.size() == 1); - return *m_illustrations.front(); + for ( const auto& ilPtr : m_illustrations ) { + if (ilPtr->width == 48 && ilPtr->height == 48) { + return *ilPtr; + } + } + throw std::runtime_error("No default illustration"); } Book::Illustration& Book::getMutableDefaultIllustration()