summaryrefslogtreecommitdiff
path: root/src/history
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-03-20 22:54:21 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-03-20 22:54:21 +0100
commita6ef003dd4c1b6ad08eca4f5adaa4679bbc20bce (patch)
treef8a2aa5daa3e9e68984308a1cb891cc1bd4e3675 /src/history
parentNewTabPage: clean API (diff)
downloadrekonq-a6ef003dd4c1b6ad08eca4f5adaa4679bbc20bce.tar.xz
Downloads Page
This commit implements the downloads history page. While it is in an horrible shape, its slots seem working well It needs just some love..
Diffstat (limited to 'src/history')
-rw-r--r--src/history/historymanager.cpp53
-rw-r--r--src/history/historymanager.h32
2 files changed, 84 insertions, 1 deletions
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 362fe340..39c128f4 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -451,3 +451,56 @@ KCompletion * HistoryManager::completionObject() const
{
return m_completion;
}
+
+
+void HistoryManager::addDownload(const QString &srcUrl, const QString &destUrl)
+{
+ QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads");
+ QFile downloadFile(downloadFilePath);
+ if ( !downloadFile.open(QFile::WriteOnly | QFile::Append) )
+ {
+ kDebug() << "azz...";
+ return;
+ }
+ QDataStream out(&downloadFile);
+ out << srcUrl;
+ out << destUrl;
+ out << QDateTime::currentDateTime();
+ downloadFile.close();
+}
+
+
+DownloadList HistoryManager::downloads()
+{
+ DownloadList list;
+
+ QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads");
+ QFile downloadFile(downloadFilePath);
+ if ( !downloadFile.open(QFile::ReadOnly) )
+ {
+ kDebug() << "azz...";
+ 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 HistoryManager::clearDownloadsHistory()
+{
+ QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads");
+ QFile downloadFile(downloadFilePath);
+ return downloadFile.remove();
+}
diff --git a/src/history/historymanager.h b/src/history/historymanager.h
index e744ca4b..8fc5c30e 100644
--- a/src/history/historymanager.h
+++ b/src/history/historymanager.h
@@ -57,7 +57,10 @@ public:
const QDateTime &d = QDateTime(),
const QString &t = QString()
)
- : title(t), url(u), dateTime(d) {}
+ : title(t)
+ , url(u),
+ dateTime(d)
+ {}
inline bool operator==(const HistoryItem &other) const
{
@@ -77,6 +80,29 @@ public:
};
+// ---------------------------------------------------------------------------------------------------------------
+
+
+class DownloadItem
+{
+public:
+ DownloadItem() {}
+ explicit DownloadItem(const QString &srcUrl,
+ const QString &destUrl,
+ const QDateTime &d
+ )
+ : srcUrlString(srcUrl)
+ , destUrlString(destUrl)
+ , dateTime(d)
+ {}
+
+ QString srcUrlString;
+ QString destUrlString;
+ QDateTime dateTime;
+};
+
+
+typedef QList<DownloadItem> DownloadList;
// ---------------------------------------------------------------------------------------------------------------
@@ -131,6 +157,10 @@ public:
*/
KCompletion *completionObject() const;
+ void addDownload(const QString &srcUrl, const QString &destUrl);
+ DownloadList downloads();
+ bool clearDownloadsHistory();
+
public slots:
void clear();
void loadSettings();