From 6b79ca55bf3790ef48cf5185b80dc491d861ac65 Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 4 Apr 2012 13:21:53 +0200 Subject: [PATCH] Fixed history in frames. Closes #361 --- src/lib/app/qupzilla.cpp | 9 +++++---- src/lib/navigation/navigationbar.cpp | 18 ++++++++---------- src/lib/webview/webhistorywrapper.cpp | 5 +---- src/lib/webview/webhistorywrapper.h | 2 -- src/lib/webview/webview.cpp | 13 ++++++------- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 2592929b8..6ea64a767 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -57,7 +57,6 @@ #include "webinspectordockwidget.h" #include "bookmarksimportdialog.h" #include "globalfunctions.h" -#include "webhistorywrapper.h" #include "enhancedmenu.h" #include "settings.h" #include "webtab.h" @@ -77,6 +76,7 @@ #include #include #include +#include #include const QString QupZilla::VERSION = "1.1.8"; @@ -813,12 +813,13 @@ void QupZilla::aboutToShowBookmarksMenu() void QupZilla::aboutToShowHistoryMenu() { - if (!weView()) { + TabbedWebView* view = weView(); + if (!view) { return; } - m_menuHistory->actions().at(0)->setEnabled(WebHistoryWrapper::canGoBack(weView()->history())); - m_menuHistory->actions().at(1)->setEnabled(WebHistoryWrapper::canGoForward(weView()->history())); + m_menuHistory->actions().at(0)->setEnabled(view->history()->canGoBack()); + m_menuHistory->actions().at(1)->setEnabled(view->history()->canGoForward()); } void QupZilla::aboutToHideHistoryMenu() diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index 38e7b829b..3a04e0139 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -305,26 +305,25 @@ void NavigationBar::refreshHistory() } QWebHistory* history = p_QupZilla->weView()->page()->history(); - m_buttonBack->setEnabled(WebHistoryWrapper::canGoBack(history)); - m_buttonNext->setEnabled(WebHistoryWrapper::canGoForward(history)); + m_buttonBack->setEnabled(history->canGoBack()); + m_buttonNext->setEnabled(history->canGoForward()); } void NavigationBar::goBack() { QWebHistory* history = p_QupZilla->weView()->page()->history(); - WebHistoryWrapper::goBack(history); + history->back(); } void NavigationBar::goBackInNewTab() { QWebHistory* history = p_QupZilla->weView()->page()->history(); - QList backItems = WebHistoryWrapper::backItems(1, history); - if (backItems.isEmpty()) { + if (!history->canGoBack()) { return; } - int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), backItems.at(0)); + int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->backItem()); if (itemIndex == -1) { return; } @@ -335,19 +334,18 @@ void NavigationBar::goBackInNewTab() void NavigationBar::goForward() { QWebHistory* history = p_QupZilla->weView()->page()->history(); - WebHistoryWrapper::goForward(history); + history->forward(); } void NavigationBar::goForwardInNewTab() { QWebHistory* history = p_QupZilla->weView()->page()->history(); - QList forwardItems = WebHistoryWrapper::forwardItems(1, history); - if (forwardItems.isEmpty()) { + if (!history->canGoForward()) { return; } - int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), forwardItems.at(0)); + int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->forwardItem()); if (itemIndex == -1) { return; } diff --git a/src/lib/webview/webhistorywrapper.cpp b/src/lib/webview/webhistorywrapper.cpp index d0eaba97e..21e6daaf8 100644 --- a/src/lib/webview/webhistorywrapper.cpp +++ b/src/lib/webview/webhistorywrapper.cpp @@ -18,12 +18,9 @@ #include "webhistorywrapper.h" #include +#include #include -WebHistoryWrapper::WebHistoryWrapper() -{ -} - QList WebHistoryWrapper::forwardItems(int maxItems, QWebHistory* history) { QList list; diff --git a/src/lib/webview/webhistorywrapper.h b/src/lib/webview/webhistorywrapper.h index 0ac4b40ae..8e767d2ea 100644 --- a/src/lib/webview/webhistorywrapper.h +++ b/src/lib/webview/webhistorywrapper.h @@ -28,8 +28,6 @@ class QWebHistoryItem; class WebHistoryWrapper { public: - explicit WebHistoryWrapper(); - static QList forwardItems(int maxItems, QWebHistory* history); static QList backItems(int maxItems, QWebHistory* history); diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index d9e2b93a8..bdf55c53d 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -17,7 +17,6 @@ * ============================================================ */ #include "webview.h" #include "webpage.h" -#include "webhistorywrapper.h" #include "mainapplication.h" #include "globalfunctions.h" #include "iconprovider.h" @@ -271,8 +270,8 @@ void WebView::back() { QWebHistory* history = page()->history(); - if (WebHistoryWrapper::canGoBack(history)) { - WebHistoryWrapper::goBack(history); + if (history->canGoBack()) { + history->back(); emit urlChanged(url()); emit iconChanged(); @@ -283,8 +282,8 @@ void WebView::forward() { QWebHistory* history = page()->history(); - if (WebHistoryWrapper::canGoForward(history)) { - WebHistoryWrapper::goForward(history); + if (history->canGoForward()) { + history->forward(); emit urlChanged(url()); emit iconChanged(); @@ -691,11 +690,11 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos) QAction* action = menu->addAction(tr("&Back"), this, SLOT(back())); action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack)); - action->setEnabled(WebHistoryWrapper::canGoBack(history())); + action->setEnabled(history()->canGoBack()); action = menu->addAction(tr("&Forward"), this, SLOT(forward())); action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward)); - action->setEnabled(WebHistoryWrapper::canGoForward(history())); + action->setEnabled(history()->canGoForward()); menu->addAction(m_actionReload); menu->addAction(m_actionStop);