mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
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:
committed by
Mat Sutcliffe
parent
5c785643c7
commit
8c3faa4ca9
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user