mirror of https://github.com/kiwix/libkiwix.git
Internally Book supports multiple illustrations
This commit is contained in:
parent
c129952605
commit
5263f6880c
|
@ -21,6 +21,8 @@
|
|||
#define KIWIX_BOOK_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace pugi {
|
||||
class xml_node;
|
||||
|
@ -139,7 +141,7 @@ class Book
|
|||
uint64_t m_mediaCount = 0;
|
||||
bool m_readOnly = false;
|
||||
uint64_t m_size = 0;
|
||||
Illustration m_illustration;
|
||||
std::vector<std::shared_ptr<Illustration>> m_illustrations;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
14
src/book.cpp
14
src/book.cpp
|
@ -40,7 +40,10 @@ Book::Book() :
|
|||
m_pathValid(false),
|
||||
m_readOnly(false)
|
||||
{
|
||||
const auto illustration = std::make_shared<Illustration>();
|
||||
m_illustrations.assign(1, illustration);
|
||||
}
|
||||
|
||||
/* Destructor */
|
||||
Book::~Book()
|
||||
{
|
||||
|
@ -72,7 +75,10 @@ bool Book::update(const kiwix::Book& other)
|
|||
m_articleCount = other.m_articleCount;
|
||||
m_mediaCount = other.m_mediaCount;
|
||||
m_size = other.m_size;
|
||||
m_illustration = other.m_illustration;
|
||||
m_illustrations.clear();
|
||||
for ( const auto& ill : other.m_illustrations ) {
|
||||
m_illustrations.push_back(std::make_shared<Illustration>(*ill));
|
||||
}
|
||||
|
||||
m_downloadId = other.m_downloadId;
|
||||
|
||||
|
@ -220,12 +226,14 @@ void Book::setPath(const std::string& path)
|
|||
|
||||
const Book::Illustration& Book::getDefaultIllustration() const
|
||||
{
|
||||
return m_illustration;
|
||||
assert(m_illustrations.size() == 1);
|
||||
return *m_illustrations.front();
|
||||
}
|
||||
|
||||
Book::Illustration& Book::getMutableDefaultIllustration()
|
||||
{
|
||||
return m_illustration;
|
||||
const Book* const const_this = this;
|
||||
return const_cast<Illustration&>(const_this->getDefaultIllustration());
|
||||
}
|
||||
|
||||
const std::string& Book::Illustration::getData() const
|
||||
|
|
Loading…
Reference in New Issue