mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 02:51:26 -04:00
DownloadManager::getDownloadState()
This commit is contained in:
parent
be017b7e2c
commit
e6c2effa0f
@ -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" ) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user