From 0fd81e81a357edb9f9e615cff28a1876bd363b2e Mon Sep 17 00:00:00 2001 From: kh1 Date: Mon, 19 Apr 2010 18:59:32 +0200 Subject: Quick fix to make the documentation work, needs a proper solution though. Reviewed-by: kh --- tools/assistant/tools/assistant/helpviewer.cpp | 4 ++++ tools/assistant/tools/assistant/helpviewer.h | 1 + tools/assistant/tools/assistant/helpviewer_qwv.cpp | 22 ++++++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 0c51a02..85e4e71 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -52,6 +52,10 @@ QT_BEGIN_NAMESPACE +QString AbstractHelpViewer::DocPath = QString::fromLatin1("qthelp://com." + "trolltech.qt.%1/").arg(QString(QLatin1String(QT_VERSION_STR)) + .replace(QLatin1String("."), QLatin1String(""))); + QString AbstractHelpViewer::AboutBlank = QCoreApplication::translate("HelpViewer", "about:blank"); diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 6f1f48d..9c3971f 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -67,6 +67,7 @@ public: virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0; + static QString DocPath; static QString AboutBlank; static QString LocalHelpFile; static QString PageNotFoundMessage; diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index db1cd58..a19b29a 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -129,13 +129,27 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, const QNetworkRequest &request, QIODevice* /*outgoingData*/) { TRACE_OBJ - const QUrl &url = request.url(); - const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url.toString()); - + QString url = request.url().toString(); HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + + // TODO: For some reason the url to load is already wrong (passed from webkit) + // though the css file and the references inside should work that way. One + // possible problem might be that the css is loaded at the same level as the + // html, thus a path inside the css like (../images/foo.png) might cd out of + // the virtual folder + if (!helpEngine.findFile(url).isValid()) { + if (url.startsWith(AbstractHelpViewer::DocPath)) { + if (!url.startsWith(AbstractHelpViewer::DocPath + QLatin1String("qdoc/"))) { + url = url.replace(AbstractHelpViewer::DocPath, + AbstractHelpViewer::DocPath + QLatin1String("qdoc/")); + } + } + } + + const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url); const QByteArray &data = helpEngine.findFile(url).isValid() ? helpEngine.fileData(url) - : AbstractHelpViewer::PageNotFoundMessage.arg(url.toString()).toUtf8(); + : AbstractHelpViewer::PageNotFoundMessage.arg(url).toUtf8(); return new HelpNetworkReply(request, data, mimeType.isEmpty() ? QLatin1String("application/octet-stream") : mimeType); } -- cgit v0.12