mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Extracted ContentManagerModel::getThumbnail()
This commit is contained in:
parent
32f839b192
commit
622f9a0ff8
@ -111,9 +111,8 @@ void ContentManagerModel::setBooksData(const BookInfoList& data)
|
||||
emit dataChanged(QModelIndex(), QModelIndex());
|
||||
}
|
||||
|
||||
std::shared_ptr<RowNode> ContentManagerModel::createNode(BookInfo bookItem) const
|
||||
QByteArray ContentManagerModel::getThumbnail(const BookInfo& bookItem) const
|
||||
{
|
||||
const auto faviconUrl = bookItem["faviconUrl"].toString();
|
||||
QString id = bookItem["id"].toString();
|
||||
QByteArray bookIcon;
|
||||
try {
|
||||
@ -124,10 +123,18 @@ std::shared_ptr<RowNode> ContentManagerModel::createNode(BookInfo bookItem) cons
|
||||
bookIcon = QByteArray::fromRawData(reinterpret_cast<const char*>(favicon.data()), favicon.size());
|
||||
bookIcon.detach(); // deep copy
|
||||
} catch (...) {
|
||||
const auto faviconUrl = bookItem["faviconUrl"].toString();
|
||||
if (m_iconMap.contains(faviconUrl)) {
|
||||
bookIcon = m_iconMap[faviconUrl];
|
||||
}
|
||||
}
|
||||
return bookIcon;
|
||||
}
|
||||
|
||||
std::shared_ptr<RowNode> ContentManagerModel::createNode(BookInfo bookItem) const
|
||||
{
|
||||
QString id = bookItem["id"].toString();
|
||||
const QByteArray bookIcon = getThumbnail(bookItem);
|
||||
std::weak_ptr<RowNode> weakRoot = rootNode;
|
||||
auto rowNodePtr = std::shared_ptr<RowNode>(new
|
||||
RowNode({bookIcon, bookItem["title"],
|
||||
|
@ -56,6 +56,9 @@ protected: // functions
|
||||
bool canFetchMore(const QModelIndex &parent) const override;
|
||||
void fetchMore(const QModelIndex &parent) override;
|
||||
|
||||
private: // functions
|
||||
QByteArray getThumbnail(const BookInfo& bookItem) const;
|
||||
|
||||
private: // data
|
||||
BookInfoList m_data;
|
||||
std::shared_ptr<RowNode> rootNode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user