1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Fixed history in frames. Closes #361

This commit is contained in:
nowrep 2012-04-04 13:21:53 +02:00
parent 79a548b365
commit 6b79ca55bf
5 changed files with 20 additions and 27 deletions

View File

@ -57,7 +57,6 @@
#include "webinspectordockwidget.h" #include "webinspectordockwidget.h"
#include "bookmarksimportdialog.h" #include "bookmarksimportdialog.h"
#include "globalfunctions.h" #include "globalfunctions.h"
#include "webhistorywrapper.h"
#include "enhancedmenu.h" #include "enhancedmenu.h"
#include "settings.h" #include "settings.h"
#include "webtab.h" #include "webtab.h"
@ -77,6 +76,7 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QPrintPreviewDialog> #include <QPrintPreviewDialog>
#include <QWebFrame> #include <QWebFrame>
#include <QWebHistory>
#include <QMessageBox> #include <QMessageBox>
const QString QupZilla::VERSION = "1.1.8"; const QString QupZilla::VERSION = "1.1.8";
@ -813,12 +813,13 @@ void QupZilla::aboutToShowBookmarksMenu()
void QupZilla::aboutToShowHistoryMenu() void QupZilla::aboutToShowHistoryMenu()
{ {
if (!weView()) { TabbedWebView* view = weView();
if (!view) {
return; return;
} }
m_menuHistory->actions().at(0)->setEnabled(WebHistoryWrapper::canGoBack(weView()->history())); m_menuHistory->actions().at(0)->setEnabled(view->history()->canGoBack());
m_menuHistory->actions().at(1)->setEnabled(WebHistoryWrapper::canGoForward(weView()->history())); m_menuHistory->actions().at(1)->setEnabled(view->history()->canGoForward());
} }
void QupZilla::aboutToHideHistoryMenu() void QupZilla::aboutToHideHistoryMenu()

View File

@ -305,26 +305,25 @@ void NavigationBar::refreshHistory()
} }
QWebHistory* history = p_QupZilla->weView()->page()->history(); QWebHistory* history = p_QupZilla->weView()->page()->history();
m_buttonBack->setEnabled(WebHistoryWrapper::canGoBack(history)); m_buttonBack->setEnabled(history->canGoBack());
m_buttonNext->setEnabled(WebHistoryWrapper::canGoForward(history)); m_buttonNext->setEnabled(history->canGoForward());
} }
void NavigationBar::goBack() void NavigationBar::goBack()
{ {
QWebHistory* history = p_QupZilla->weView()->page()->history(); QWebHistory* history = p_QupZilla->weView()->page()->history();
WebHistoryWrapper::goBack(history); history->back();
} }
void NavigationBar::goBackInNewTab() void NavigationBar::goBackInNewTab()
{ {
QWebHistory* history = p_QupZilla->weView()->page()->history(); QWebHistory* history = p_QupZilla->weView()->page()->history();
QList<QWebHistoryItem> backItems = WebHistoryWrapper::backItems(1, history);
if (backItems.isEmpty()) { if (!history->canGoBack()) {
return; return;
} }
int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), backItems.at(0)); int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->backItem());
if (itemIndex == -1) { if (itemIndex == -1) {
return; return;
} }
@ -335,19 +334,18 @@ void NavigationBar::goBackInNewTab()
void NavigationBar::goForward() void NavigationBar::goForward()
{ {
QWebHistory* history = p_QupZilla->weView()->page()->history(); QWebHistory* history = p_QupZilla->weView()->page()->history();
WebHistoryWrapper::goForward(history); history->forward();
} }
void NavigationBar::goForwardInNewTab() void NavigationBar::goForwardInNewTab()
{ {
QWebHistory* history = p_QupZilla->weView()->page()->history(); QWebHistory* history = p_QupZilla->weView()->page()->history();
QList<QWebHistoryItem> forwardItems = WebHistoryWrapper::forwardItems(1, history);
if (forwardItems.isEmpty()) { if (!history->canGoForward()) {
return; return;
} }
int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), forwardItems.at(0)); int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->forwardItem());
if (itemIndex == -1) { if (itemIndex == -1) {
return; return;
} }

View File

@ -18,12 +18,9 @@
#include "webhistorywrapper.h" #include "webhistorywrapper.h"
#include <QUrl> #include <QUrl>
#include <QVariant>
#include <QWebHistory> #include <QWebHistory>
WebHistoryWrapper::WebHistoryWrapper()
{
}
QList<QWebHistoryItem> WebHistoryWrapper::forwardItems(int maxItems, QWebHistory* history) QList<QWebHistoryItem> WebHistoryWrapper::forwardItems(int maxItems, QWebHistory* history)
{ {
QList<QWebHistoryItem> list; QList<QWebHistoryItem> list;

View File

@ -28,8 +28,6 @@ class QWebHistoryItem;
class WebHistoryWrapper class WebHistoryWrapper
{ {
public: public:
explicit WebHistoryWrapper();
static QList<QWebHistoryItem> forwardItems(int maxItems, QWebHistory* history); static QList<QWebHistoryItem> forwardItems(int maxItems, QWebHistory* history);
static QList<QWebHistoryItem> backItems(int maxItems, QWebHistory* history); static QList<QWebHistoryItem> backItems(int maxItems, QWebHistory* history);

View File

@ -17,7 +17,6 @@
* ============================================================ */ * ============================================================ */
#include "webview.h" #include "webview.h"
#include "webpage.h" #include "webpage.h"
#include "webhistorywrapper.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "globalfunctions.h" #include "globalfunctions.h"
#include "iconprovider.h" #include "iconprovider.h"
@ -271,8 +270,8 @@ void WebView::back()
{ {
QWebHistory* history = page()->history(); QWebHistory* history = page()->history();
if (WebHistoryWrapper::canGoBack(history)) { if (history->canGoBack()) {
WebHistoryWrapper::goBack(history); history->back();
emit urlChanged(url()); emit urlChanged(url());
emit iconChanged(); emit iconChanged();
@ -283,8 +282,8 @@ void WebView::forward()
{ {
QWebHistory* history = page()->history(); QWebHistory* history = page()->history();
if (WebHistoryWrapper::canGoForward(history)) { if (history->canGoForward()) {
WebHistoryWrapper::goForward(history); history->forward();
emit urlChanged(url()); emit urlChanged(url());
emit iconChanged(); emit iconChanged();
@ -691,11 +690,11 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
QAction* action = menu->addAction(tr("&Back"), this, SLOT(back())); QAction* action = menu->addAction(tr("&Back"), this, SLOT(back()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack)); 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 = menu->addAction(tr("&Forward"), this, SLOT(forward()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward)); action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward));
action->setEnabled(WebHistoryWrapper::canGoForward(history())); action->setEnabled(history()->canGoForward());
menu->addAction(m_actionReload); menu->addAction(m_actionReload);
menu->addAction(m_actionStop); menu->addAction(m_actionStop);