mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Fixed showing bad total + downloaded size when starting download.
This commit is contained in:
parent
e55cbcbfc0
commit
47a80e2b2a
@ -72,9 +72,9 @@ void DownloadFileHelper::handleUnsupportedContent(QNetworkReply* reply, bool ask
|
|||||||
m_fileIcon = m_iconProvider->icon(tempInfo).pixmap(30, 30);
|
m_fileIcon = m_iconProvider->icon(tempInfo).pixmap(30, 30);
|
||||||
QString mimeType = m_iconProvider->type(tempInfo);
|
QString mimeType = m_iconProvider->type(tempInfo);
|
||||||
|
|
||||||
qint64 size = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong();
|
m_fileSize = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong();
|
||||||
if (size > 0) {
|
if (m_fileSize > 0) {
|
||||||
mimeType.append(QString(" (%1)").arg(DownloadItem::fileSizeToString(size)));
|
mimeType.append(QString(" (%1)").arg(DownloadItem::fileSizeToString(m_fileSize)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close Empty Tab
|
// Close Empty Tab
|
||||||
@ -226,6 +226,7 @@ void DownloadFileHelper::fileNameChoosed(const QString &name, bool fileNameAutoG
|
|||||||
|
|
||||||
QListWidgetItem* item = new QListWidgetItem(m_listWidget);
|
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);
|
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);
|
emit itemCreated(item, downItem);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ private:
|
|||||||
QNetworkReply* m_reply;
|
QNetworkReply* m_reply;
|
||||||
QPixmap m_fileIcon;
|
QPixmap m_fileIcon;
|
||||||
QUrl m_downloadPage;
|
QUrl m_downloadPage;
|
||||||
|
qint64 m_fileSize;
|
||||||
bool m_openFileChoosed;
|
bool m_openFileChoosed;
|
||||||
|
|
||||||
QListWidget* m_listWidget;
|
QListWidget* m_listWidget;
|
||||||
|
@ -49,6 +49,8 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QS
|
|||||||
, m_downloading(false)
|
, m_downloading(false)
|
||||||
, m_openAfterFinish(openAfterFinishedDownload)
|
, m_openAfterFinish(openAfterFinishedDownload)
|
||||||
, m_downloadStopped(false)
|
, m_downloadStopped(false)
|
||||||
|
, m_received(0)
|
||||||
|
, m_total(0)
|
||||||
{
|
{
|
||||||
#ifdef DOWNMANAGER_DEBUG
|
#ifdef DOWNMANAGER_DEBUG
|
||||||
qDebug() << __FUNCTION__ << item << reply << path << fileName;
|
qDebug() << __FUNCTION__ << item << reply << path << fileName;
|
||||||
@ -76,6 +78,13 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QS
|
|||||||
startDownloading();
|
startDownloading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadItem::setTotalSize(qint64 total)
|
||||||
|
{
|
||||||
|
if (total > 0) {
|
||||||
|
m_total = total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadItem::startDownloading()
|
void DownloadItem::startDownloading()
|
||||||
{
|
{
|
||||||
QUrl locationHeader = m_reply->header(QNetworkRequest::LocationHeader).toUrl();
|
QUrl locationHeader = m_reply->header(QNetworkRequest::LocationHeader).toUrl();
|
||||||
|
@ -49,6 +49,8 @@ public:
|
|||||||
int progress();
|
int progress();
|
||||||
~DownloadItem();
|
~DownloadItem();
|
||||||
|
|
||||||
|
void setTotalSize(qint64 total);
|
||||||
|
|
||||||
static QString remaingTimeToString(QTime time);
|
static QString remaingTimeToString(QTime time);
|
||||||
static QString currentSpeedToString(double speed);
|
static QString currentSpeedToString(double speed);
|
||||||
static QString fileSizeToString(qint64 size);
|
static QString fileSizeToString(qint64 size);
|
||||||
|
Loading…
Reference in New Issue
Block a user