summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-05-19 00:34:41 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-05-19 00:34:41 +0200
commit4338a19c4b1feb3136a4a61c22c495c036f5b5cf (patch)
treeb510b058b736f8291ef4cc5cdc511350b063a36e
parentMerge branch 'master' of gitorious.org:rekonq/mainline (diff)
downloadrekonq-4338a19c4b1feb3136a4a61c22c495c036f5b5cf.tar.xz
This patch is based on Cedric's idea about fixing history with error pages
and use it to fix back/forward buttons also on kparts and so on :)
-rw-r--r--src/mainwindow.cpp42
-rw-r--r--src/newtabpage.cpp3
-rw-r--r--src/protocolhandler.cpp3
-rw-r--r--src/webpage.cpp40
-rw-r--r--src/webpage.h10
5 files changed, 67 insertions, 31 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 1aa4374a..1488980f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1016,13 +1016,22 @@ void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifie
QWebHistory *history = currentTab()->view()->history();
if (history->canGoBack())
{
+ QWebHistoryItem *item;
+ if (currentTab()->view()->page()->isOnRekonqPage())
+ {
+ item = new QWebHistoryItem(history->currentItem());
+ currentTab()->view()->page()->setIsOnRekonqPage(false);
+ }
+ else
+ item = new QWebHistoryItem(history->backItem());
+
if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
{
- Application::instance()->loadUrl(history->backItem().url(), Rekonq::SettingOpenTab);
+ Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab);
}
else
{
- history->goToItem(history->backItem());
+ history->goToItem(*item);
}
updateActions();
@@ -1036,13 +1045,22 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k
QWebHistory *history = currentTab()->view()->history();
if (history->canGoForward())
{
+ QWebHistoryItem *item;
+ if (currentTab()->view()->page()->isOnRekonqPage())
+ {
+ item = new QWebHistoryItem(history->currentItem());
+ currentTab()->view()->page()->setIsOnRekonqPage(false);
+ }
+ else
+ item = new QWebHistoryItem(history->forwardItem());
+
if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
{
- Application::instance()->loadUrl(history->forwardItem().url(), Rekonq::SettingOpenTab);
+ Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab);
}
else
{
- history->goToItem(history->forwardItem());
+ history->goToItem(*item);
}
updateActions();
}
@@ -1253,6 +1271,22 @@ void MainWindow::aboutToShowBackMenu()
if (pivot >= 8)
offset = pivot - 8;
+ /*
+ * Need a bug report upstream.
+ * Seems setHtml() do some garbage in history
+ * Here history->currentItem() have backItem url and currentItem (error page) title
+ */
+ if (currentTab()->view()->page()->isOnRekonqPage())
+ {
+ QWebHistoryItem item = history->currentItem();
+ KAction *action = new KAction(this);
+ action->setData(listCount + offset++);
+ KIcon icon = Application::icon(item.url());
+ action->setIcon(icon);
+ action->setText(item.title());
+ m_historyBackMenu->addAction(action);
+ }
+
for (int i = listCount - 1; i >= 0; --i)
{
QWebHistoryItem item = historyList.at(i);
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index f177cbf3..b3b9cf65 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -124,8 +124,9 @@ void NewTabPage::generate(const KUrl &url)
return;
}
- QWebPage *page = m_root.webFrame()->page();
+ WebPage *page = qobject_cast <WebPage *>(m_root.webFrame()->page());
page->mainFrame()->setHtml(m_html);
+ page->setIsOnRekonqPage(true);
m_root = page->mainFrame()->documentElement().findFirst("#content");
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 4a25ccd7..040dc822 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -226,7 +226,8 @@ void ProtocolHandler::showResults(const KFileItemList &list)
else
{
QString html = dirHandling(list);
- _frame->setHtml(html, _url);
+ _frame->setHtml(html);
+ qobject_cast<WebPage *>(_frame->page())->setIsOnRekonqPage(true);
Application::instance()->mainWindow()->currentTab()->setFocus();
Application::historyManager()->addHistoryEntry(_url.prettyUrl());
diff --git a/src/webpage.cpp b/src/webpage.cpp
index d266b257..81486a32 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -102,6 +102,7 @@ static bool domainSchemeMatch(const QUrl& u1, const QUrl& u2)
WebPage::WebPage(QWidget *parent)
: KWebPage(parent, KWalletIntegration)
, _networkAnalyzer(false)
+ , _isOnRekonqPage(false)
{
// ----- handling unsupported content...
setForwardUnsupportedContent(true);
@@ -145,6 +146,9 @@ WebPage::~WebPage()
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
{
+ _isOnRekonqPage = false;
+ kDebug() << "ACCEPT_NAVIGATION false";
+
_loadingUrl = request.url();
KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
@@ -237,7 +241,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
// NOTE
// This is probably needed just in ONE stupid case..
if (_protHandler.postHandling(reply->request(), mainFrame()))
- return; // FIXME RE-ENABLE ME reply->deleteLater();
+ return;
if (reply->error() == QNetworkReply::NoError)
{
@@ -256,7 +260,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
? KMessageBox::sorry(view(), i18n("No service can handle this :("))
: downloadRequest(reply->request());
- return; // FIXME RE-ENABLE ME reply->deleteLater();
+ return;
}
if (!isLocal)
@@ -268,10 +272,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
case KParts::BrowserOpenOrSaveQuestion::Save:
kDebug() << "service handling: download!";
downloadRequest(reply->request());
- return; // FIXME RE-ENABLE ME reply->deleteLater();
+ return;
case KParts::BrowserOpenOrSaveQuestion::Cancel:
- return; // FIXME RE-ENABLE ME reply->deleteLater();
+ return;
default: // non extant case
break;
@@ -279,7 +283,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
}
// case KParts::BrowserRun::Embed
-
KService::List partServices = KMimeTypeTrader::self()->query(mimeType, QL1S("KParts/ReadOnlyPart"));
if (partServices.count() > 0)
{
@@ -299,7 +302,9 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
html += "</body>";
html += "</html>";
- mainFrame()->setHtml(html, url);
+ mainFrame()->setHtml(html);
+ _isOnRekonqPage = true;
+ kDebug() << "EMBED true";
}
else
{
@@ -307,7 +312,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
KRun::run(*appService, url, 0);
}
- return ; // FIXME RE-ENABLE ME reply->deleteLater();
+ return;
}
}
@@ -315,7 +320,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
void WebPage::loadFinished(bool ok)
{
Q_UNUSED(ok);
-
+
Application::adblockManager()->applyHidingRules(this);
QStringList list = ReKonfig::walletBlackList();
@@ -379,7 +384,11 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
case QNetworkReply::ProtocolInvalidOperationError: // requested operation is invalid for this protocol
if (reply->url() == _loadingUrl)
- mainFrame()->setHtml(errorPage(reply), reply->url());
+ {
+ mainFrame()->setHtml(errorPage(reply));
+ _isOnRekonqPage = true;
+ kDebug() << "ERROR true";
+ }
break;
default:
@@ -387,7 +396,6 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
break;
}
- // FIXME RE-ENABLE ME reply->deleteLater();
}
@@ -585,15 +593,3 @@ void WebPage::updateImage(bool ok)
p.snapFinished();
}
}
-
-
-bool WebPage::hasNetworkAnalyzerEnabled() const
-{
- return _networkAnalyzer;
-}
-
-
-void WebPage::enableNetworkAnalyzer(bool b)
-{
- _networkAnalyzer = b;
-}
diff --git a/src/webpage.h b/src/webpage.h
index 74695f35..9b2243bc 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -60,9 +60,12 @@ public:
explicit WebPage(QWidget *parent = 0);
~WebPage();
- bool hasNetworkAnalyzerEnabled() const;
- void enableNetworkAnalyzer(bool);
-
+ inline bool hasNetworkAnalyzerEnabled() const { return _networkAnalyzer; };
+ inline void enableNetworkAnalyzer(bool b) { _networkAnalyzer = b; };
+
+ inline bool isOnRekonqPage() const { return _isOnRekonqPage; };
+ inline void setIsOnRekonqPage(bool b) { _isOnRekonqPage = b; };
+
public slots:
virtual void downloadRequest(const QNetworkRequest &request);
void downloadAllContentsWithKGet(QPoint);
@@ -89,6 +92,7 @@ private:
WebSslInfo _sslInfo;
bool _networkAnalyzer;
+ bool _isOnRekonqPage;
};
#endif