mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Reduced the in-use API of ContentManagerModel::Downloads
... in preparation for converting `ContentManagerModel::Downloads` into a thread-safe class.
This commit is contained in:
parent
de296ed548
commit
728a8a44bb
@ -674,7 +674,9 @@ void ContentManager::pauseBook(const QString& id, QModelIndex index)
|
||||
auto download = mp_downloader->getDownload(b.getDownloadId());
|
||||
if (download->getStatus() == kiwix::Download::K_ACTIVE) {
|
||||
download->pauseDownload();
|
||||
m_downloads[id]->pause();
|
||||
if ( const auto downloadState = m_downloads.value(id) ) {
|
||||
downloadState->pause();
|
||||
}
|
||||
}
|
||||
managerModel->triggerDataUpdateAt(index);
|
||||
}
|
||||
@ -685,7 +687,9 @@ void ContentManager::resumeBook(const QString& id, QModelIndex index)
|
||||
auto download = mp_downloader->getDownload(b.getDownloadId());
|
||||
if (download->getStatus() == kiwix::Download::K_PAUSED) {
|
||||
download->resumeDownload();
|
||||
m_downloads[id]->resume();
|
||||
if ( const auto downloadState = m_downloads.value(id) ) {
|
||||
downloadState->resume();
|
||||
}
|
||||
}
|
||||
managerModel->triggerDataUpdateAt(index);
|
||||
}
|
||||
|
@ -123,10 +123,7 @@ void ContentManagerModel::setBooksData(const BookInfoList& data, const Downloads
|
||||
const auto rowNode = createNode(bookItem);
|
||||
|
||||
// Restore download state during model updates (filtering, etc)
|
||||
const auto downloadIter = downloads.constFind(rowNode->getBookId());
|
||||
if ( downloadIter != downloads.constEnd() ) {
|
||||
rowNode->setDownloadState(downloadIter.value());
|
||||
}
|
||||
rowNode->setDownloadState(downloads.value(rowNode->getBookId()));
|
||||
|
||||
bookIdToRowMap[bookItem["id"].toString()] = rootNode->childCount();
|
||||
rootNode->appendChild(rowNode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user