| 3360 | } |
| 3361 | |
| 3362 | void UpdateTransferProgress(qint64 xfer, qint64 total, QElapsedTimer *timer, |
| 3363 | QProgressBar *progressBar, QLabel *progressLabel, QString progressText) |
| 3364 | { |
| 3365 | if(xfer >= total) |
| 3366 | { |
| 3367 | progressBar->setMaximum(10000); |
| 3368 | progressBar->setValue(10000); |
| 3369 | return; |
| 3370 | } |
| 3371 | |
| 3372 | if(total <= 0) |
| 3373 | { |
| 3374 | progressBar->setMaximum(10000); |
| 3375 | progressBar->setValue(0); |
| 3376 | return; |
| 3377 | } |
| 3378 | |
| 3379 | progressBar->setMaximum(10000); |
| 3380 | progressBar->setValue(int(10000.0 * (double(xfer) / double(total)))); |
| 3381 | |
| 3382 | double xferMB = double(xfer) / 1000000.0; |
| 3383 | double totalMB = double(total) / 1000000.0; |
| 3384 | |
| 3385 | double secondsElapsed = double(timer->nsecsElapsed()) * 1.0e-9; |
| 3386 | |
| 3387 | double speedMBS = xferMB / secondsElapsed; |
| 3388 | |
| 3389 | qulonglong secondsRemaining = qulonglong(double(totalMB - xferMB) / speedMBS); |
| 3390 | |
| 3391 | if(secondsElapsed > 1.0) |
| 3392 | { |
| 3393 | QString remainString; |
| 3394 | |
| 3395 | qulonglong minutesRemaining = (secondsRemaining / 60) % 60; |
| 3396 | qulonglong hoursRemaining = (secondsRemaining / 3600); |
| 3397 | secondsRemaining %= 60; |
| 3398 | |
| 3399 | if(hoursRemaining > 0) |
| 3400 | remainString = QFormatStr("%1:%2:%3") |
| 3401 | .arg(hoursRemaining, 2, 10, QLatin1Char('0')) |
| 3402 | .arg(minutesRemaining, 2, 10, QLatin1Char('0')) |
| 3403 | .arg(secondsRemaining, 2, 10, QLatin1Char('0')); |
| 3404 | else if(minutesRemaining > 0) |
| 3405 | remainString = QFormatStr("%1:%2") |
| 3406 | .arg(minutesRemaining, 2, 10, QLatin1Char('0')) |
| 3407 | .arg(secondsRemaining, 2, 10, QLatin1Char('0')); |
| 3408 | else |
| 3409 | remainString = QApplication::translate("qrenderdoc", "%1 seconds").arg(secondsRemaining); |
| 3410 | |
| 3411 | double speed = speedMBS; |
| 3412 | |
| 3413 | bool MBs = true; |
| 3414 | if(speedMBS < 1) |
| 3415 | { |
| 3416 | MBs = false; |
| 3417 | speed *= 1000; |
| 3418 | } |
| 3419 |
no test coverage detected