mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
TabWidget: Add public webTab method
Also cleanup tabbedwebview.h includes.
This commit is contained in:
parent
fbbe3c6385
commit
408b2ffad6
|
@ -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>(), 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>(), 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<WebTab*>(), 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<QIcon>().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<WebTab*>(), tab0);
|
||||
QCOMPARE(model.data(model.index(1, 0), TabModel::WebTabRole).value<WebTab*>(), 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<WebTab*>(), tab1);
|
||||
QCOMPARE(model.index(1, 0).data(TabModel::WebTabRole).value<WebTab*>(), tab2);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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 <QWebEngineProfile>
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ void LocationCompleter::switchToTab(BrowserWindow* window, int tab)
|
|||
window->raise();
|
||||
}
|
||||
else {
|
||||
window->weView()->setFocus();
|
||||
tabWidget->webTab()->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "ui_aboutdialog.h"
|
||||
#include "browserwindow.h"
|
||||
#include "mainapplication.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "webpage.h"
|
||||
#include "useragentmanager.h"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<WebTab*>(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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "searchtoolbar.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "webview.h"
|
||||
#include "webpage.h"
|
||||
#include "lineedit.h"
|
||||
#include "ui_searchtoolbar.h"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "emptynetworkreply.h"
|
||||
#include "tabwidget.h"
|
||||
#include "webtab.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "../config.h"
|
||||
|
||||
#include <QTranslator>
|
||||
|
|
|
@ -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 <QListView>
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user