diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-02-15 15:38:36 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-02-15 15:38:36 +0100 |
commit | 93562769c23827a1a6ddec63816ac7edbdeb98f6 (patch) | |
tree | 15d226ee3dae2da99eef768461e4e239d874be1b /src/download.cpp | |
parent | BrowserApplication --> Application (diff) | |
parent | Preliminary flash support (diff) | |
download | rekonq-93562769c23827a1a6ddec63816ac7edbdeb98f6.tar.xz |
Merge branch 'master' into mainwindow
Diffstat (limited to 'src/download.cpp')
-rw-r--r-- | src/download.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/download.cpp b/src/download.cpp index aedd0a63..627b11b2 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -33,7 +33,7 @@ Download::Download(const KUrl &srcUrl, const KUrl &destUrl) : m_srcUrl(srcUrl), m_destUrl(destUrl) { - kDebug(5001) << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); + kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); @@ -51,32 +51,36 @@ void Download::slotData(KIO::Job *job, const QByteArray& data) void Download::slotResult(KJob * job) { - kDebug(5001); switch (job->error()) { case 0://The download has finished { - kDebug(5001) << "Downloading successfully finished" << m_destUrl.url(); - QFile torrentFile(m_destUrl.path()); - if (!torrentFile.open(QIODevice::WriteOnly | QIODevice::Text)) {} - torrentFile.write(m_data); - torrentFile.close(); - emit finishedSuccessfully(m_destUrl, m_data); + kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); + QFile destFile(m_destUrl.path()); + int n = 1; + QString fn = destFile.fileName(); + while( destFile.exists() ) + { + destFile.setFileName( fn + "." + QString::number(n) ); + n++; + } + if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) + { + destFile.write(m_data); + destFile.close(); + } m_data = 0; break; } case KIO::ERR_FILE_ALREADY_EXIST: { - kDebug(5001) << "ERROR - File already exists"; - QFile file(m_destUrl.path()); - emit finishedSuccessfully(m_destUrl, file.readAll()); + kWarning() << "ERROR - File already exists"; m_data = 0; break; } default: - kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; + kWarning() << "We are sorry to say you, that there were errors while downloading :("; m_data = 0; - emit finishedWithError(); break; } } |