summaryrefslogtreecommitdiff
path: root/src/history
diff options
context:
space:
mode:
Diffstat (limited to 'src/history')
-rw-r--r--src/history/historymanager.cpp99
-rw-r--r--src/history/historymanager.h33
2 files changed, 15 insertions, 117 deletions
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 99862205..966487a9 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -115,6 +115,10 @@ bool HistoryManager::historyContains(const QString &url) const
void HistoryManager::addHistoryEntry(const QString &url)
{
+ QWebSettings *globalSettings = QWebSettings::globalSettings();
+ if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ return;
+
QUrl cleanUrl(url);
// don't store about: urls (home page related)
@@ -124,7 +128,13 @@ void HistoryManager::addHistoryEntry(const QString &url)
cleanUrl.setPassword(QString());
cleanUrl.setHost(cleanUrl.host().toLower());
HistoryItem item(cleanUrl.toString(), QDateTime::currentDateTime());
- addHistoryEntry(item);
+
+ m_history.prepend(item);
+ addHistoryHashEntry(item);
+ emit entryAdded(item);
+
+ if (m_history.count() == 1)
+ checkForExpired();
}
@@ -210,20 +220,6 @@ void HistoryManager::checkForExpired()
}
-void HistoryManager::addHistoryEntry(const HistoryItem &item)
-{
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- return;
-
- m_history.prepend(item);
- addHistoryHashEntry(item);
- emit entryAdded(item);
-
- if (m_history.count() == 1)
- checkForExpired();
-}
-
void HistoryManager::addHistoryHashEntry(const HistoryItem &item)
{
if (m_hash.contains(item.url))
@@ -265,18 +261,6 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title)
}
-void HistoryManager::removeHistoryEntry(const HistoryItem &item)
-{
- m_lastSavedUrl.clear();
- m_history.removeOne(item);
- if (m_hash.contains(item.url) && m_hash[item.url].savedCount>0)
- {
- m_hash[item.url].savedCount--; //this counter is used for expired urls
- }
- emit entryRemoved(item);
-}
-
-
void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)
{
HistoryItem item;
@@ -286,7 +270,9 @@ void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)
&& (title.isEmpty() || title == m_history.at(i).title))
{
item = m_history.at(i);
- removeHistoryEntry(item);
+ m_lastSavedUrl.clear();
+ m_history.removeOne(item);
+ emit entryRemoved(item);
break;
}
}
@@ -494,60 +480,3 @@ void HistoryManager::save()
}
m_lastSavedUrl = m_history.value(0).url;
}
-
-
-void HistoryManager::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 HistoryManager::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 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 c1627530..85702b84 100644
--- a/src/history/historymanager.h
+++ b/src/history/historymanager.h
@@ -106,29 +106,6 @@ public:
int savedCount;
};
-// ---------------------------------------------------------------------------------------------------------------
-
-
-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;
// ---------------------------------------------------------------------------------------------------------------
@@ -178,10 +155,6 @@ public:
HistoryFilterModel *historyFilterModel() const;
HistoryTreeModel *historyTreeModel() const;
- void addDownload(const QString &srcUrl, const QString &destUrl);
- DownloadList downloads();
- bool clearDownloadsHistory();
-
public slots:
void clear();
void loadSettings();
@@ -190,12 +163,8 @@ private slots:
void save();
void checkForExpired();
-protected:
- void addHistoryEntry(const HistoryItem &item);
- void removeHistoryEntry(const HistoryItem &item);
- void addHistoryHashEntry(const HistoryItem &item);
-
private:
+ void addHistoryHashEntry(const HistoryItem &item);
void load();
AutoSaver *m_saveTimer;