mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Renamed ContentManagerModel::{iconMap -> m_iconMap}
... and stopped passing it (as the second parameter) into ContentManagerModel::createNode().
This commit is contained in:
parent
75ecdeb03e
commit
32f839b192
@ -111,7 +111,7 @@ void ContentManagerModel::setBooksData(const BookInfoList& data)
|
|||||||
emit dataChanged(QModelIndex(), QModelIndex());
|
emit dataChanged(QModelIndex(), QModelIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RowNode> ContentManagerModel::createNode(BookInfo bookItem, QMap<QString, QByteArray> iconMap) const
|
std::shared_ptr<RowNode> ContentManagerModel::createNode(BookInfo bookItem) const
|
||||||
{
|
{
|
||||||
const auto faviconUrl = bookItem["faviconUrl"].toString();
|
const auto faviconUrl = bookItem["faviconUrl"].toString();
|
||||||
QString id = bookItem["id"].toString();
|
QString id = bookItem["id"].toString();
|
||||||
@ -124,8 +124,8 @@ std::shared_ptr<RowNode> ContentManagerModel::createNode(BookInfo bookItem, QMap
|
|||||||
bookIcon = QByteArray::fromRawData(reinterpret_cast<const char*>(favicon.data()), favicon.size());
|
bookIcon = QByteArray::fromRawData(reinterpret_cast<const char*>(favicon.data()), favicon.size());
|
||||||
bookIcon.detach(); // deep copy
|
bookIcon.detach(); // deep copy
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (iconMap.contains(faviconUrl)) {
|
if (m_iconMap.contains(faviconUrl)) {
|
||||||
bookIcon = iconMap[faviconUrl];
|
bookIcon = m_iconMap[faviconUrl];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::weak_ptr<RowNode> weakRoot = rootNode;
|
std::weak_ptr<RowNode> weakRoot = rootNode;
|
||||||
@ -147,7 +147,7 @@ void ContentManagerModel::setupNodes()
|
|||||||
beginResetModel();
|
beginResetModel();
|
||||||
bookIdToRowMap.clear();
|
bookIdToRowMap.clear();
|
||||||
for (auto bookItem : m_data) {
|
for (auto bookItem : m_data) {
|
||||||
const auto rowNode = createNode(bookItem, iconMap);
|
const auto rowNode = createNode(bookItem);
|
||||||
|
|
||||||
// Restore download state during model updates (filtering, etc)
|
// Restore download state during model updates (filtering, etc)
|
||||||
const auto downloadIter = m_downloads.constFind(rowNode->getBookId());
|
const auto downloadIter = m_downloads.constFind(rowNode->getBookId());
|
||||||
@ -175,7 +175,7 @@ void ContentManagerModel::refreshIcons()
|
|||||||
auto book = app->getLibrary()->getBookById(id);
|
auto book = app->getLibrary()->getBookById(id);
|
||||||
auto item = book.getIllustration(48);
|
auto item = book.getIllustration(48);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (faviconUrl != "" && !iconMap.contains(faviconUrl)) {
|
if (faviconUrl != "" && !m_iconMap.contains(faviconUrl)) {
|
||||||
td.addDownload(faviconUrl, id);
|
td.addDownload(faviconUrl, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ void ContentManagerModel::updateImage(QString bookId, QString url, QByteArray im
|
|||||||
const size_t row = it.value();
|
const size_t row = it.value();
|
||||||
const auto item = static_cast<RowNode*>(rootNode->child(row).get());
|
const auto item = static_cast<RowNode*>(rootNode->child(row).get());
|
||||||
item->setIconData(imageData);
|
item->setIconData(imageData);
|
||||||
iconMap[url] = imageData;
|
m_iconMap[url] = imageData;
|
||||||
const QModelIndex index = this->index(row, 0);
|
const QModelIndex index = this->index(row, 0);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public: // functions
|
|||||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||||
void refreshIcons();
|
void refreshIcons();
|
||||||
|
|
||||||
std::shared_ptr<RowNode> createNode(BookInfo bookItem, QMap<QString, QByteArray> iconMap) const;
|
std::shared_ptr<RowNode> createNode(BookInfo bookItem) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateImage(QString bookId, QString url, QByteArray imageData);
|
void updateImage(QString bookId, QString url, QByteArray imageData);
|
||||||
@ -62,7 +62,7 @@ private: // data
|
|||||||
int zimCount = 0;
|
int zimCount = 0;
|
||||||
ThumbnailDownloader td;
|
ThumbnailDownloader td;
|
||||||
QMap<QString, size_t> bookIdToRowMap;
|
QMap<QString, size_t> bookIdToRowMap;
|
||||||
QMap<QString, QByteArray> iconMap;
|
QMap<QString, QByteArray> m_iconMap;
|
||||||
const Downloads& m_downloads;
|
const Downloads& m_downloads;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user