summaryrefslogtreecommitdiff
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-05-13 12:05:06 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-05-15 09:53:43 +0200
commitf56f2761ed68aee64fc334230e4fc34f1a7e2213 (patch)
tree2d974dd2cf9252190e42724fab16faccd288ef67 /src/downloadmanager.cpp
parentClean up NewTabPage API a bit (diff)
downloadrekonq-f56f2761ed68aee64fc334230e4fc34f1a7e2213.tar.xz
Improve downloads page
- remove from list (+ API for DownloadManager to save changes) - open dir in extern app - css
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp36
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: