diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2011-06-03 18:20:35 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-06-03 18:20:35 +0200 |
commit | 34c581e7e382084e9273b6c3b8762b36d527d4aa (patch) | |
tree | af494bb421e86f7d0a1ec4c7c8248af340c2c58b /src/application.cpp | |
parent | Code janitoring (diff) | |
parent | Last (diff) | |
download | rekonq-34c581e7e382084e9273b6c3b8762b36d527d4aa.tar.xz |
Merge branch 'DownloadManager'
Diffstat (limited to 'src/application.cpp')
-rw-r--r-- | src/application.cpp | 75 |
1 files changed, 19 insertions, 56 deletions
diff --git a/src/application.cpp b/src/application.cpp index 830442f0..c00f3f96 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -36,6 +36,7 @@ // Local Includes #include "adblockmanager.h" #include "bookmarkprovider.h" +#include "downloadmanager.h" #include "filterurljob.h" #include "historymanager.h" #include "iconmanager.h" @@ -125,6 +126,14 @@ Application::~Application() m_adblockManager.clear(); } + // TODO: + // add a check to NOT close rekonq + // until last download is finished + + if (!m_downloadManager.isNull()) { + delete m_adblockManager.data(); + m_adblockManager.clear(); + } } @@ -355,6 +364,16 @@ IconManager *Application::iconManager() } +DownloadManager *Application::downloadManager() +{ + if (m_downloadManager.isNull()) + { + m_downloadManager = new DownloadManager(instance()); + } + return m_downloadManager.data(); +} + + void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) { if (url.isEmpty()) @@ -622,62 +641,6 @@ void Application::updateConfiguration() } -void Application::addDownload(const QString &srcUrl, const QString &destUrl) -{ - QWebSettings *globalSettings = QWebSettings::globalSettings(); - if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) - return; - QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); - QFile downloadFile(downloadFilePath); - if (!downloadFile.open(QFile::WriteOnly | QFile::Append)) - { - kDebug() << "Unable to open download file (WRITE mode).."; - return; - } - QDataStream out(&downloadFile); - out << srcUrl; - out << destUrl; - out << QDateTime::currentDateTime(); - downloadFile.close(); -} - - -DownloadList Application::downloads() -{ - DownloadList list; - - QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); - QFile downloadFile(downloadFilePath); - if (!downloadFile.open(QFile::ReadOnly)) - { - kDebug() << "Unable to open download file (READ mode).."; - return list; - } - - QDataStream in(&downloadFile); - while (!in.atEnd()) - { - QString srcUrl; - in >> srcUrl; - QString destUrl; - in >> destUrl; - QDateTime dt; - in >> dt; - DownloadItem item(srcUrl, destUrl, dt); - list << item; - } - return list; -} - - -bool Application::clearDownloadsHistory() -{ - QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); - QFile downloadFile(downloadFilePath); - return downloadFile.remove(); -} - - void Application::setPrivateBrowsingMode(bool b) { // NOTE |