DownloadManager::getDownloadState()

This commit is contained in:
Veloman Yunkan 2024-05-30 11:01:00 +04:00 committed by Kelson
parent be017b7e2c
commit e6c2effa0f
2 changed files with 8 additions and 3 deletions

View File

@ -445,7 +445,7 @@ ContentManager::BookInfo ContentManager::getBookInfos(QString id, const QStringL
ContentManager::BookState ContentManager::getBookState(QString bookId)
{
if ( const auto downloadState = m_downloads.value(bookId) ) {
if ( const auto downloadState = DownloadManager::getDownloadState(bookId) ) {
return downloadState->paused
? BookState::DOWNLOAD_PAUSED
: BookState::DOWNLOADING;
@ -562,7 +562,7 @@ void ContentManager::downloadCompleted(QString bookId, QString path)
void ContentManager::updateDownload(QString bookId, const DownloadInfo& downloadInfo)
{
const auto downloadState = m_downloads.value(bookId);
const auto downloadState = DownloadManager::getDownloadState(bookId);
if ( downloadState ) {
const auto downloadPath = downloadInfo["path"].toString();
if ( downloadInfo["status"].toString() == "completed" ) {

View File

@ -33,12 +33,12 @@ class DownloadManager : public QObject
Q_OBJECT
public: // types
typedef std::shared_ptr<DownloadState> DownloadStatePtr;
// BookId -> DownloadState map
class Downloads
{
private:
typedef std::shared_ptr<DownloadState> DownloadStatePtr;
typedef QMap<QString, DownloadStatePtr> ImplType;
public:
@ -81,6 +81,11 @@ public: // functions
bool cancelDownload(const QString& bookId);
void removeDownload(QString bookId);
DownloadStatePtr getDownloadState(QString bookId) const
{
return m_downloads.value(bookId);
}
signals:
void downloadUpdated(QString bookId, const DownloadInfo& );
void downloadDisappeared(QString bookId);