summaryrefslogtreecommitdiff
path: root/src/webpage.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-05-26 00:12:01 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-05-26 00:12:01 +0200
commit47bd57b5027f0fe34a6619d3d1902a9e67a16673 (patch)
treee02b667975eef3d35efa3ab325a67279065ff32e /src/webpage.cpp
parentFixes the size of a tab preview to a constant size, decorate it a bit (diff)
downloadrekonq-47bd57b5027f0fe34a6619d3d1902a9e67a16673.tar.xz
Adding DownloadManager class, following Pierre and Benjamin code changes.
First step in the introduction of the new rekonq pages
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r--src/webpage.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 3e2798d3..29ee4a40 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -40,6 +40,7 @@
// Local Includes
#include "adblockmanager.h"
#include "application.h"
+#include "downloadmanager.h"
#include "iconmanager.h"
#include "mainview.h"
#include "mainwindow.h"
@@ -209,7 +210,7 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
while (result == KIO::R_CANCEL && destUrl.isValid());
// Save download history
- rApp->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl());
+ DownloadItem *item = rApp->downloadManager()->addDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl());
if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetDownload())
{
@@ -219,16 +220,25 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
KToolInvocation::kdeinitExecWait("kget");
}
QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
- if (kget.isValid())
- {
- kget.call("addTransfer", srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
+ if (!kget.isValid())
+ return false;
+
+ QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
+ if (transfer.arguments().isEmpty())
return true;
- }
- return false;
+
+ const QString transferPath = transfer.arguments().first().toString();
+ item->setKGetTransferDbusPath(transferPath);
+ return true;
}
KIO::Job *job = KIO::file_copy(srcUrl, destUrl, -1, KIO::Overwrite);
-
+ if (item)
+ {
+ QObject::connect(job, SIGNAL(percent(KJob *,unsigned long)), item, SLOT(updateProgress(KJob *,unsigned long)));
+ QObject::connect(job, SIGNAL(finished(KJob *)), item, SLOT(onFinished(KJob*)));
+ }
+
if (!metaData.isEmpty())
job->setMetaData(metaData);
@@ -236,7 +246,6 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available.
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
return true;
-
}