Commit c1e001a5 authored by Mike Kremer's avatar Mike Kremer

Refactored namespace handling within help system such that each help module...

Refactored namespace handling within help system such that each help module (identified by a .qch file) is registered under a unique namespace under the overall common virtual folder "doc".

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5741 383ad7c9-94d9-4d36-a494-682f7c89f535
parent eaaf6abf
......@@ -45,8 +45,6 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QtHelp>
//== IMPLEMENTATION ==========================================================
......@@ -57,8 +55,7 @@ void CoreWidget::showHelpBrowser( ) {
return;
if(helpWidget_ == 0)
helpWidget_ = new HelpWidget(this, "qthelp://doc.openflipper.dev/openflipper-1.0-dev/main.html",
"qthelp://doc.openflipper.dev/openflipper-1.0-dev/");
helpWidget_ = new HelpWidget(this, "qthelp://org.openflipper.dev/doc/main.html");
helpWidget_->show();
......
......@@ -10,11 +10,10 @@
#include <iostream>
HelpBrowser::HelpBrowser(QHelpEngine* _helpEngine, const QUrl& _basePath, QWidget* parent) :
HelpBrowser::HelpBrowser(QHelpEngine* _helpEngine, QWidget* parent) :
QTextBrowser(parent),
helpEngine_(_helpEngine),
basePath_(_basePath) {
helpEngine_(_helpEngine) {
currentPage_ = 0;
......@@ -35,10 +34,24 @@ QVariant HelpBrowser::loadResource (int /*_type*/, const QUrl& _url) {
}
else {
// Set basePath_ as prefix of resource file
QUrl newUrl = QUrl(basePath_.toString() + _url.toString());
QUrl newUrl;
return QVariant(helpEngine_->fileData(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();
}
}
......
......@@ -8,6 +8,8 @@
#ifndef HELPBROWSER_HH_
#define HELPBROWSER_HH_
#define VIRTUAL_FOLDER "doc"
#include <QtGui>
#include <QTextBrowser>
#include <QtHelp>
......@@ -16,7 +18,7 @@ class HelpBrowser : public QTextBrowser {
Q_OBJECT
public:
HelpBrowser(QHelpEngine* _helpEngine, const QUrl& _basePath, QWidget* parent = 0);
HelpBrowser(QHelpEngine* _helpEngine, QWidget* parent = 0);
virtual ~HelpBrowser();
......@@ -52,8 +54,6 @@ private:
QStringList visitedPages_;
int currentPage_;
QUrl basePath_;
};
......
......@@ -13,7 +13,7 @@
#include <QTextStream>
HelpWidget::HelpWidget(QWidget* parent, const QString& _homeSite, const QString& _baseURL)
HelpWidget::HelpWidget(QWidget* parent, const QString& _homeSite)
: QMainWindow(parent),
searchWidget_(0),
tabWidget_(0),
......@@ -52,7 +52,7 @@ HelpWidget::HelpWidget(QWidget* parent, const QString& _homeSite, const QString&
searchEngine_ = new QHelpSearchEngine(helpEngine_, this);
textWindow_ = new HelpBrowser(helpEngine_, _baseURL, this);
textWindow_ = new HelpBrowser(helpEngine_, this);
homeIndex_ = tabWidget_->addTab(textWindow_, "Home");
......
......@@ -27,7 +27,7 @@ class HelpWidget : public QMainWindow, public Ui::HelpWidget
public:
HelpWidget(QWidget* parent = 0, const QString& _homeSite = "", const QString& _baseURL = "");
HelpWidget(QWidget* parent = 0, const QString& _homeSite = "");
virtual ~HelpWidget();
......
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