diff --git a/autotests/tabmodeltest.cpp b/autotests/tabmodeltest.cpp index c35d1e198..87112f1f6 100644 --- a/autotests/tabmodeltest.cpp +++ b/autotests/tabmodeltest.cpp @@ -21,7 +21,6 @@ #include "tabtreemodel.h" #include "webtab.h" #include "tabwidget.h" -#include "tabbedwebview.h" #include "mainapplication.h" #include "browserwindow.h" @@ -50,7 +49,7 @@ void TabModelTest::basicTest() rowsInsertedSpy.wait(); QCOMPARE(rowsInsertedSpy.count(), 1); - WebTab *tab0 = w->weView(0)->webTab(); + WebTab *tab0 = w->tabWidget()->webTab(0); QCOMPARE(rowsInsertedSpy.at(0).at(0).value(), QModelIndex()); QCOMPARE(rowsInsertedSpy.at(0).at(1).toInt(), 0); QCOMPARE(rowsInsertedSpy.at(0).at(2).toInt(), 0); @@ -61,23 +60,23 @@ void TabModelTest::basicTest() w->tabWidget()->addView(QUrl("http://test.com")); QCOMPARE(rowsInsertedSpy.count(), 1); - WebTab *tab1 = w->weView(1)->webTab(); + WebTab *tab1 = w->tabWidget()->webTab(1); QCOMPARE(rowsInsertedSpy.at(0).at(0).value(), QModelIndex()); QCOMPARE(rowsInsertedSpy.at(0).at(1).toInt(), 1); QCOMPARE(rowsInsertedSpy.at(0).at(2).toInt(), 1); QCOMPARE(model1.data(model1.index(1, 0), TabModel::WebTabRole).value(), tab1); w->tabWidget()->moveTab(0, 1); - QCOMPARE(w->weView(0)->webTab(), tab1); - QCOMPARE(w->weView(1)->webTab(), tab0); + QCOMPARE(w->tabWidget()->webTab(0), tab1); + QCOMPARE(w->tabWidget()->webTab(1), tab0); w->tabWidget()->moveTab(1, 0); - QCOMPARE(w->weView(0)->webTab(), tab0); - QCOMPARE(w->weView(1)->webTab(), tab1); + QCOMPARE(w->tabWidget()->webTab(0), tab0); + QCOMPARE(w->tabWidget()->webTab(1), tab1); w->tabWidget()->moveTab(0, 1); - QCOMPARE(w->weView(0)->webTab(), tab1); - QCOMPARE(w->weView(1)->webTab(), tab0); + QCOMPARE(w->tabWidget()->webTab(0), tab1); + QCOMPARE(w->tabWidget()->webTab(1), tab0); QCOMPARE(rowsRemovedSpy.count(), 0); @@ -106,7 +105,7 @@ void TabModelTest::dataTest() QTRY_COMPARE(model.rowCount(), 1); - WebTab *tab0 = w->weView(0)->webTab(); + WebTab *tab0 = w->tabWidget()->webTab(0); QCOMPARE(model.index(0, 0).data(TabModel::TitleRole).toString(), tab0->title()); QCOMPARE(model.index(0, 0).data(Qt::DisplayRole).toString(), tab0->title()); QCOMPARE(model.index(0, 0).data(TabModel::IconRole).value().pixmap(16), tab0->icon().pixmap(16)); @@ -131,8 +130,8 @@ void TabModelTest::pinTabTest() QTRY_COMPARE(model.rowCount(), 2); - WebTab *tab0 = w->weView(0)->webTab(); - WebTab *tab1 = w->weView(1)->webTab(); + WebTab *tab0 = w->tabWidget()->webTab(0); + WebTab *tab1 = w->tabWidget()->webTab(1); QCOMPARE(model.data(model.index(0, 0), TabModel::WebTabRole).value(), tab0); QCOMPARE(model.data(model.index(1, 0), TabModel::WebTabRole).value(), tab1); @@ -163,12 +162,12 @@ void TabModelTest::treeModelTest() QTRY_COMPARE(model.rowCount(QModelIndex()), 6); - WebTab *tab1 = w->weView(0)->webTab(); - WebTab *tab2 = w->weView(1)->webTab(); - WebTab *tab3 = w->weView(2)->webTab(); - WebTab *tab4 = w->weView(3)->webTab(); - WebTab *tab5 = w->weView(4)->webTab(); - WebTab *tab6 = w->weView(5)->webTab(); + WebTab *tab1 = w->tabWidget()->webTab(0); + WebTab *tab2 = w->tabWidget()->webTab(1); + WebTab *tab3 = w->tabWidget()->webTab(2); + WebTab *tab4 = w->tabWidget()->webTab(3); + WebTab *tab5 = w->tabWidget()->webTab(4); + WebTab *tab6 = w->tabWidget()->webTab(5); QCOMPARE(model.index(0, 0).data(TabModel::WebTabRole).value(), tab1); QCOMPARE(model.index(1, 0).data(TabModel::WebTabRole).value(), tab2); diff --git a/src/lib/adblock/adblockicon.cpp b/src/lib/adblock/adblockicon.cpp index 89fbadaf9..6b28ca9e0 100644 --- a/src/lib/adblock/adblockicon.cpp +++ b/src/lib/adblock/adblockicon.cpp @@ -22,7 +22,6 @@ #include "mainapplication.h" #include "browserwindow.h" #include "webview.h" -#include "tabbedwebview.h" #include "tabwidget.h" #include "desktopnotificationsfactory.h" #include "qztools.h" diff --git a/src/lib/autofill/autofill.cpp b/src/lib/autofill/autofill.cpp index a03e13297..e93945023 100644 --- a/src/lib/autofill/autofill.cpp +++ b/src/lib/autofill/autofill.cpp @@ -19,7 +19,6 @@ #include "browserwindow.h" #include "webpage.h" #include "sqldatabase.h" -#include "tabbedwebview.h" #include "popupwebview.h" #include "mainapplication.h" #include "autofillnotification.h" diff --git a/src/lib/history/history.cpp b/src/lib/history/history.cpp index f4fe31a8f..e41324a16 100644 --- a/src/lib/history/history.cpp +++ b/src/lib/history/history.cpp @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2017 David Rosca +* Copyright (C) 2010-2018 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,12 +17,12 @@ * ============================================================ */ #include "history.h" #include "historymodel.h" -#include "tabbedwebview.h" #include "browserwindow.h" #include "iconprovider.h" #include "settings.h" #include "mainapplication.h" #include "sqldatabase.h" +#include "webview.h" #include diff --git a/src/lib/navigation/completer/locationcompleter.cpp b/src/lib/navigation/completer/locationcompleter.cpp index db9eef1c7..5c3e78710 100644 --- a/src/lib/navigation/completer/locationcompleter.cpp +++ b/src/lib/navigation/completer/locationcompleter.cpp @@ -333,7 +333,7 @@ void LocationCompleter::switchToTab(BrowserWindow* window, int tab) window->raise(); } else { - window->weView()->setFocus(); + tabWidget->webTab()->setFocus(); } } diff --git a/src/lib/network/schemehandlers/falkonschemehandler.cpp b/src/lib/network/schemehandlers/falkonschemehandler.cpp index 195173888..c76f81169 100644 --- a/src/lib/network/schemehandlers/falkonschemehandler.cpp +++ b/src/lib/network/schemehandlers/falkonschemehandler.cpp @@ -19,7 +19,6 @@ #include "qztools.h" #include "browserwindow.h" #include "mainapplication.h" -#include "tabbedwebview.h" #include "speeddial.h" #include "pluginproxy.h" #include "plugininterface.h" diff --git a/src/lib/other/aboutdialog.cpp b/src/lib/other/aboutdialog.cpp index f577ce388..e00bacf02 100644 --- a/src/lib/other/aboutdialog.cpp +++ b/src/lib/other/aboutdialog.cpp @@ -19,7 +19,6 @@ #include "ui_aboutdialog.h" #include "browserwindow.h" #include "mainapplication.h" -#include "tabbedwebview.h" #include "webpage.h" #include "useragentmanager.h" diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 2e8d6ccfb..2ef16f3ca 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -21,7 +21,6 @@ #include "webtab.h" #include "toolbutton.h" #include "settings.h" -#include "tabbedwebview.h" #include "mainapplication.h" #include "pluginproxy.h" #include "iconprovider.h" @@ -702,7 +701,7 @@ void TabBar::dropEvent(QDropEvent* event) } } else { LoadRequest req; - WebTab* tab = m_window->weView(index)->webTab(); + WebTab* tab = m_tabWidget->webTab(index); TabDropAction action = tabDropAction(event->pos(), tabRect(index), !mime->hasFormat(MIMETYPE)); if (mime->hasUrls()) { req = mime->urls().at(0); @@ -711,7 +710,7 @@ void TabBar::dropEvent(QDropEvent* event) } if (action == SelectTab) { if (tab->isRestored() && req.isValid()) { - tab->webView()->load(req); + tab->load(req); } } else if (action == PrependTab || action == AppendTab) { const int newIndex = action == PrependTab ? index : index + 1; diff --git a/src/lib/tabwidget/tabmodel.cpp b/src/lib/tabwidget/tabmodel.cpp index 558e0e729..f3ef96f15 100644 --- a/src/lib/tabwidget/tabmodel.cpp +++ b/src/lib/tabwidget/tabmodel.cpp @@ -18,7 +18,6 @@ #include "tabmodel.h" #include "webtab.h" #include "tabwidget.h" -#include "tabbedwebview.h" #include "browserwindow.h" // TabModelMimeData @@ -235,7 +234,7 @@ void TabModel::init() void TabModel::tabInserted(int index) { - WebTab *tab = m_window->weView(index)->webTab(); + WebTab *tab = m_window->tabWidget()->webTab(index); beginInsertRows(QModelIndex(), index, index); m_tabs.insert(index, tab); diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index c09f6cf37..748c2c159 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -175,17 +175,17 @@ void TabWidget::loadSettings() updateClosedTabsButton(); } -WebTab* TabWidget::weTab() +WebTab* TabWidget::weTab() const { return weTab(currentIndex()); } -WebTab* TabWidget::weTab(int index) +WebTab* TabWidget::weTab(int index) const { return qobject_cast(widget(index)); } -TabIcon* TabWidget::tabIcon(int index) +TabIcon* TabWidget::tabIcon(int index) const { return weTab(index)->tabIcon(); } @@ -571,6 +571,11 @@ void TabWidget::reloadTab(int index) weTab(index)->reload(); } +WebTab *TabWidget::webTab(int index) const +{ + return index < 0 ? weTab() : weTab(index); +} + WebTab *TabWidget::lastTab() const { return m_lastTab; diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index b5f6abd6a..bbb00cc08 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -83,6 +83,8 @@ public: int pinnedTabsCount() const; int extraReservedWidth() const; + WebTab *webTab(int index = -1) const; + WebTab *lastTab() const; int lastTabIndex() const; @@ -148,9 +150,9 @@ private slots: void tabWasMoved(int before, int after); private: - WebTab* weTab(); - WebTab* weTab(int index); - TabIcon* tabIcon(int index); + WebTab* weTab() const; + WebTab* weTab(int index) const; + TabIcon* tabIcon(int index) const; bool validIndex(int index) const; void updateClosedTabsButton(); diff --git a/src/lib/webtab/searchtoolbar.cpp b/src/lib/webtab/searchtoolbar.cpp index 54d41bf29..3e9583d58 100644 --- a/src/lib/webtab/searchtoolbar.cpp +++ b/src/lib/webtab/searchtoolbar.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * ============================================================ */ #include "searchtoolbar.h" -#include "tabbedwebview.h" +#include "webview.h" #include "webpage.h" #include "lineedit.h" #include "ui_searchtoolbar.h" diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index 45ccd3f78..564439678 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -140,6 +140,7 @@ WebTab::WebTab(QWidget *parent) m_webView = new TabbedWebView(this); m_webView->setPage(new WebPage); m_webView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + setFocusProxy(m_webView); m_locationBar = new LocationBar(this); m_locationBar->setWebView(m_webView); @@ -378,6 +379,11 @@ void WebTab::reload() m_webView->reload(); } +void WebTab::load(const LoadRequest &request) +{ + m_webView->load(request); +} + void WebTab::unload() { m_savedTab = SavedTab(this); diff --git a/src/lib/webtab/webtab.h b/src/lib/webtab/webtab.h index 259957ed2..ef5cc839f 100644 --- a/src/lib/webtab/webtab.h +++ b/src/lib/webtab/webtab.h @@ -34,6 +34,7 @@ class WebInspector; class LocationBar; class TabIcon; class TabBar; +class LoadRequest; class FALKON_EXPORT WebTab : public QWidget { @@ -94,6 +95,7 @@ public: void stop(); void reload(); + void load(const LoadRequest &request); void unload(); bool isLoading() const; diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp index 89035522d..d29ecd4a9 100644 --- a/src/plugins/GreaseMonkey/gm_plugin.cpp +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -24,7 +24,6 @@ #include "emptynetworkreply.h" #include "tabwidget.h" #include "webtab.h" -#include "tabbedwebview.h" #include "../config.h" #include diff --git a/src/plugins/VerticalTabs/verticaltabswidget.cpp b/src/plugins/VerticalTabs/verticaltabswidget.cpp index 2caed14b1..d2a82eb47 100644 --- a/src/plugins/VerticalTabs/verticaltabswidget.cpp +++ b/src/plugins/VerticalTabs/verticaltabswidget.cpp @@ -22,9 +22,9 @@ #include "webtab.h" #include "tabmodel.h" +#include "tabwidget.h" #include "toolbutton.h" #include "tabtreemodel.h" -#include "tabbedwebview.h" #include "browserwindow.h" #include @@ -111,7 +111,7 @@ void VerticalTabsWidget::switchToPreviousTab() WebTab *VerticalTabsWidget::nextTab() const { QModelIndex next; - if (m_window->weView()->webTab()->isPinned()) { + if (m_window->tabWidget()->webTab()->isPinned()) { next = m_pinnedView->indexAfter(m_pinnedView->currentIndex()); if (!next.isValid()) { next = m_normalView->model()->index(0, 0); @@ -128,7 +128,7 @@ WebTab *VerticalTabsWidget::nextTab() const WebTab *VerticalTabsWidget::previousTab() const { QModelIndex previous; - if (m_window->weView()->webTab()->isPinned()) { + if (m_window->tabWidget()->webTab()->isPinned()) { previous = m_pinnedView->indexBefore(m_pinnedView->currentIndex()); if (!previous.isValid()) { previous = m_normalView->model()->index(m_normalView->model()->rowCount() - 1, 0);