summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-02-02 01:57:19 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-02-02 01:57:19 +0100
commit3afb0217d09a012c4a65740155b232c67fef4990 (patch)
tree9d6c66ede1b7dada90d5c3f68f6d71868534bf48
parentrekonq 0.0.3 (diff)
downloadrekonq-3afb0217d09a012c4a65740155b232c67fef4990.tar.xz
Fixed download system about downloading files with the same name.
-rw-r--r--src/download.cpp8
-rw-r--r--src/webview.cpp10
2 files changed, 7 insertions, 11 deletions
diff --git a/src/download.cpp b/src/download.cpp
index d1ed296a..e4ee556d 100644
--- a/src/download.cpp
+++ b/src/download.cpp
@@ -58,6 +58,13 @@ void Download::slotResult(KJob * job)
{
kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url();
QFile destFile(m_destUrl.path());
+ int n = 1;
+ while( destFile.exists() )
+ {
+ QString fn = QFile(m_destUrl.path()).fileName();
+ destFile.setFileName( fn + "." + QString::number(n) );
+ n++;
+ }
if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) )
{
destFile.write(m_data);
@@ -69,7 +76,6 @@ void Download::slotResult(KJob * job)
case KIO::ERR_FILE_ALREADY_EXIST:
{
kDebug(5001) << "ERROR - File already exists";
- // QFile file(m_destUrl.path());
m_data = 0;
break;
}
diff --git a/src/webview.cpp b/src/webview.cpp
index 95fcdf83..a4ca8211 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -126,11 +126,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
KUrl srcUrl = reply->url();
QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName();
- QFile file(path);
- if (file.exists())
- {
- path = KFileDialog::getOpenFileName();
- }
KUrl destUrl = KUrl(path);
BrowserApplication::instance()->downloadUrl( srcUrl, destUrl );
return;
@@ -317,11 +312,6 @@ void WebView::downloadRequested(const QNetworkRequest &request)
{
KUrl srcUrl = request.url();
QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName();
- QFile file(path);
- if (file.exists())
- {
- path = KFileDialog::getOpenFileName();
- }
KUrl destUrl = KUrl(path);
BrowserApplication::instance()->downloadUrl( srcUrl, destUrl );
}