diff options
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r-- | src/downloadmanager.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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: |