Got rid of ContentManager::downloadStarted()

This commit is contained in:
Veloman Yunkan 2024-05-30 14:24:41 +04:00 committed by Kelson
parent 4f6b0f1bab
commit b43607a919
2 changed files with 6 additions and 12 deletions

View File

@ -494,15 +494,6 @@ void ContentManager::openBookPreview(const QString &id)
} catch (...) {}
}
void ContentManager::downloadStarted(const kiwix::Book& book, const std::string& downloadId)
{
kiwix::Book bookCopy(book);
bookCopy.setDownloadId(downloadId);
mp_library->addBookBeingDownloaded(bookCopy, getSettingsManager()->getDownloadDir());
mp_library->save();
emit(oneBookChanged(QString::fromStdString(book.getId())));
}
void ContentManager::removeDownload(QString bookId)
{
DownloadManager::removeDownload(bookId);
@ -560,6 +551,7 @@ void ContentManager::downloadBook(const QString &id, QModelIndex /*index*/)
downloadBook(id);
const auto downloadState = DownloadManager::getDownloadState(id);
managerModel->setDownloadState(id, downloadState);
emit(oneBookChanged(id));
}
catch ( const ContentManagerError& err )
{
@ -587,7 +579,7 @@ QString ContentManager::getRemoteLibraryUrl() const
void ContentManager::downloadBook(const QString &id)
{
const auto& book = getRemoteOrLocalBook(id);
kiwix::Book book = getRemoteOrLocalBook(id);
const auto downloadPath = getSettingsManager()->getDownloadDir();
checkThatBookCanBeSaved(book, downloadPath);
@ -598,7 +590,10 @@ void ContentManager::downloadBook(const QString &id)
} catch (std::exception& e) {
throwDownloadUnavailableError();
}
downloadStarted(book, downloadId);
book.setDownloadId(downloadId);
mp_library->addBookBeingDownloaded(book, downloadPath);
mp_library->save();
}
static const char MSG_FOR_PREVENTED_RMSTAR_OPERATION[] = R"(

View File

@ -122,7 +122,6 @@ private: // functions
QString getRemoteLibraryUrl() const;
void removeDownload(QString bookId);
void downloadStarted(const kiwix::Book& book, const std::string& downloadId);
void downloadDisappeared(QString bookId);
void downloadCompleted(QString bookId, QString path);