Commit f850326b authored by Jan Möbius's avatar Jan Möbius

Fixed help browser to correctly find resources in the virtual folder of the last opened document.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13970 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d91a6b75
......@@ -1076,7 +1076,7 @@ QHP_NAMESPACE = "org.openflipper.dev"
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = doc
QHP_VIRTUAL_FOLDER = dev
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
# add. For more information please see
......
......@@ -1079,7 +1079,7 @@ QHP_NAMESPACE = "org.openflipper.dev"
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = doc
QHP_VIRTUAL_FOLDER = dev
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
# add. For more information please see
......
......@@ -124,7 +124,7 @@ FULL_PATH_NAMES = YES
# If left blank the directory from which doxygen is run is used as the
# path to strip.
STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@
STRIP_FROM_PATH =
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
......@@ -133,7 +133,7 @@ STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@
# definition is used. Otherwise one should specify the include paths that
# are normally passed to the compiler using the -I flag.
STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@/
STRIP_FROM_INC_PATH =
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
......@@ -543,7 +543,7 @@ WARNINGS = YES
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = YES
WARN_IF_UNDOCUMENTED = NO
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some
......@@ -713,7 +713,7 @@ EXAMPLE_RECURSIVE = NO
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH = @CMAKE_SOURCE_DIR@/Plugin-@plugin@/userDoc/images
IMAGE_PATH = @CMAKE_SOURCE_DIR@/Plugin-@plugin@/userDoc/images/
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
......@@ -971,7 +971,7 @@ QCH_FILE = @plugin_qt_help_dir@/Plugin-@plugin@.qch
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#namespace
QHP_NAMESPACE = "org.openflipper.user.@plugin@"
QHP_NAMESPACE = "org.openflipper.Plugin-@plugin@"
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
......@@ -1356,7 +1356,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED =
PREDEFINED = QTHELP=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
......
......@@ -976,7 +976,7 @@ QHP_NAMESPACE = "org.openflipper.user"
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = "doc"
QHP_VIRTUAL_FOLDER = "user"
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
# For more information please see
......
......@@ -977,7 +977,7 @@ QHP_NAMESPACE = "org.openflipper.user"
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
QHP_VIRTUAL_FOLDER = "doc"
QHP_VIRTUAL_FOLDER = "user"
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
# For more information please see
......
......@@ -51,11 +51,13 @@
#include <iostream>
HelpBrowser::HelpBrowser(QHelpEngine* _helpEngine, QWidget* parent) :
QTextBrowser(parent),
helpEngine_(_helpEngine) {
helpEngine_(_helpEngine),
currentVirtualFolder_(""),
currentNameSpace_("")
{
currentPage_ = 0;
......@@ -72,65 +74,33 @@ QVariant HelpBrowser::loadResource (int /*_type*/, const QUrl& _url) {
if (_url.scheme() == "qthelp") {
return QVariant(helpEngine_->fileData(_url));
}
else if (_url.toString().contains("../../")) {
// Relative link
// So convert into qthelp-link
QStringList list = _url.toString().split("/");
// Extract the global virtual folder from this link
QString link = _url.toString();
QString base = "";
QStringList linkParts = link.split("/");
for(int i = 0; i < list.size(); i++) {
if(list[i].toLower().contains("plugin")) {
base = list[i].toLower();
break;
}
if ( linkParts.size() > 3) {
currentNameSpace_ = linkParts[2];
currentVirtualFolder_ = linkParts[3];
} else {
currentNameSpace_ = "";
currentVirtualFolder_ = "";
std::cerr << "Unable to detect virtual folder or namespace of this link" << _url.toString().toStdString() << std::endl;
}
if(base != "") {
// Build new link
QStringList docDomains = helpEngine_->registeredDocumentations();
QString newUrl = "qthelp://";
// This gives org.openflipper
newUrl += docDomains[0].split(".")[0] + "." + docDomains[0].split(".")[1];
newUrl += "." + base + "/doc/" + list.last();
if((helpEngine_->findFile(newUrl)).isValid()) {
return QVariant(helpEngine_->fileData(_url));
} else {
return QVariant(helpEngine_->fileData(newUrl));
}
const QString sNewUrl = "qthelp://" + currentNameSpace_ + "/" + currentVirtualFolder_ + "/" + _url.toString();
const QUrl newUrl = helpEngine_->findFile(QUrl(sNewUrl));
if(newUrl.isValid())
return QVariant(helpEngine_->fileData(newUrl));
else {
std::cerr << "Unable to find file at url : " << sNewUrl.toStdString() << std::endl;
return QVariant();
}
return QVariant();
}
else {
QUrl newUrl;
QStringList docDomains = helpEngine_->registeredDocumentations();
// Search in all namespaces for requested file
for(int i = 0; i < docDomains.size(); i++) {
QString sNewUrl = "qthelp://" + docDomains[i] + "/" + VIRTUAL_FOLDER +
"/" + _url.toString();
newUrl = helpEngine_->findFile(QUrl(sNewUrl));
if(newUrl.isValid()) return QVariant(helpEngine_->fileData(newUrl));
}
// If file has not been found in any of the namespaces
// return an empty QVariant
return QVariant();
}
}
......
......@@ -51,8 +51,6 @@
#ifndef HELPBROWSER_HH_
#define HELPBROWSER_HH_
#define VIRTUAL_FOLDER "doc"
#include <QtGui>
#include <QTextBrowser>
#include <QtHelp>
......@@ -97,6 +95,9 @@ private:
QStringList visitedPages_;
int currentPage_;
QString currentVirtualFolder_;
QString currentNameSpace_;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment