Ref T489, support download progress in our readers

* signal for download progress per entity (DB reader)
* ProgressSlot
* changed signatures for ProgressSlot
This commit is contained in:
Klaus Basan
2018-12-27 10:29:29 +01:00
committed by Mat Sutcliffe
parent 5c785643c7
commit 8c3faa4ca9
10 changed files with 171 additions and 33 deletions

View File

@@ -171,7 +171,7 @@ namespace BlackCore
return true;
}
QNetworkReply *CThreadedReader::getFromNetworkAndLog(const CUrl &url, const BlackMisc::CSlot<void (QNetworkReply *)> &callback)
QNetworkReply *CThreadedReader::getFromNetworkAndLog(const CUrl &url, const CSlot<void (QNetworkReply *)> &callback)
{
QWriteLocker wl(&m_lock);
const CUrlLogList outdatedPendingUrls = m_urlReadLog.findOutdatedPending(OutdatedPendingCallMs);
@@ -185,7 +185,24 @@ namespace BlackCore
wl.unlock();
// returned QNetworkReply normally nullptr since QAM is in different thread
return sApp->getFromNetwork(url, id, callback);
QNetworkReply *nr = sApp->getFromNetwork(url, id, callback, { this, &CThreadedReader::networkReplyProgress });
return nr;
}
QPair<qint64, qint64> CThreadedReader::getNetworkReplyBytes() const
{
return QPair<qint64, qint64>(m_networkReplyCurrent, m_networkReplyNax);
}
void CThreadedReader::networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url)
{
// max can be -1 if file size is not available
m_networkReplyProgress = (current > 0 && max > 0) ? static_cast<int>((current * 100) / max) : -1;
m_networkReplyCurrent = current;
m_networkReplyNax = max;
Q_UNUSED(url);
Q_UNUSED(logId);
}
void CThreadedReader::logNetworkReplyReceived(QNetworkReply *reply)