1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

Fixed showing bad total + downloaded size when starting download.

This commit is contained in:
nowrep 2012-03-08 12:48:23 +01:00
parent e55cbcbfc0
commit 47a80e2b2a
4 changed files with 16 additions and 3 deletions

View File

@ -72,9 +72,9 @@ void DownloadFileHelper::handleUnsupportedContent(QNetworkReply* reply, bool ask
m_fileIcon = m_iconProvider->icon(tempInfo).pixmap(30, 30);
QString mimeType = m_iconProvider->type(tempInfo);
qint64 size = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong();
if (size > 0) {
mimeType.append(QString(" (%1)").arg(DownloadItem::fileSizeToString(size)));
m_fileSize = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong();
if (m_fileSize > 0) {
mimeType.append(QString(" (%1)").arg(DownloadItem::fileSizeToString(m_fileSize)));
}
// Close Empty Tab
@ -226,6 +226,7 @@ void DownloadFileHelper::fileNameChoosed(const QString &name, bool fileNameAutoG
QListWidgetItem* item = new QListWidgetItem(m_listWidget);
DownloadItem* downItem = new DownloadItem(item, m_reply, m_path, m_fileName, m_fileIcon, m_timer, m_openFileChoosed, m_downloadPage, m_manager);
downItem->setTotalSize(m_fileSize);
emit itemCreated(item, downItem);
}

View File

@ -68,6 +68,7 @@ private:
QNetworkReply* m_reply;
QPixmap m_fileIcon;
QUrl m_downloadPage;
qint64 m_fileSize;
bool m_openFileChoosed;
QListWidget* m_listWidget;

View File

@ -49,6 +49,8 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QS
, m_downloading(false)
, m_openAfterFinish(openAfterFinishedDownload)
, m_downloadStopped(false)
, m_received(0)
, m_total(0)
{
#ifdef DOWNMANAGER_DEBUG
qDebug() << __FUNCTION__ << item << reply << path << fileName;
@ -76,6 +78,13 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QS
startDownloading();
}
void DownloadItem::setTotalSize(qint64 total)
{
if (total > 0) {
m_total = total;
}
}
void DownloadItem::startDownloading()
{
QUrl locationHeader = m_reply->header(QNetworkRequest::LocationHeader).toUrl();

View File

@ -49,6 +49,8 @@ public:
int progress();
~DownloadItem();
void setTotalSize(qint64 total);
static QString remaingTimeToString(QTime time);
static QString currentSpeedToString(double speed);
static QString fileSizeToString(qint64 size);