summaryrefslogtreecommitdiff
path: root/src
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
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')
-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
-rw-r--r--src/mainview.cpp1
-rw-r--r--src/protocolhandler.cpp2
-rw-r--r--src/webtab.cpp24
-rw-r--r--src/webtab.h3
8 files changed, 36 insertions, 65 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;
diff --git a/src/mainview.cpp b/src/mainview.cpp
index b164c72b..ec838ff4 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -615,7 +615,6 @@ void MainView::webViewTitleChanged(const QString &title)
tabBar()->setTabHighlighted(index);
}
- rApp->historyManager()->updateHistoryEntry(tab->url(), tabTitle);
if (ReKonfig::hoveringTabOption() == 1)
tabBar()->setTabToolTip(index, tabTitle.remove('&'));
}
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 4744e766..fb7ee936 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -250,7 +250,7 @@ void ProtocolHandler::showResults(const KFileItemList &list)
rApp->mainWindow()->mainView()->currentUrlBar()->setQUrl(_url);
rApp->mainWindow()->currentTab()->setFocus();
- rApp->historyManager()->addHistoryEntry(_url.prettyUrl());
+ rApp->historyManager()->addHistoryEntry(_url, _url.prettyUrl());
}
}
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 8db44dd8..cbb38a5e 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -33,17 +33,18 @@
#include "rekonq.h"
// Local Includes
-#include "urlbar.h"
+#include "application.h"
+#include "historymanager.h"
+#include "messagebar.h"
+#include "opensearchmanager.h"
#include "previewselectorbar.h"
#include "rsswidget.h"
+#include "sessionmanager.h"
+#include "syncmanager.h"
+#include "urlbar.h"
#include "walletbar.h"
#include "webpage.h"
#include "webshortcutwidget.h"
-#include "application.h"
-#include "sessionmanager.h"
-#include "syncmanager.h"
-#include "opensearchmanager.h"
-#include "messagebar.h"
// KDE Includes
#include <KWebWallet>
@@ -55,7 +56,7 @@
#include <KBuildSycocaProgressDialog>
// Qt Includes
-#include <QtGui/QVBoxLayout>
+#include <QVBoxLayout>
WebTab::WebTab(QWidget *parent)
@@ -88,6 +89,7 @@ WebTab::WebTab(QWidget *parent)
connect(view(), SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
connect(view(), SIGNAL(loadStarted()), this, SLOT(resetProgress()));
connect(view(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ connect(view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
// Session Manager
connect(view(), SIGNAL(loadFinished(bool)), rApp->sessionManager(), SLOT(saveSession()));
@@ -353,3 +355,11 @@ bool WebTab::hasAdBlockedElements()
{
return page()->hasAdBlockedElements();
}
+
+
+void WebTab::loadFinished()
+{
+ // add page to history
+ QString pageTitle = (page() && page()->isOnRekonqPage()) ? url().url() : m_webView->title();
+ rApp->historyManager()->addHistoryEntry(url(), pageTitle);
+}
diff --git a/src/webtab.h b/src/webtab.h
index b0c849ef..257f7380 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -72,6 +72,7 @@ public:
}
KUrl url();
+
void createPreviewSelectorBar(int index);
void hideSelectorBar();
@@ -79,6 +80,7 @@ public:
bool hasRSSInfo();
bool isPageLoading();
+
bool hasNewSearchEngine();
KParts::ReadOnlyPart *part()
@@ -101,6 +103,7 @@ private Q_SLOTS:
void openSearchEngineAdded();
void showMessageBar();
+ void loadFinished();
private:
KUrl extractOpensearchUrl(QWebElement e);