Made DownloadState::status private

This commit is contained in:
Veloman Yunkan 2024-06-06 16:16:35 +04:00 committed by Kelson
parent cbdb4b0404
commit ce2fbbf7fc
4 changed files with 4 additions and 5 deletions

View File

@ -379,7 +379,7 @@ ContentManager::BookInfo ContentManager::getBookInfos(QString id, const QStringL
ContentManager::BookState ContentManager::getBookState(QString bookId)
{
if ( const auto downloadState = DownloadManager::getDownloadState(bookId) ) {
return downloadState->status == DownloadState::PAUSED
return downloadState->getStatus() == DownloadState::PAUSED
? BookState::DOWNLOAD_PAUSED
: BookState::DOWNLOADING;
// TODO: a download may be in error state

View File

@ -131,7 +131,7 @@ void showDownloadProgress(QPainter *painter, QRect box, const DownloadState& dow
auto completedLength = downloadInfo.completedLength;
auto downloadSpeed = downloadInfo.getDownloadSpeed();
if (downloadInfo.status == DownloadState::PAUSED) {
if (downloadInfo.getStatus() == DownloadState::PAUSED) {
createResumeSymbol(painter, dcl.pauseResumeButtonRect);
createCancelButton(painter, dcl.cancelButtonRect);
} else {

View File

@ -136,7 +136,6 @@ void DownloadManager::restoreDownloads()
const kiwix::Book& book = mp_library->getBookById(bookId);
if ( ! book.getDownloadId().empty() ) {
const auto newDownload = std::make_shared<DownloadState>();
newDownload->status = DownloadState::UNKNOWN;
m_downloads.set(bookId, newDownload);
}
}

View File

@ -62,21 +62,21 @@ public: // types
PAUSED
};
public: // data
double progress = 0;
QString completedLength;
Status status = UNKNOWN;
public: // functions
void update(const DownloadInfo& info);
QString getDownloadSpeed() const;
Status getStatus() const { return status; }
// time in seconds since last update
double timeSinceLastUpdate() const;
private: // data
Status status = UNKNOWN;
QString downloadSpeed;
std::chrono::steady_clock::time_point lastUpdated;
};