mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-26 06:12:17 -04:00
Made DownloadState::update() a setter
DownloadState::update() no longer calls ContentManager::updateDownloadInfos()
This commit is contained in:
parent
a6359af1ab
commit
b288f287f2
@ -437,7 +437,7 @@ void ContentManager::downloadCompleted(QString bookId, QString path)
|
||||
}
|
||||
}
|
||||
|
||||
ContentManager::DownloadInfo ContentManager::getDownloadInfo(QString bookId, const QStringList &keys) const
|
||||
DownloadInfo ContentManager::getDownloadInfo(QString bookId, const QStringList &keys) const
|
||||
{
|
||||
DownloadInfo values;
|
||||
if (!mp_downloader) {
|
||||
@ -464,7 +464,7 @@ ContentManager::DownloadInfo ContentManager::getDownloadInfo(QString bookId, con
|
||||
return values;
|
||||
}
|
||||
|
||||
ContentManager::DownloadInfo ContentManager::updateDownloadInfos(QString bookId, QStringList keys)
|
||||
DownloadInfo ContentManager::updateDownloadInfos(QString bookId, QStringList keys)
|
||||
{
|
||||
if ( !keys.contains("status") ) keys.append("status");
|
||||
if ( !keys.contains("path") ) keys.append("path");
|
||||
|
@ -20,8 +20,6 @@ public: // types
|
||||
typedef ContentManagerModel::BookInfo BookInfo;
|
||||
typedef ContentManagerModel::BookInfoList BookInfoList;
|
||||
|
||||
typedef QMap<QString, QVariant> DownloadInfo;
|
||||
|
||||
public: // functions
|
||||
explicit ContentManager(Library* library, kiwix::Downloader *downloader, QObject *parent = nullptr);
|
||||
virtual ~ContentManager() {}
|
||||
|
@ -252,9 +252,10 @@ void ContentManagerModel::updateDownload(QString bookId)
|
||||
if ( ! download )
|
||||
return;
|
||||
|
||||
const bool downloadStillValid = download->update(bookId);
|
||||
const auto downloadInfos = KiwixApp::instance()->getContentManager()->updateDownloadInfos(bookId, {"status", "completedLength", "totalLength", "downloadSpeed"});
|
||||
const bool downloadStillValid = download->update(downloadInfos);
|
||||
|
||||
// The download->update() call above may result in
|
||||
// The ContentManager::updateDownloadInfos() call above may result in
|
||||
// ContentManagerModel::setBooksData() being called (through a chain
|
||||
// of signals), which in turn will rebuild bookIdToRowMap. Hence
|
||||
// bookIdToRowMap access must happen after it.
|
||||
|
@ -26,9 +26,8 @@ QString convertToUnits(QString size)
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
bool DownloadState::update(QString id)
|
||||
bool DownloadState::update(const DownloadInfo& downloadInfos)
|
||||
{
|
||||
auto downloadInfos = KiwixApp::instance()->getContentManager()->updateDownloadInfos(id, {"status", "completedLength", "totalLength", "downloadSpeed"});
|
||||
if (!downloadInfos["status"].isValid()) {
|
||||
*this = {0, "", "", false};
|
||||
return false;
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <QIcon>
|
||||
#include "kiwix/book.h"
|
||||
|
||||
typedef QMap<QString, QVariant> DownloadInfo;
|
||||
|
||||
class DownloadState
|
||||
{
|
||||
public:
|
||||
@ -17,7 +19,7 @@ public:
|
||||
public:
|
||||
void pause();
|
||||
void resume();
|
||||
bool update(QString id);
|
||||
bool update(const DownloadInfo& info);
|
||||
};
|
||||
|
||||
class RowNode : public Node
|
||||
|
Loading…
x
Reference in New Issue
Block a user