diff options
author | ck <qt-info@nokia.com> | 2009-11-16 15:10:46 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2009-11-16 15:11:46 (GMT) |
commit | f3556c2afa373cd37cb64e35b4b1d990558396c8 (patch) | |
tree | f6ef1b0ca3ce27d0d11f6f5bbd3afa19929d52d0 | |
parent | 7cc0f75a3572cd001df7150faf04dc59e6b95edc (diff) | |
download | Qt-f3556c2afa373cd37cb64e35b4b1d990558396c8.zip Qt-f3556c2afa373cd37cb64e35b4b1d990558396c8.tar.gz Qt-f3556c2afa373cd37cb64e35b4b1d990558396c8.tar.bz2 |
Assistant: Display "Page not found" message for invalid URLs.
Reviewed-by: kh1
-rw-r--r-- | tools/assistant/tools/assistant/helpviewer.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 3547652..157f5ab 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -63,6 +63,12 @@ QT_BEGIN_NAMESPACE +namespace { + const QString PageNotFoundMessage = + QObject::tr("<title>Error 404...</title><div align=\"center\"><br><br>" + "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>"); +} + #if !defined(QT_NO_WEBKIT) class HelpNetworkReply : public QNetworkReply @@ -151,7 +157,10 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, mimeType = QLatin1String("text/html"); } - return new HelpNetworkReply(request, helpEngine->fileData(url), mimeType); + const QByteArray &data = helpEngine->findFile(url).isValid() + ? helpEngine->fileData(url) + : PageNotFoundMessage.arg(url.toString()).toUtf8(); + return new HelpNetworkReply(request, data, mimeType); } class HelpPage : public QWebPage @@ -425,9 +434,7 @@ void HelpViewer::setSource(const QUrl &url) "assistantinternal-1.0.0/assistant/assistant.html"))); } else { QTextBrowser::setSource(url); - setHtml(tr("<title>Error 404...</title><div align=\"center\"><br><br>" - "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>") - .arg(url.toString())); + setHtml(PageNotFoundMessage.arg(url.toString())); emit sourceChanged(url); } } |