From 412e9b019ad5c868dd0c5573bf185a32cca31b7d Mon Sep 17 00:00:00 2001 From: Bernhard Beschow Date: Mon, 14 Dec 2009 17:43:05 +0100 Subject: factor out WebTab class from WebView * it basically represents a tab in rekonq * everything that happens within one tab should go here (wallet bar, find bar?) --- src/webtab.cpp | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/webtab.cpp (limited to 'src/webtab.cpp') diff --git a/src/webtab.cpp b/src/webtab.cpp new file mode 100644 index 00000000..f79e53d0 --- /dev/null +++ b/src/webtab.cpp @@ -0,0 +1,171 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2009 by Lionel Chauvin +* +* +* 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 the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* ============================================================ */ + + +// Self Includes +#include "webtab.h" +#include "webtab.moc" + +// Auto Includes +#include "rekonq.h" + +// Local Includes +#include "application.h" +#include "mainwindow.h" +#include "mainview.h" +#include "webpage.h" +#include "bookmarksmanager.h" +#include "walletwidget.h" + +// KDE Includes +#include +#include +#include +#include +#include +#include +#include + +// Qt Includes +#include +#include +#include +#include +#include +#include +#include + + +WebTab::WebTab(QWidget* parent) + : QWidget(parent) + , m_view( new WebView(parent) ) + , m_progress(0) +{ + QVBoxLayout* l=new QVBoxLayout(this); + l->setMargin(0); + + QWidget* messageBar=new QWidget(this); + l->addWidget(messageBar); + messageBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + + QVBoxLayout* l2 = new QVBoxLayout(messageBar); + l2->setMargin(0); + l2->setSpacing(0); + + l->addWidget(m_view); + m_view->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + + // add kwallet bar + { + WalletWidget *walletBar = new WalletWidget(messageBar); + messageBar->layout()->addWidget(walletBar); + walletBar->hide(); + + KWebWallet *wallet = m_view->page()->wallet(); + if(wallet) + { + connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), + walletBar, SLOT(onSaveFormData(const QString &, const QUrl &))); + connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)), + wallet, SLOT(acceptSaveFormDataRequest(const QString &))); + connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)), + wallet, SLOT(rejectSaveFormDataRequest(const QString &))); + + connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), + walletBar, SLOT(show())); + connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)), + walletBar, SLOT(hide())); + connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)), + walletBar, SLOT(hide())); + + } + } + + connect(m_view->page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); + connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); + connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); + + connect(m_view, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) ); +} + + +WebTab::~WebTab() +{ +} + + +WebView *WebTab::view() +{ + return m_view; +} + + +WebPage *WebTab::page() +{ + return m_view->page(); +} + + +KUrl WebTab::url() const +{ + return KUrl(m_view->url()); +} + + +int WebTab::progress() +{ + return m_progress; +} + + +QString WebTab::lastStatusBarText() const +{ + return m_statusBarText; +} + + +void WebTab::setStatusBarText(const QString &string) +{ + m_statusBarText = string; +} + + +void WebTab::updateProgress(int p) +{ + m_progress = p; +} + + +void WebTab::loadFinished(bool) +{ + m_progress = 0; +} + + +void WebTab::loadInNewTab(const KUrl &url) +{ + Application::instance()->loadUrl(url, Rekonq::NewCurrentTab); +} -- cgit v1.2.1