diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 08703db..571a213 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -506,7 +506,7 @@ void ContentManager::downloadStarted(const kiwix::Book& book, const std::string& void ContentManager::removeDownload(QString bookId) { DownloadManager::removeDownload(bookId); - managerModel->removeDownload(bookId); + managerModel->setDownloadState(bookId, nullptr); } void ContentManager::downloadDisappeared(QString bookId) @@ -553,13 +553,13 @@ void ContentManager::updateDownload(QString bookId, const DownloadInfo& download } } -void ContentManager::downloadBook(const QString &id, QModelIndex index) +void ContentManager::downloadBook(const QString &id, QModelIndex /*index*/) { try { downloadBook(id); - const auto node = static_cast(index.internalPointer()); - node->setDownloadState(DownloadManager::getDownloadState(id)); + const auto downloadState = DownloadManager::getDownloadState(id); + managerModel->setDownloadState(id, downloadState); } catch ( const ContentManagerError& err ) { diff --git a/src/contentmanagermodel.cpp b/src/contentmanagermodel.cpp index 27e0c2b..e79565b 100644 --- a/src/contentmanagermodel.cpp +++ b/src/contentmanagermodel.cpp @@ -265,14 +265,14 @@ void ContentManagerModel::triggerDataUpdateAt(QModelIndex index) emit dataChanged(index, index); } -void ContentManagerModel::removeDownload(QString bookId) +void ContentManagerModel::setDownloadState(QString bookId, std::shared_ptr ds) { const auto it = bookIdToRowMap.constFind(bookId); if ( it == bookIdToRowMap.constEnd() ) return; const size_t row = it.value(); - getRowNode(row)->setDownloadState(nullptr); + getRowNode(row)->setDownloadState(ds); triggerDataUpdateAt( this->index(row, 5) ); } diff --git a/src/contentmanagermodel.h b/src/contentmanagermodel.h index ae133e9..7853e04 100644 --- a/src/contentmanagermodel.h +++ b/src/contentmanagermodel.h @@ -45,7 +45,7 @@ public: // functions public slots: void updateImage(QString bookId, QString url, QByteArray imageData); void triggerDataUpdateAt(QModelIndex index); - void removeDownload(QString bookId); + void setDownloadState(QString bookId, std::shared_ptr ds); void updateDownload(QString bookId); private: // functions