From f56f2761ed68aee64fc334230e4fc34f1a7e2213 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 13 May 2012 12:05:06 +0200 Subject: Improve downloads page - remove from list (+ API for DownloadManager to save changes) - open dir in extern app - css --- src/downloadmanager.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 4dc7e670..5a2467d3 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -59,11 +59,38 @@ DownloadManager::DownloadManager(QObject *parent) : QObject(parent) + , m_needToSave(false) { init(); } +DownloadManager::~DownloadManager() +{ + if (!m_needToSave) + return; + + QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); + QFile downloadFile(downloadFilePath); + + if (!downloadFile.open(QFile::WriteOnly)) + { + kDebug() << "Unable to open download file (WRITE mode).."; + return; + } + + QDataStream out(&downloadFile); + Q_FOREACH(DownloadItem * item, m_downloadList) + { + out << item->originUrl(); + out << item->destinationUrl(); + out << item->dateTime(); + } + + downloadFile.close(); +} + + void DownloadManager::init() { QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); @@ -136,6 +163,15 @@ void DownloadManager::downloadLinksWithKGet(const QVariant &contentList) } +void DownloadManager::removeDownloadItem(int index) +{ + DownloadItem *item = m_downloadList.takeAt(index); + delete item; + + m_needToSave = true; +} + + // NOTE // These 2 functions have been copied from the KWebPage class to implement a local version of the downloadResponse method. // In this way, we can easily provide the extra functionality we need: -- cgit v1.2.1