From 47bd57b5027f0fe34a6619d3d1902a9e67a16673 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 26 May 2011 00:12:01 +0200 Subject: Adding DownloadManager class, following Pierre and Benjamin code changes. First step in the introduction of the new rekonq pages --- src/application.cpp | 67 +++++++++-------------------------------------------- 1 file changed, 11 insertions(+), 56 deletions(-) (limited to 'src/application.cpp') diff --git a/src/application.cpp b/src/application.cpp index 830442f0..311c90a2 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" @@ -355,6 +356,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 +633,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 -- cgit v1.2.1