ContentManagerModel::{removeDownload -> setDownloadState}()

This commit is contained in:
Veloman Yunkan 2024-05-30 14:17:40 +04:00 committed by Kelson
parent a7fb85b8b0
commit 4f6b0f1bab
3 changed files with 7 additions and 7 deletions

View File

@ -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<RowNode*>(index.internalPointer());
node->setDownloadState(DownloadManager::getDownloadState(id));
const auto downloadState = DownloadManager::getDownloadState(id);
managerModel->setDownloadState(id, downloadState);
}
catch ( const ContentManagerError& err )
{

View File

@ -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<DownloadState> 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) );
}

View File

@ -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<DownloadState> ds);
void updateDownload(QString bookId);
private: // functions