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

@@ -201,6 +201,7 @@ namespace BlackCore
QTimer::singleShot(0, this, [ = ]
{
if (!myself) { return; }
if (!sApp || sApp->isShuttingDown()) { return; }
emit this->dataRead(validInCacheEntities, CEntityFlags::ReadFinished, 0);
});
}
@@ -220,7 +221,8 @@ namespace BlackCore
if (entities == CEntityFlags::NoEntity) { return; }
if (!this->isInternetAccessible(QStringLiteral("No network/internet access, will not read %1").arg(CEntityFlags::flagToString(entities)))) { return; }
//! \todo MS 2018-12 Error: CDatabaseReader has no ps_read method
//! \todo MS 2018-12 Error: CDatabaseReader has no ps_read method -> T490
//! \todo KB 2018-12 https://dev.swift-project.org/T490
const bool s = QMetaObject::invokeMethod(this, "ps_read",
Q_ARG(BlackMisc::Network::CEntityFlags::Entity, entities),
Q_ARG(BlackMisc::Db::CDbFlags::DataRetrievalModeFlag, mode),
@@ -674,6 +676,17 @@ namespace BlackCore
<< CThreadUtils::currentThreadInfo() << response.toQString();
}
void CDatabaseReader::networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url)
{
CThreadedReader::networkReplyProgress(logId, current, max, url);
const QString fileName = url.fileName();
const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(fileName);
if (CEntityFlags::isSingleEntity(entity))
{
emit this->entityDownloadProgress(entity, logId, m_networkReplyProgress, m_networkReplyCurrent, m_networkReplyNax, url);
}
}
QString CDatabaseReader::fileNameForMode(CEntityFlags::Entity entity, CDbFlags::DataRetrievalModeFlag mode)
{
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "needs single entity");