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;
|
DownloadInfo values;
|
||||||
if (!mp_downloader) {
|
if (!mp_downloader) {
|
||||||
@ -464,7 +464,7 @@ ContentManager::DownloadInfo ContentManager::getDownloadInfo(QString bookId, con
|
|||||||
return values;
|
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("status") ) keys.append("status");
|
||||||
if ( !keys.contains("path") ) keys.append("path");
|
if ( !keys.contains("path") ) keys.append("path");
|
||||||
|
@ -20,8 +20,6 @@ public: // types
|
|||||||
typedef ContentManagerModel::BookInfo BookInfo;
|
typedef ContentManagerModel::BookInfo BookInfo;
|
||||||
typedef ContentManagerModel::BookInfoList BookInfoList;
|
typedef ContentManagerModel::BookInfoList BookInfoList;
|
||||||
|
|
||||||
typedef QMap<QString, QVariant> DownloadInfo;
|
|
||||||
|
|
||||||
public: // functions
|
public: // functions
|
||||||
explicit ContentManager(Library* library, kiwix::Downloader *downloader, QObject *parent = nullptr);
|
explicit ContentManager(Library* library, kiwix::Downloader *downloader, QObject *parent = nullptr);
|
||||||
virtual ~ContentManager() {}
|
virtual ~ContentManager() {}
|
||||||
|
@ -252,9 +252,10 @@ void ContentManagerModel::updateDownload(QString bookId)
|
|||||||
if ( ! download )
|
if ( ! download )
|
||||||
return;
|
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
|
// ContentManagerModel::setBooksData() being called (through a chain
|
||||||
// of signals), which in turn will rebuild bookIdToRowMap. Hence
|
// of signals), which in turn will rebuild bookIdToRowMap. Hence
|
||||||
// bookIdToRowMap access must happen after it.
|
// bookIdToRowMap access must happen after it.
|
||||||
|
@ -26,9 +26,8 @@ QString convertToUnits(QString size)
|
|||||||
|
|
||||||
} // unnamed namespace
|
} // 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()) {
|
if (!downloadInfos["status"].isValid()) {
|
||||||
*this = {0, "", "", false};
|
*this = {0, "", "", false};
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include "kiwix/book.h"
|
#include "kiwix/book.h"
|
||||||
|
|
||||||
|
typedef QMap<QString, QVariant> DownloadInfo;
|
||||||
|
|
||||||
class DownloadState
|
class DownloadState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -17,7 +19,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
void pause();
|
void pause();
|
||||||
void resume();
|
void resume();
|
||||||
bool update(QString id);
|
bool update(const DownloadInfo& info);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RowNode : public Node
|
class RowNode : public Node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user