From 61f4d694c0eec98ce5036f2a7536c570a7f75950 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 24 May 2012 01:08:51 +0200 Subject: Add informations to download items --- src/newtabpage.cpp | 63 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 20 deletions(-) (limited to 'src/newtabpage.cpp') diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 8d5e5780..f74e5cf1 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -600,7 +600,7 @@ void NewTabPage::downloadsPage(const QString & filter) Q_FOREACH(DownloadItem * item, list) { - KUrl u = KUrl(item->destinationUrl()); + KUrl u = item->destUrl(); QString fName = u.fileName(); QString srcUrl = item->originUrl(); @@ -634,31 +634,54 @@ void NewTabPage::downloadsPage(const QString & filter) div.appendInside(QL1S("")); div.appendInside(QL1S("
")); - if (QFile::exists(file)) + switch (item->state()) { - div.appendInside(markup(QL1S("a"))); - div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); - div.lastChild().setAttribute(QL1S("href"), QL1S("about:downloads/opendir?q=") + QL1S("file://") + dir); - div.lastChild().setPlainText(i18n("Open directory")); + case DownloadItem::KGetManaged: + div.appendInside(QL1S("") + i18n("This download is managed by KGet. Check it to grab information about its state") + QL1S("")); + break; + + case DownloadItem::Suspended: + div.appendInside(QL1S("") + i18n("Suspended") + QL1S("")); + break; + + case DownloadItem::Downloading: + div.appendInside(QL1S("") + i18n("Downloading now...") + QL1S("")); + break; + + case DownloadItem::Errors: + div.appendInside(QL1S("") + i18nc("%1 = Error description", "Error: %1", item->errorString()) + QL1S("")); + break; + + case DownloadItem::Done: + default: + if (QFile::exists(file)) + { + div.appendInside(markup(QL1S("a"))); + div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); + div.lastChild().setAttribute(QL1S("href"), QL1S("about:downloads/opendir?q=") + QL1S("file://") + dir); + div.lastChild().setPlainText(i18n("Open directory")); + + div.appendInside(QL1S(" - ")); + + div.appendInside(markup(QL1S("a"))); + div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); + div.lastChild().setAttribute(QL1S("href"), QL1S("file://") + file); + div.lastChild().setPlainText(i18n("Open file")); + } + else + { + div.appendInside(QL1S("") + QL1S("Removed") + QL1S("")); + } div.appendInside(QL1S(" - ")); - + div.appendInside(markup(QL1S("a"))); div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); - div.lastChild().setAttribute(QL1S("href"), QL1S("file://") + file); - div.lastChild().setPlainText(i18n("Open file")); + div.lastChild().setAttribute(QL1S("href"), QL1S("about:downloads/removeItem?item=") + QString::number(i)); + div.lastChild().setPlainText(i18n("Remove from list")); + + break; } - else - { - div.appendInside(QL1S("") + QL1S("Removed") + QL1S("")); - } - - div.appendInside(QL1S(" - ")); - - div.appendInside(markup(QL1S("a"))); - div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); - div.lastChild().setAttribute(QL1S("href"), QL1S("about:downloads/removeItem?item=") + QString::number(i)); - div.lastChild().setPlainText(i18n("Remove from list")); i++; } -- cgit v1.2.1