示例#1
0
void DownloadItem::updateDownloadInfo(double currSpeed, qint64 received, qint64 total)
{
#ifdef DOWNMANAGER_DEBUG
    qDebug() << __FUNCTION__ << currSpeed << received << total;
#endif
    //            QString          QString       QString     QString
    //          | m_remTime |   |m_currSize|  |m_fileSize|  |m_speed|
    // Remaining 26 minutes -     339MB of      693 MB        (350kB/s)

    int estimatedTime = ((total - received) / 1024) / (currSpeed / 1024);
    QString speed = currentSpeedToString(currSpeed);
    // We have QString speed now

    QTime time;
    time = time.addSecs(estimatedTime);
    QString remTime = remaingTimeToString(time);
    m_remTime = time;

    QString currSize = QzTools::fileSizeToString(received);
    QString fileSize = QzTools::fileSizeToString(total);

    if (fileSize == tr("Unknown size")) {
        ui->downloadInfo->setText(tr("%2 - unknown size (%3)").arg(currSize, speed));
    }
    else {
        ui->downloadInfo->setText(tr("Remaining %1 - %2 of %3 (%4)").arg(remTime, currSize, fileSize, speed));
    }
}
示例#2
0
void DownloadItem::updateInfo()
{
    int estimatedTime = ((total_ - received_) / 1024) / (curSpeed_ / 1024);
    QString speed = currentSpeedToString(curSpeed_);

    QTime time;
    time = time.addSecs(estimatedTime);
    QString remTime = remaingTimeToString(time);
    remTime_ = time;

    QString curSize = fileSizeToString(received_);
    QString fileSize = fileSizeToString(total_);

    if (fileSize == tr("Unknown size")) {
        downloadInfo_->setText(tr("%2 - unknown size (%3)").arg(curSize, speed));
    } else {
        downloadInfo_->setText(tr("Remaining %1 - %2 of %3 (%4)").arg(remTime, curSize, fileSize, speed));
    }
}