summaryrefslogtreecommitdiff
path: root/src/webpage.cpp
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2009-12-22 17:19:34 +0100
committermegabigbug <megabigbug@arrakis.(none)>2009-12-22 17:19:34 +0100
commite440ff5b1f1d742b59a20b65d11092403ae9b6b1 (patch)
treed767cf30502cb543ed434621c36f088708135668 /src/webpage.cpp
parentrekonq 0.3.25 (diff)
downloadrekonq-e440ff5b1f1d742b59a20b65d11092403ae9b6b1.tar.xz
add options for kget in the config panel
replace kio for download
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r--src/webpage.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index cdb72caa..14a96543 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -53,6 +53,8 @@
#include <kparts/browseropenorsavequestion.h>
+#include <kio/renamedialog.h>
+
#include <KDE/KMimeTypeTrader>
#include <KDE/KRun>
#include <KDE/KFileDialog>
@@ -250,3 +252,76 @@ QString WebPage::errorPage(QNetworkReply *reply)
;
return html;
}
+
+
+void WebPage::downloadRequest(const QNetworkRequest &request)
+{
+ if (ReKonfig::kgetDownload())
+ {
+ //*Copy of kwebpage code (Shouldn't be done in kwepage ?)
+
+ KUrl destUrl;
+ KUrl srcUrl (request.url());
+ int result = KIO::R_OVERWRITE;
+
+ do
+ {
+ destUrl = KFileDialog::getSaveFileName(srcUrl.fileName(), QString(), view());
+
+ if (destUrl.isLocalFile())
+ {
+ QFileInfo finfo (destUrl.toLocalFile());
+ if (finfo.exists())
+ {
+ QDateTime now = QDateTime::currentDateTime();
+ KIO::RenameDialog dlg (view(), i18n("Overwrite File?"), srcUrl, destUrl,
+ KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP),
+ -1, finfo.size(),
+ now.toTime_t(), finfo.created().toTime_t(),
+ now.toTime_t(), finfo.lastModified().toTime_t());
+ result = dlg.exec();
+ }
+ }
+ }
+ while (result == KIO::R_CANCEL && destUrl.isValid());
+
+ if (result == KIO::R_OVERWRITE && destUrl.isValid())
+ {
+ //*End of copy code
+
+ //KGet integration:
+ if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
+ {
+ KToolInvocation::kdeinitExecWait("kget");
+ }
+ QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
+ kget.call("addTransfer", srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
+ }
+ }
+ else KWebPage::downloadRequest(request);
+}
+
+
+void WebPage::downloadAllContentsWithKGet()
+{
+ QList<QString> contentList;
+
+ QWebElementCollection images = mainFrame()->documentElement().findAll("img");
+ foreach(QWebElement img, images)
+ {
+ contentList.append(img.attribute("src"));
+ }
+
+ QWebElementCollection links = mainFrame()->documentElement().findAll("a");
+ foreach(QWebElement link, links)
+ {
+ contentList.append(link.attribute("href"));
+ }
+
+ if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
+ {
+ KToolInvocation::kdeinitExecWait("kget");
+ }
+ QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
+ kget.call("importLinks", QVariant(contentList));
+}