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

View File

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