From e473d62586b7d31c281d5fa15a7cd98f9024190a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 1 Aug 2012 12:24:32 +0200 Subject: Remove a lot of application calls by refactoring code --- src/webtab/protocolhandler.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/webtab/protocolhandler.cpp') diff --git a/src/webtab/protocolhandler.cpp b/src/webtab/protocolhandler.cpp index 8618667b..0a21fc4c 100644 --- a/src/webtab/protocolhandler.cpp +++ b/src/webtab/protocolhandler.cpp @@ -31,12 +31,12 @@ #include "rekonq.h" // Local Includes -#include "application.h" #include "historymanager.h" -#include "tabwindow.h" #include "webwindow.h" -// #include "newtabpage.h" #include "webpage.h" +#include "webtab.h" +#include // this has to be substituted with #include "urlbar.h" +// #include "newtabpage.h" // KDE Includes #include @@ -91,8 +91,15 @@ ProtocolHandler::ProtocolHandler(QObject *parent) : QObject(parent) , _lister(new KDirLister(this)) , _frame(0) + , _webwin(0) +{ +} + + +void ProtocolHandler::setWindow(WebWindow *w) { - _lister->setMainWindow(rApp->tabWindow()); + _webwin = w; + _lister->setMainWindow(_webwin); } @@ -181,7 +188,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra if (_url.protocol() == QL1S("apt")) { kDebug() << "APT URL: " << _url; - (void)new KRun(_url, rApp->tabWindow(), 0, _url.isLocalFile()); + (void)new KRun(_url, _webwin, 0, _url.isLocalFile()); return true; } @@ -190,7 +197,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra return false; // Error Message, for those protocols we cannot handle - KMessageBox::error(rApp->tabWindow(), i18nc("@info", "rekonq does not know how to handle this protocol: %1", _url.protocol())); + KMessageBox::error(_webwin, i18nc("@info", "rekonq does not know how to handle this protocol: %1", _url.protocol())); return true; } @@ -244,7 +251,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr // Try KRunning it... if (KProtocolInfo::isKnownProtocol(_url)) { - (void)new KRun(_url, rApp->tabWindow(), 0, _url.isLocalFile()); + (void)new KRun(_url, _webwin, 0, _url.isLocalFile()); return true; } @@ -267,8 +274,9 @@ void ProtocolHandler::showResults(const KFileItemList &list) _frame->setHtml(html); qobject_cast(_frame->page())->setIsOnRekonqPage(true); -// FIXME rApp->mainWindow()->mainView()->currentUrlBar()->setQUrl(_url); -// rApp->mainWindow()->currentTab()->setFocus(); + _webwin->urlBar()->setUrl(_url); + _webwin->view()->setFocus(); + HistoryManager::self()->addHistoryEntry(_url, _url.prettyUrl()); } } -- cgit v1.2.1