summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-08-13 16:04:36 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-08-13 16:04:36 +0200
commit9fc1c2bf47f3cf5496e6ec9c99daabce5a9696c2 (patch)
treea2da534e4a3b098327a6b975a5d10f765fd1c99a
parentRemoved unuseful (?) WebPage::chooseFile method. (diff)
downloadrekonq-9fc1c2bf47f3cf5496e6ec9c99daabce5a9696c2.tar.xz
Some work on WebPage class..
-rw-r--r--src/webpage.cpp57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index b289c97f..33711f7d 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -91,13 +91,13 @@ WebPage::~WebPage()
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
{
- m_requestedUrl = request.url();
-
if (m_requestedUrl.scheme() == QLatin1String("mailto"))
{
KToolInvocation::invokeMailer(m_requestedUrl);
return false;
}
+
+ m_requestedUrl = request.url();
if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)
{
@@ -132,7 +132,6 @@ WebPage *WebPage::newWindow(WebWindowType type)
}
-// FIXME: dear slot, you need to handle unsupported content a bit better..
void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply)
{
if (reply->error() == QNetworkReply::NoError)
@@ -170,40 +169,39 @@ void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply)
void WebPage::manageNetworkErrors(QNetworkReply* reply)
{
- if (reply->url() != m_requestedUrl) //prevent favicon loading
+ if( reply->error() == QNetworkReply::NoError )
return;
-
- switch (reply->error())
+
+ if( reply->url() != m_requestedUrl ) // prevent favicon loading
+ return;
+
+ if( reply->error() == QNetworkReply::ContentNotFoundError )
{
- case QNetworkReply::NoError:
- return;
- case QNetworkReply::ContentNotFoundError:
+ QList<QWebFrame*> frames;
+ frames.append(mainFrame());
+ while (!frames.isEmpty())
{
- QList<QWebFrame*> frames;
- frames.append(mainFrame());
- while (!frames.isEmpty())
- {
- QWebFrame *firstFrame = frames.takeFirst();
+ QWebFrame *firstFrame = frames.takeFirst();
- if (firstFrame->url() == reply->url())
- {
- firstFrame->setHtml(errorPage(reply), reply->url());
- return;
- }
- QList<QWebFrame *> children = firstFrame->childFrames();
- foreach(QWebFrame *frame, children)
- {
- frames.append(frame);
- }
+ if (firstFrame->url() == reply->url())
+ {
+ firstFrame->setHtml(errorPage(reply), reply->url());
+ return;
+ }
+ QList<QWebFrame *> children = firstFrame->childFrames();
+ foreach(QWebFrame *frame, children)
+ {
+ frames.append(frame);
}
}
- break;
- default:
- mainFrame()->setHtml(errorPage(reply), reply->url());
- break;
+ }
+ else
+ {
+ mainFrame()->setHtml(errorPage(reply), reply->url());
}
}
+
QString WebPage::errorPage(QNetworkReply *reply)
{
// display "not found" page
@@ -227,6 +225,7 @@ QString WebPage::errorPage(QNetworkReply *reply)
return html;
}
+
void WebPage::javaScriptAlert(QWebFrame *frame, const QString &msg)
{
KMessageBox::error(frame->page()->view(), msg, i18n("JavaScript"));
@@ -260,7 +259,7 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
}
-// FIXME: sometimes url.fileName() fails to retrieve url file name
+// TODO FIXME: sometimes url.fileName() fails to retrieve url file name
void WebPage::slotDownloadRequested(const QNetworkRequest &request)
{
const KUrl url(request.url());