mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -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)
|
ContentManager::BookState ContentManager::getBookState(QString bookId)
|
||||||
{
|
{
|
||||||
if ( const auto downloadState = m_downloads.value(bookId) ) {
|
if ( const auto downloadState = DownloadManager::getDownloadState(bookId) ) {
|
||||||
return downloadState->paused
|
return downloadState->paused
|
||||||
? BookState::DOWNLOAD_PAUSED
|
? BookState::DOWNLOAD_PAUSED
|
||||||
: BookState::DOWNLOADING;
|
: BookState::DOWNLOADING;
|
||||||
@ -562,7 +562,7 @@ void ContentManager::downloadCompleted(QString bookId, QString path)
|
|||||||
|
|
||||||
void ContentManager::updateDownload(QString bookId, const DownloadInfo& downloadInfo)
|
void ContentManager::updateDownload(QString bookId, const DownloadInfo& downloadInfo)
|
||||||
{
|
{
|
||||||
const auto downloadState = m_downloads.value(bookId);
|
const auto downloadState = DownloadManager::getDownloadState(bookId);
|
||||||
if ( downloadState ) {
|
if ( downloadState ) {
|
||||||
const auto downloadPath = downloadInfo["path"].toString();
|
const auto downloadPath = downloadInfo["path"].toString();
|
||||||
if ( downloadInfo["status"].toString() == "completed" ) {
|
if ( downloadInfo["status"].toString() == "completed" ) {
|
||||||
|
@ -33,12 +33,12 @@ class DownloadManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public: // types
|
public: // types
|
||||||
|
typedef std::shared_ptr<DownloadState> DownloadStatePtr;
|
||||||
|
|
||||||
// BookId -> DownloadState map
|
// BookId -> DownloadState map
|
||||||
class Downloads
|
class Downloads
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef std::shared_ptr<DownloadState> DownloadStatePtr;
|
|
||||||
typedef QMap<QString, DownloadStatePtr> ImplType;
|
typedef QMap<QString, DownloadStatePtr> ImplType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -81,6 +81,11 @@ public: // functions
|
|||||||
bool cancelDownload(const QString& bookId);
|
bool cancelDownload(const QString& bookId);
|
||||||
void removeDownload(QString bookId);
|
void removeDownload(QString bookId);
|
||||||
|
|
||||||
|
DownloadStatePtr getDownloadState(QString bookId) const
|
||||||
|
{
|
||||||
|
return m_downloads.value(bookId);
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void downloadUpdated(QString bookId, const DownloadInfo& );
|
void downloadUpdated(QString bookId, const DownloadInfo& );
|
||||||
void downloadDisappeared(QString bookId);
|
void downloadDisappeared(QString bookId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user