summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-08-01 12:24:32 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:04 +0100
commite473d62586b7d31c281d5fa15a7cd98f9024190a (patch)
treef24f6f1582e9ade2786ce9b3a1c41781a1d8a465 /src
parentFix use of webpage (diff)
downloadrekonq-e473d62586b7d31c281d5fa15a7cd98f9024190a.tar.xz
Remove a lot of application calls by refactoring code
Diffstat (limited to 'src')
-rw-r--r--src/webtab/protocolhandler.cpp26
-rw-r--r--src/webtab/protocolhandler.h6
-rw-r--r--src/webtab/webpage.cpp29
-rw-r--r--src/webtab/webpage.h1
-rw-r--r--src/webwindow/webwindow.cpp12
-rw-r--r--src/webwindow/webwindow.h3
6 files changed, 47 insertions, 30 deletions
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 <KLineEdit> // this has to be substituted with #include "urlbar.h"
+// #include "newtabpage.h"
// KDE Includes
#include <KIO/Job>
@@ -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<WebPage *>(_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());
}
}
diff --git a/src/webtab/protocolhandler.h b/src/webtab/protocolhandler.h
index f35fdcc6..c4bc6faf 100644
--- a/src/webtab/protocolhandler.h
+++ b/src/webtab/protocolhandler.h
@@ -38,6 +38,8 @@
#include <QObject>
// Forward Declarations
+class WebWindow;
+
class KDirLister;
class KFileItemList;
class KJob;
@@ -65,6 +67,8 @@ public:
*/
bool postHandling(const QNetworkRequest &request, QWebFrame *frame);
+ void setWindow(WebWindow *);
+
Q_SIGNALS:
void downloadUrl(const KUrl &);
@@ -78,6 +82,8 @@ private:
KDirLister *_lister;
QWebFrame *_frame;
KUrl _url;
+
+ WebWindow *_webwin;
};
#endif // PROTOCOL_HANDLER_H
diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp
index d87c2119..c2b6bdde 100644
--- a/src/webtab/webpage.cpp
+++ b/src/webtab/webpage.cpp
@@ -41,15 +41,16 @@
#include "downloadmanager.h"
#include "historymanager.h"
#include "iconmanager.h"
-#include "tabwindow.h"
+
#include "networkaccessmanager.h"
#include "webpluginfactory.h"
#include "websnap.h"
#include "webtab.h"
-#include "searchengine.h"
-// #include "sslwidget.h"
#include "sslinfodialog.h"
+#include "searchengine.h"
+#include "webwindow.h"
+
// KDE Includes
#include <KTemporaryFile>
#include <KStandardDirs>
@@ -125,6 +126,11 @@ WebPage::WebPage(QWidget *parent)
, _networkAnalyzer(false)
, _isOnRekonqPage(false)
{
+ WebView *view = qobject_cast<WebView *>(parent);
+ WebTab *tab = qobject_cast<WebTab *>(view->parent());
+ WebWindow *w = tab->webWindow();
+ _protHandler.setWindow(w);
+
// handling unsupported content...
setForwardUnsupportedContent(true);
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*)));
@@ -691,23 +697,6 @@ void WebPage::downloadAllContentsWithKGet()
}
-void WebPage::showSSLInfo(QPoint pos)
-{
- if (mainFrame()->url().scheme() == QL1S("https"))
- {
-// SSLWidget *widget = new SSLWidget(mainFrame()->url(), _sslInfo, view());
-// widget->showAt(pos);
- }
- else
- {
- KMessageBox::information(view(),
- i18n("This site does not contain SSL information."),
- i18nc("Secure Sockets Layer", "SSL")
- );
- }
-}
-
-
void WebPage::copyToTempFileResult(KJob* job)
{
if (job->error())
diff --git a/src/webtab/webpage.h b/src/webtab/webpage.h
index 1985e047..79a8e8f4 100644
--- a/src/webtab/webpage.h
+++ b/src/webtab/webpage.h
@@ -81,7 +81,6 @@ private Q_SLOTS:
void manageNetworkErrors(QNetworkReply *reply);
void loadStarted();
void loadFinished(bool);
- void showSSLInfo(QPoint);
void copyToTempFileResult(KJob*);
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index cdd350b3..c0cd9c41 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -141,6 +141,18 @@ QIcon WebWindow::icon() const
}
+KLineEdit *WebWindow::urlBar()
+{
+ return _edit;
+}
+
+
+WebTab *WebWindow::view()
+{
+ return _tab;
+}
+
+
QPixmap WebWindow::tabPreview(int width, int height)
{
return WebSnap::renderPagePreview(*page(), width, height);
diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h
index 64af055b..9551000b 100644
--- a/src/webwindow/webwindow.h
+++ b/src/webwindow/webwindow.h
@@ -64,6 +64,9 @@ public:
KUrl url() const;
QString title() const;
QIcon icon() const;
+
+ KLineEdit *urlBar();
+ WebTab *view();
QPixmap tabPreview(int width, int height);