| 536 | } |
| 537 | |
| 538 | void Loader::start(const Urls &urls, const QUrl &previous, const QString &error) |
| 539 | { |
| 540 | if (!error.isEmpty()) |
| 541 | qCritical() << error; |
| 542 | |
| 543 | if (urls.isEmpty()) { |
| 544 | if (!previous.isEmpty()) |
| 545 | updater_.downloadFailed(previous, error); |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | auto leftUrls = urls; |
| 550 | const auto current = leftUrls.takeFirst(); |
| 551 | auto reply = network_->get(QNetworkRequest(current)); |
| 552 | downloads_.insert(reply, leftUrls); |
| 553 | |
| 554 | connect(reply, &QNetworkReply::downloadProgress, // |
| 555 | this, [this, current](qint64 bytesSent, qint64 bytesTotal) { |
| 556 | updater_.updateProgress(current, bytesSent, bytesTotal); |
| 557 | }); |
| 558 | |
| 559 | if (reply->error() == QNetworkReply::NoError) { |
| 560 | updater_.updateProgress(current, -1, -1); |
| 561 | return; |
| 562 | } |
| 563 | |
| 564 | handleReply(reply); |
| 565 | } |
| 566 | |
| 567 | void Loader::handleReply(QNetworkReply *reply) |
| 568 | { |
no test coverage detected