Made DownloadManager::mp_downloader private

This commit is contained in:
Veloman Yunkan 2024-05-30 12:01:36 +04:00 committed by Kelson
parent fffe7586b4
commit 6bbbe7dafc
3 changed files with 10 additions and 5 deletions

View File

@ -149,7 +149,7 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader)
connect(this, &DownloadManager::downloadDisappeared,
this, &ContentManager::downloadDisappeared);
if ( mp_downloader ) {
if ( DownloadManager::downloadingFunctionalityAvailable() ) {
startDownloadUpdaterThread();
}
}
@ -605,7 +605,7 @@ std::string ContentManager::startDownload(const kiwix::Book& book)
void ContentManager::downloadBook(const QString &id)
{
if (!mp_downloader)
if ( ! DownloadManager::downloadingFunctionalityAvailable() )
throwDownloadUnavailableError();
const auto& book = getRemoteOrLocalBook(id);

View File

@ -56,6 +56,11 @@ DownloadManager::~DownloadManager()
}
}
bool DownloadManager::downloadingFunctionalityAvailable() const
{
return mp_downloader != nullptr;
}
void DownloadManager::startDownloadUpdaterThread()
{
// so that DownloadInfo can be copied across threads

View File

@ -72,6 +72,8 @@ public: // functions
DownloadManager(const Library* lib, kiwix::Downloader *downloader);
virtual ~DownloadManager();
bool downloadingFunctionalityAvailable() const;
void startDownloadUpdaterThread();
DownloadInfo getDownloadInfo(QString bookId) const;
@ -94,11 +96,9 @@ signals:
void downloadUpdated(QString bookId, const DownloadInfo& );
void downloadDisappeared(QString bookId);
protected: // data
private: // data
const Library* const mp_library;
kiwix::Downloader* const mp_downloader;
private:
Downloads m_downloads;
QThread* mp_downloadUpdaterThread = nullptr;
};