summaryrefslogtreecommitdiff
path: root/src/history
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-02-15 16:54:55 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-03-18 06:44:33 +0100
commit591b4c3cb201c3d405f4a0a168c65bfe83325c0c (patch)
tree42027d42ceda96ead0711388e23908e1dd7c8d36 /src/history
parentfixuifiles (diff)
downloadrekonq-591b4c3cb201c3d405f4a0a168c65bfe83325c0c.tar.xz
New History Manager, NO MORE QWebHistoryInterface based.
We are just saving datas on our own, I don't like QtWebKit APIs to do it. We now call addHistoryEntry(url, title) on loadFinished. Data structure will remain the same as usual, but I think API is better and data are now saved when we really have them ready. REVIEW:104257
Diffstat (limited to 'src/history')
-rw-r--r--src/history/historymanager.cpp55
-rw-r--r--src/history/historymanager.h7
-rw-r--r--src/history/historymodels.cpp8
-rw-r--r--src/history/historymodels.h1
4 files changed, 15 insertions, 56 deletions
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 602e4606..c78bb009 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -63,7 +63,7 @@ static const unsigned int HISTORY_VERSION = 25;
HistoryManager::HistoryManager(QObject *parent)
- : QWebHistoryInterface(parent)
+ : QObject(parent)
, m_saveTimer(new AutoSaver(this))
, m_historyLimit(0)
, m_historyTreeModel(0)
@@ -77,9 +77,6 @@ HistoryManager::HistoryManager(QObject *parent)
HistoryModel *historyModel = new HistoryModel(this, this);
m_historyFilterModel = new HistoryFilterModel(historyModel, this);
m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this);
-
- // QWebHistoryInterface will delete the history manager
- QWebHistoryInterface::setDefaultInterface(this);
}
@@ -95,30 +92,33 @@ bool HistoryManager::historyContains(const QString &url) const
}
-void HistoryManager::addHistoryEntry(const QString &url)
+void HistoryManager::addHistoryEntry(const KUrl &url, const QString &title)
{
QWebSettings *globalSettings = QWebSettings::globalSettings();
if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
return;
- QUrl cleanUrl(url);
+ if (url.isEmpty())
+ return;
+
+ QUrl urlToClean(url);
// don't store about: urls (home page related)
- if (cleanUrl.scheme() == QString("about"))
+ if (urlToClean.scheme() == QString("about"))
return;
- cleanUrl.setPassword(QString());
- cleanUrl.setHost(cleanUrl.host().toLower());
- QString checkUrlString = cleanUrl.toString();
+ urlToClean.setPassword(QString());
+ urlToClean.setHost(urlToClean.host().toLower());
+ QString urlString = urlToClean.toString();
HistoryItem item;
// NOTE
// check if the url has just been visited.
// if so, remove previous entry from history, update and prepend it
- if (historyContains(checkUrlString))
+ if (historyContains(urlString))
{
- int index = m_historyFilterModel->historyLocation(checkUrlString);
+ int index = m_historyFilterModel->historyLocation(urlString);
item = m_history.at(index);
m_history.removeOne(item);
emit entryRemoved(item);
@@ -128,7 +128,7 @@ void HistoryManager::addHistoryEntry(const QString &url)
}
else
{
- item = HistoryItem(checkUrlString, QDateTime::currentDateTime());
+ item = HistoryItem(urlString, QDateTime::currentDateTime(), title);
}
m_history.prepend(item);
@@ -196,35 +196,6 @@ void HistoryManager::checkForExpired()
}
-void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title)
-{
- QString urlString = url.url();
- urlString.remove(QL1S("www."));
- if (urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/')))
- urlString.remove(urlString.length() - 1, 1);
-
- for (int i = 0; i < m_history.count(); ++i)
- {
- QString itemUrl = m_history.at(i).url;
- itemUrl.remove(QL1S("www."));
- if (itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/')))
- itemUrl.remove(itemUrl.length() - 1, 1);
-
- if (urlString == itemUrl)
- {
- m_history[i].title = title;
- m_history[i].url = url.url();
- m_saveTimer->changeOccurred();
- if (m_lastSavedUrl.isEmpty())
- m_lastSavedUrl = m_history.at(i).url;
-
- emit entryUpdated(i);
- break;
- }
- }
-}
-
-
void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)
{
HistoryItem item;
diff --git a/src/history/historymanager.h b/src/history/historymanager.h
index d4531e5c..fc2e9abd 100644
--- a/src/history/historymanager.h
+++ b/src/history/historymanager.h
@@ -45,7 +45,6 @@
#include <QObject>
#include <QTimer>
#include <QSortFilterProxyModel>
-#include <QWebHistoryInterface>
#include <QWebHistory>
#include <math.h>
@@ -146,7 +145,7 @@ class HistoryTreeModel;
* It manages rekonq history
*
*/
-class REKONQ_TESTS_EXPORT HistoryManager : public QWebHistoryInterface
+class REKONQ_TESTS_EXPORT HistoryManager : public QObject
{
Q_OBJECT
@@ -155,8 +154,7 @@ public:
~HistoryManager();
bool historyContains(const QString &url) const;
- void addHistoryEntry(const QString &url);
- void updateHistoryEntry(const KUrl &url, const QString &title);
+ void addHistoryEntry(const KUrl &url, const QString &title);
void removeHistoryEntry(const KUrl &url, const QString &title = QString());
QList<HistoryItem> find(const QString &text);
@@ -181,7 +179,6 @@ Q_SIGNALS:
void historyReset();
void entryAdded(const HistoryItem &item);
void entryRemoved(const HistoryItem &item);
- void entryUpdated(int offset);
void historySaved();
diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp
index 16054054..d50d28a0 100644
--- a/src/history/historymodels.cpp
+++ b/src/history/historymodels.cpp
@@ -66,7 +66,6 @@ HistoryModel::HistoryModel(HistoryManager *history, QObject *parent)
connect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset()));
connect(m_historyManager, SIGNAL(entryRemoved(HistoryItem)), this, SLOT(historyReset()));
connect(m_historyManager, SIGNAL(entryAdded(HistoryItem)), this, SLOT(entryAdded()));
- connect(m_historyManager, SIGNAL(entryUpdated(int)), this, SLOT(entryUpdated(int)));
}
@@ -83,13 +82,6 @@ void HistoryModel::entryAdded()
}
-void HistoryModel::entryUpdated(int offset)
-{
- QModelIndex idx = index(offset, 0);
- emit dataChanged(idx, idx);
-}
-
-
QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal
diff --git a/src/history/historymodels.h b/src/history/historymodels.h
index 9c3bfc36..4f4f30b5 100644
--- a/src/history/historymodels.h
+++ b/src/history/historymodels.h
@@ -65,7 +65,6 @@ public:
public Q_SLOTS:
void historyReset();
void entryAdded();
- void entryUpdated(int offset);
public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;