summaryrefslogtreecommitdiff
path: root/src/webpage.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-05-19 16:06:43 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-05-19 16:06:43 +0200
commit8ea63d83c5251bcff66de198afabc227162c637f (patch)
treef88a9e2ed5713b3f111023f187be157013fa94c1 /src/webpage.cpp
parentBIG COMMIT (diff)
downloadrekonq-8ea63d83c5251bcff66de198afabc227162c637f.tar.xz
Fix download handling
This commit, together with adawit's patch to QtWebKit (not yet merged) && KIO will definitely solve download handling. At least, I hope so :)
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r--src/webpage.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index b0397870..9da75a91 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -296,7 +296,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
isLocal
? KMessageBox::sorry(view(), i18n("No service can handle this :("))
- : downloadRequest(reply->request());
+ : downloadThings(reply->request(), suggestedFileName);
return;
}
@@ -312,7 +312,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
case KParts::BrowserOpenOrSaveQuestion::Save:
kDebug() << "service handling: download!";
- downloadRequest(reply->request());
+ downloadThings(reply->request(), suggestedFileName);
return;
case KParts::BrowserOpenOrSaveQuestion::Cancel:
@@ -491,15 +491,28 @@ QString WebPage::errorPage(QNetworkReply *reply)
// this code is actually copied from KWebPage::downloadRequest to save
// downloads data before. If you have some better ideas about,
// feel free to let us know about :)
-void WebPage::downloadRequest(const QNetworkRequest &request)
+void WebPage::downloadThings(const QNetworkRequest &request, const QString &suggestedFileName)
{
KUrl destUrl;
KUrl srcUrl(request.url());
+
+ if( !ReKonfig::kgetDownload() && suggestedFileName.isEmpty() )
+ {
+ kDebug() << "Using KWebPage downloadRequest..";
+ Application::historyManager()->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl());
+ KWebPage::downloadRequest(request);
+ return;
+ }
+
int result = KIO::R_OVERWRITE;
do
{
- destUrl = KFileDialog::getSaveFileName(srcUrl.fileName(), QString(), view());
+ QString fName = suggestedFileName.isEmpty()
+ ? srcUrl.fileName()
+ : suggestedFileName;
+
+ destUrl = KFileDialog::getSaveFileName(fName, QString(), view());
if (destUrl.isLocalFile())
{