summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-06-11 13:11:37 +0200
committerkh1 <qt-info@nokia.com>2010-06-11 13:11:37 +0200
commit1b6ad087950ca0753f9e17016b618bc6656004af (patch)
tree3f04a59717d3f5ab80e4c6fd74a71d8d29e8e693
parent40b983a91b306c3f21e2b973b8b63f1b913e26c2 (diff)
downloadqt-creator-1b6ad087950ca0753f9e17016b618bc6656004af.tar.gz
Move help manager into core.
- lessens open file handles - improves help plugin startup further Task-number: QTCREATORBUG-337 Reviewed-by: ck
-rw-r--r--src/plugins/coreplugin/coreimpl.cpp5
-rw-r--r--src/plugins/coreplugin/coreimpl.h1
-rw-r--r--src/plugins/coreplugin/coreplugin.pro7
-rw-r--r--src/plugins/coreplugin/helpmanager.cpp321
-rw-r--r--src/plugins/coreplugin/helpmanager.h96
-rw-r--r--src/plugins/coreplugin/icore.h2
-rw-r--r--src/plugins/coreplugin/mainwindow.cpp10
-rw-r--r--src/plugins/coreplugin/mainwindow.h3
-rw-r--r--src/plugins/cppeditor/cppeditor.pro1
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.cpp30
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.h3
-rw-r--r--src/plugins/designer/formeditorw.cpp11
-rw-r--r--src/plugins/designer/qtcreatorintegration.cpp4
-rw-r--r--src/plugins/designer/qtcreatorintegration.h4
-rw-r--r--src/plugins/help/centralwidget.cpp5
-rw-r--r--src/plugins/help/docsettingspage.cpp29
-rw-r--r--src/plugins/help/docsettingspage.h3
-rw-r--r--src/plugins/help/filtersettingspage.cpp17
-rw-r--r--src/plugins/help/filtersettingspage.h6
-rw-r--r--src/plugins/help/generalsettingspage.cpp12
-rw-r--r--src/plugins/help/helpindexfilter.cpp187
-rw-r--r--src/plugins/help/helpindexfilter.h8
-rw-r--r--src/plugins/help/helpmanager.cpp140
-rw-r--r--src/plugins/help/helpmanager.h48
-rw-r--r--src/plugins/help/helpplugin.cpp106
-rw-r--r--src/plugins/help/helpplugin.h5
-rw-r--r--src/plugins/help/helpviewer.cpp6
-rw-r--r--src/plugins/help/helpviewer_qwv.cpp6
-rw-r--r--src/plugins/help/openpagesmanager.cpp4
-rw-r--r--src/plugins/help/searchwidget.cpp4
-rw-r--r--src/plugins/plugins.pro1
-rw-r--r--src/plugins/qmljseditor/qmljseditor.pro1
-rw-r--r--src/plugins/qmljseditor/qmljshoverhandler.cpp27
-rw-r--r--src/plugins/qmljseditor/qmljshoverhandler.h3
-rw-r--r--src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec1
-rw-r--r--src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp9
-rw-r--r--src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri1
-rw-r--r--src/plugins/qt4projectmanager/qtversionmanager.cpp4
-rw-r--r--src/shared/help/bookmarkmanager.cpp7
-rw-r--r--src/shared/help/contentwindow.cpp2
-rw-r--r--src/shared/help/indexwindow.cpp2
41 files changed, 622 insertions, 520 deletions
diff --git a/src/plugins/coreplugin/coreimpl.cpp b/src/plugins/coreplugin/coreimpl.cpp
index d072e8df09..99d76f3539 100644
--- a/src/plugins/coreplugin/coreimpl.cpp
+++ b/src/plugins/coreplugin/coreimpl.cpp
@@ -144,6 +144,11 @@ MimeDatabase *CoreImpl::mimeDatabase() const
return m_mainwindow->mimeDatabase();
}
+HelpManager *CoreImpl::helpManager() const
+{
+ return m_mainwindow->helpManager();
+}
+
QSettings *CoreImpl::settings(QSettings::Scope scope) const
{
return m_mainwindow->settings(scope);
diff --git a/src/plugins/coreplugin/coreimpl.h b/src/plugins/coreplugin/coreimpl.h
index 50a8a673fb..efd971f3b6 100644
--- a/src/plugins/coreplugin/coreimpl.h
+++ b/src/plugins/coreplugin/coreimpl.h
@@ -67,6 +67,7 @@ public:
VCSManager *vcsManager() const;
ModeManager *modeManager() const;
MimeDatabase *mimeDatabase() const;
+ HelpManager *helpManager() const;
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
SettingsDatabase *settingsDatabase() const;
diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro
index d5b3064713..3b607d037b 100644
--- a/src/plugins/coreplugin/coreplugin.pro
+++ b/src/plugins/coreplugin/coreplugin.pro
@@ -6,6 +6,7 @@ QT += xml \
script \
svg \
sql
+CONFIG += help
include(../../qtcreatorplugin.pri)
include(../../libs/utils/utils.pri)
include(../../shared/scriptwrapper/scriptwrapper.pri)
@@ -86,7 +87,8 @@ SOURCES += mainwindow.cpp \
editortoolbar.cpp \
ssh/ne7sshobject.cpp \
ssh/sshconnection.cpp \
- ssh/sshkeygenerator.cpp
+ ssh/sshkeygenerator.cpp \
+ helpmanager.cpp
HEADERS += mainwindow.h \
editmode.h \
@@ -171,7 +173,8 @@ HEADERS += mainwindow.h \
editortoolbar.h \
ssh/ne7sshobject.h \
ssh/sshconnection.h \
- ssh/sshkeygenerator.h
+ ssh/sshkeygenerator.h \
+ helpmanager.h
FORMS += dialogs/newdialog.ui \
actionmanager/commandmappings.ui \
diff --git a/src/plugins/coreplugin/helpmanager.cpp b/src/plugins/coreplugin/helpmanager.cpp
new file mode 100644
index 0000000000..85cf89a1a5
--- /dev/null
+++ b/src/plugins/coreplugin/helpmanager.cpp
@@ -0,0 +1,321 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "helpmanager.h"
+
+#include "icore.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QStringList>
+
+#include <QtHelp/QHelpEngineCore>
+
+#include <QtSql/QSqlDatabase>
+#include <QtSql/QSqlDriver>
+#include <QtSql/QSqlError>
+#include <QtSql/QSqlQuery>
+
+namespace Core {
+
+HelpManager *HelpManager::m_instance = 0;
+
+static const char linksForKeyQuery[] = "SELECT d.Title, f.Name, e.Name, "
+ "d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
+ "NamespaceTable f WHERE a.FileId=d.FileId AND d.FolderId=e.Id AND "
+ "a.NamespaceId=f.Id AND a.Name='%1'";
+
+// -- DbCleaner
+
+struct DbCleaner {
+ DbCleaner(const QString &dbName)
+ : name(dbName) {}
+ ~DbCleaner() {
+ QSqlDatabase::removeDatabase(name);
+ }
+ QString name;
+};
+
+// -- HelpManager
+
+HelpManager::HelpManager(QObject *parent)
+ : QObject(parent)
+ , m_needsSetup(true)
+ , m_helpEngine(0)
+{
+ Q_ASSERT(!m_instance);
+ m_instance = this;
+
+ connect(Core::ICore::instance(), SIGNAL(coreOpened()), this,
+ SLOT(setupHelpManager()));
+}
+
+HelpManager::~HelpManager()
+{
+ delete m_helpEngine;
+ m_helpEngine = 0;
+
+ m_instance = 0;
+}
+
+HelpManager* HelpManager::instance()
+{
+ Q_ASSERT(m_instance);
+ return m_instance;
+}
+
+QString HelpManager::collectionFilePath()
+{
+ const QFileInfo fi(Core::ICore::instance()->settings()->fileName());
+ const QDir directory(fi.absolutePath() + QLatin1String("/qtcreator"));
+ if (!directory.exists())
+ directory.mkpath(directory.absolutePath());
+ return QDir::cleanPath(directory.absolutePath() + QLatin1String("/helpcollection.qhc"));
+}
+
+void HelpManager::registerDocumentation(const QStringList &files)
+{
+ if (m_needsSetup) {
+ m_filesToRegister.append(files);
+ return;
+ }
+
+ bool docsChanged = false;
+ foreach (const QString &file, files) {
+ const QString &nameSpace = m_helpEngine->namespaceName(file);
+ if (nameSpace.isEmpty())
+ continue;
+ if (!m_helpEngine->registeredDocumentations().contains(nameSpace)) {
+ if (m_helpEngine->registerDocumentation(file)) {
+ docsChanged = true;
+ } else {
+ qWarning() << "Error registering namespace '" << nameSpace
+ << "' from file '" << file << "':" << m_helpEngine->error();
+ }
+ }
+ }
+ if (docsChanged)
+ emit documentationChanged();
+}
+
+void HelpManager::unregisterDocumentation(const QStringList &nameSpaces)
+{
+ if (m_needsSetup) {
+ m_nameSpacesToUnregister.append(nameSpaces);
+ return;
+ }
+
+ bool docsChanged = false;
+ foreach (const QString &nameSpace, nameSpaces) {
+ if (m_helpEngine->unregisterDocumentation(nameSpace)) {
+ docsChanged = true;
+ } else {
+ qWarning() << "Error unregistering namespace '" << nameSpace
+ << "' from file '" << m_helpEngine->documentationFileName(nameSpace)
+ << "': " << m_helpEngine->error();
+ }
+ }
+ if (docsChanged)
+ emit documentationChanged();
+}
+
+QUrl buildQUrl(const QString &nameSpace, const QString &folder,
+ const QString &relFileName, const QString &anchor)
+{
+ QUrl url;
+ url.setScheme(QLatin1String("qthelp"));
+ url.setAuthority(nameSpace);
+ url.setPath(folder + QLatin1Char('/') + relFileName);
+ url.setFragment(anchor);
+ return url;
+}
+
+// This should go into Qt 4.8 once we start using it for Qt Creator
+QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) const
+{
+ QMap<QString, QUrl> links;
+ if (m_needsSetup)
+ return links;
+
+ const QLatin1String sqlite("QSQLITE");
+ const QLatin1String name("HelpManager::linksForKeyword");
+
+ DbCleaner cleaner(name);
+ QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
+ if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
+ const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
+ foreach (const QString &nameSpace, registeredDocs) {
+ db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
+ if (db.open()) {
+ QSqlQuery query = QSqlQuery(db);
+ query.setForwardOnly(true);
+ query.exec(QString::fromLatin1(linksForKeyQuery).arg(key));
+ while (query.next()) {
+ QString title = query.value(0).toString();
+ if (title.isEmpty()) // generate a title + corresponding path
+ title = key + QLatin1String(" : ") + query.value(3).toString();
+ links.insertMulti(title, buildQUrl(query.value(1).toString(),
+ query.value(2).toString(), query.value(3).toString(),
+ query.value(4).toString()));
+ }
+ }
+ }
+ }
+ return links;
+}
+
+QMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id) const
+{
+ if (m_needsSetup)
+ return QMap<QString, QUrl>();
+ return m_helpEngine->linksForIdentifier(id);
+}
+
+// This should go into Qt 4.8 once we start using it for Qt Creator
+QStringList HelpManager::findKeywords(const QString &key, int maxHits) const
+{
+ QStringList keywords;
+ if (m_needsSetup)
+ return keywords;
+
+ const QLatin1String sqlite("QSQLITE");
+ const QLatin1String name("HelpManager::findKeywords");
+
+ DbCleaner cleaner(name);
+ QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
+ if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
+ const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
+ foreach (const QString &nameSpace, registeredDocs) {
+ db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
+ if (db.open()) {
+ QSqlQuery query = QSqlQuery(db);
+ query.setForwardOnly(true);
+ query.exec(QString::fromLatin1("SELECT DISTINCT Name FROM "
+ "IndexTable WHERE Name LIKE '%%1%'").arg(key));
+ while (query.next()) {
+ const QString &key = query.value(0).toString();
+ if (!key.isEmpty()) {
+ keywords.append(key);
+ if (keywords.count() == maxHits)
+ return keywords;
+ }
+ }
+ }
+ }
+ }
+ return keywords;
+}
+
+QUrl HelpManager::findFile(const QUrl &url) const
+{
+ if (m_needsSetup)
+ return QUrl();
+ return m_helpEngine->findFile(url);
+}
+
+void HelpManager::handleHelpRequest(const QString &url)
+{
+ emit helpRequested(QUrl(url));
+}
+
+QStringList HelpManager::registeredNamespaces() const
+{
+ if (m_needsSetup)
+ return QStringList();
+ return m_helpEngine->registeredDocumentations();
+}
+
+QString HelpManager::namespaceFromFile(const QString &file) const
+{
+ if (m_needsSetup)
+ return QString();
+ return m_helpEngine->namespaceName(file);
+}
+
+QString HelpManager::fileFromNamespace(const QString &nameSpace) const
+{
+ if (m_needsSetup)
+ return QString();
+ return m_helpEngine->documentationFileName(nameSpace);
+}
+
+// -- private slots
+
+void HelpManager::setupHelpManager()
+{
+ if (!m_needsSetup)
+ return;
+ m_needsSetup = false;
+
+ m_helpEngine = new QHelpEngineCore(collectionFilePath(), this);
+ m_helpEngine->setAutoSaveFilter(false);
+ m_helpEngine->setCurrentFilter(tr("Unfiltered"));
+ m_helpEngine->setupData();
+
+ verifyDocumenation();
+
+ if (!m_nameSpacesToUnregister.isEmpty()) {
+ unregisterDocumentation(m_nameSpacesToUnregister);
+ m_nameSpacesToUnregister.clear();
+ }
+
+ // this might come from the installer
+ const QLatin1String key("AddedDocs");
+ const QString &addedDocs = m_helpEngine->customValue(key).toString();
+ if (!addedDocs.isEmpty()) {
+ m_helpEngine->removeCustomValue(key);
+ m_filesToRegister += addedDocs.split(QLatin1Char(';'));
+ }
+
+ if (!m_filesToRegister.isEmpty()) {
+ registerDocumentation(m_filesToRegister);
+ m_filesToRegister.clear();
+ }
+
+ emit setupFinished();
+}
+
+// -- private
+
+void HelpManager::verifyDocumenation()
+{
+ QStringList nameSpacesToUnregister;
+ const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
+ foreach (const QString &nameSpace, registeredDocs) {
+ const QString &file = m_helpEngine->documentationFileName(nameSpace);
+ if (!QFileInfo(file).exists())
+ nameSpacesToUnregister.append(nameSpace);
+ }
+
+ if (!nameSpacesToUnregister.isEmpty())
+ unregisterDocumentation(nameSpacesToUnregister);
+}
+
+} // Core
diff --git a/src/plugins/coreplugin/helpmanager.h b/src/plugins/coreplugin/helpmanager.h
new file mode 100644
index 0000000000..7df6c55659
--- /dev/null
+++ b/src/plugins/coreplugin/helpmanager.h
@@ -0,0 +1,96 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef HELPMANAGER_H
+#define HELPMANAGER_H
+
+#include "core_global.h"
+
+#include <QtCore/QMap>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+#include <QtCore/QVariant>
+
+QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
+QT_FORWARD_DECLARE_CLASS(QSqlQuery)
+
+namespace Core {
+
+class CORE_EXPORT HelpManager : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HelpManager)
+
+public:
+ explicit HelpManager(QObject *parent = 0);
+ virtual ~HelpManager();
+
+ static HelpManager* instance();
+ static QString collectionFilePath();
+
+ void registerDocumentation(const QStringList &fileNames);
+ void unregisterDocumentation(const QStringList &nameSpaces);
+
+ QMap<QString, QUrl> linksForKeyword(const QString &key) const;
+ QMap<QString, QUrl> linksForIdentifier(const QString &id) const;
+ QStringList findKeywords(const QString &key, int maxHits = INT_MAX) const;
+
+ QUrl findFile(const QUrl &url) const;
+ void handleHelpRequest(const QString &url);
+
+ QStringList registeredNamespaces() const;
+ QString namespaceFromFile(const QString &file) const;
+ QString fileFromNamespace(const QString &nameSpace) const;
+
+signals:
+ void setupFinished();
+ void documentationChanged();
+ void helpRequested(const QUrl &url);
+
+private slots:
+ void setupHelpManager();
+
+private:
+ void verifyDocumenation();
+
+private:
+ bool m_needsSetup;
+ QHelpEngineCore *m_helpEngine;
+
+ QStringList m_filesToRegister;
+ QStringList m_nameSpacesToUnregister;
+
+ static HelpManager *m_instance;
+};
+
+} // Core
+
+#endif // HELPMANAGER_H
diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h
index cae3da1b4d..4eb3c89718 100644
--- a/src/plugins/coreplugin/icore.h
+++ b/src/plugins/coreplugin/icore.h
@@ -50,6 +50,7 @@ namespace Core {
class ActionManager;
class EditorManager;
class FileManager;
+class HelpManager;
class IContext;
class MessageManager;
class MimeDatabase;
@@ -96,6 +97,7 @@ public:
virtual VCSManager *vcsManager() const = 0;
virtual ModeManager *modeManager() const = 0;
virtual MimeDatabase *mimeDatabase() const = 0;
+ virtual HelpManager *helpManager() const = 0;
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
virtual SettingsDatabase *settingsDatabase() const = 0;
diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp
index ed1d48afb8..1555395c74 100644
--- a/src/plugins/coreplugin/mainwindow.cpp
+++ b/src/plugins/coreplugin/mainwindow.cpp
@@ -37,6 +37,7 @@
#include "fancytabwidget.h"
#include "filemanager.h"
#include "generalsettings.h"
+#include "helpmanager.h"
#include "ifilefactory.h"
#include "messagemanager.h"
#include "modemanager.h"
@@ -132,6 +133,7 @@ MainWindow::MainWindow() :
m_statusBarManager(0),
m_modeManager(0),
m_mimeDatabase(new MimeDatabase),
+ m_helpManager(new HelpManager),
m_navigationWidget(0),
m_rightPaneWidget(0),
m_versionDialog(0),
@@ -288,6 +290,9 @@ MainWindow::~MainWindow()
m_modeManager = 0;
delete m_mimeDatabase;
m_mimeDatabase = 0;
+
+ delete m_helpManager;
+ m_helpManager = 0;
}
bool MainWindow::init(QString *errorMessage)
@@ -1011,6 +1016,11 @@ MimeDatabase *MainWindow::mimeDatabase() const
return m_mimeDatabase;
}
+HelpManager *MainWindow::helpManager() const
+{
+ return m_helpManager;
+}
+
IContext *MainWindow::contextObject(QWidget *widget)
{
return m_contextWidgets.value(widget);
diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h
index 60b911ba1d..3b890439b0 100644
--- a/src/plugins/coreplugin/mainwindow.h
+++ b/src/plugins/coreplugin/mainwindow.h
@@ -52,6 +52,7 @@ class ActionManager;
class StatusBarWidget;
class EditorManager;
class FileManager;
+class HelpManager;
class IContext;
class IWizard;
class MessageManager;
@@ -107,6 +108,7 @@ public:
Core::VariableManager *variableManager() const;
Core::ModeManager *modeManager() const;
Core::MimeDatabase *mimeDatabase() const;
+ Core::HelpManager *helpManager() const;
VCSManager *vcsManager() const;
QSettings *settings(QSettings::Scope scope) const;
@@ -193,6 +195,7 @@ private:
StatusBarManager *m_statusBarManager;
ModeManager *m_modeManager;
MimeDatabase *m_mimeDatabase;
+ HelpManager *m_helpManager;
FancyTabWidget *m_modeStack;
NavigationWidget *m_navigationWidget;
RightPaneWidget *m_rightPaneWidget;
diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro
index 13f532e57a..e9f4f0d0f4 100644
--- a/src/plugins/cppeditor/cppeditor.pro
+++ b/src/plugins/cppeditor/cppeditor.pro
@@ -1,7 +1,6 @@
TEMPLATE = lib
TARGET = CppEditor
DEFINES += CPPEDITOR_LIBRARY
-CONFIG += help
include(../../qtcreatorplugin.pri)
include(../../libs/utils/utils.pri)
include(../../shared/indenter/indenter.pri)
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp
index dabf25c791..2b691e6be9 100644
--- a/src/plugins/cppeditor/cpphoverhandler.cpp
+++ b/src/plugins/cppeditor/cpphoverhandler.cpp
@@ -32,6 +32,7 @@
#include "cppplugin.h"
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppmodelmanagerinterface.h>
@@ -60,7 +61,6 @@
#include <QtGui/QToolTip>
#include <QtGui/QTextCursor>
#include <QtGui/QTextBlock>
-#include <QtHelp/QHelpEngineCore>
using namespace CppEditor::Internal;
using namespace CPlusPlus;
@@ -68,27 +68,11 @@ using namespace Core;
CppHoverHandler::CppHoverHandler(QObject *parent)
: QObject(parent)
- , m_helpEngineNeedsSetup(false)
{
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
- ICore *core = ICore::instance();
- QFileInfo fi(core->settings()->fileName());
- // FIXME shouldn't the help engine create the directory if it doesn't exist?
- QDir directory(fi.absolutePath()+"/qtcreator");
- if (!directory.exists())
- directory.mkpath(directory.absolutePath());
-
- m_helpEngine = new QHelpEngineCore(directory.absolutePath()
- + QLatin1String("/helpcollection.qhc"), this);
- if (!m_helpEngine->setupData())
- qWarning() << "Could not initialize help engine:" << m_helpEngine->error();
- m_helpEngine->setAutoSaveFilter(false);
- m_helpEngine->setCurrentFilter(tr("Unfiltered"));
- m_helpEngineNeedsSetup = m_helpEngine->registeredDocumentations().count() == 0;
-
// Listen for editor opened events in order to connect to tooltip/helpid requests
- connect(core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
+ connect(ICore::instance()->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
this, SLOT(editorOpened(Core::IEditor *)));
}
@@ -297,19 +281,13 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
}
}
- if (m_helpEngineNeedsSetup
- && m_helpEngine->registeredDocumentations().count() > 0) {
- m_helpEngine->setupData();
- m_helpEngineNeedsSetup = false;
- }
QMap<QString, QUrl> helpLinks;
-
if (m_toolTip.isEmpty()) {
foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineNumber) {
m_toolTip = QDir::toNativeSeparators(incl.fileName());
m_helpId = QFileInfo(incl.fileName()).fileName();
- helpLinks = m_helpEngine->linksForIdentifier(m_helpId);
+ helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId);
break;
}
}
@@ -388,7 +366,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
// To show their help anyway, try stripping scopes until we find something.
const QString startHelpId = m_helpId;
while (!m_helpId.isEmpty()) {
- helpLinks = m_helpEngine->linksForIdentifier(m_helpId);
+ helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId);
if (!helpLinks.isEmpty())
break;
diff --git a/src/plugins/cppeditor/cpphoverhandler.h b/src/plugins/cppeditor/cpphoverhandler.h
index d0f5b11dc5..311b829223 100644
--- a/src/plugins/cppeditor/cpphoverhandler.h
+++ b/src/plugins/cppeditor/cpphoverhandler.h
@@ -33,7 +33,6 @@
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
-class QHelpEngineCore;
class QPoint;
QT_END_NAMESPACE
@@ -70,10 +69,8 @@ private:
void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos);
CppTools::CppModelManagerInterface *m_modelManager;
- QHelpEngineCore *m_helpEngine;
QString m_helpId;
QString m_toolTip;
- bool m_helpEngineNeedsSetup;
};
} // namespace Internal
diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp
index 7ac3100845..54779835b5 100644
--- a/src/plugins/designer/formeditorw.cpp
+++ b/src/plugins/designer/formeditorw.cpp
@@ -45,6 +45,7 @@
#include <coreplugin/designmode.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
@@ -282,14 +283,8 @@ void FormEditorW::fullInit()
m_integration = new QtCreatorIntegration(m_formeditor, this);
m_formeditor->setIntegration(m_integration);
// Connect Qt Designer help request to HelpManager.
- // TODO: Use Core::HelpManager once it has been introduced.
- foreach(QObject *object, ExtensionSystem::PluginManager::instance()->allObjects()) {
- if (!qstrcmp(object->metaObject()->className(), "Help::HelpManager")) {
- connect(m_integration, SIGNAL(creatorHelpRequested(QString)),
- object, SLOT(handleHelpRequest(QString)));
- break;
- }
- }
+ connect(m_integration, SIGNAL(creatorHelpRequested(QUrl)),
+ Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)));
/**
* This will initialize our TabOrder, Signals and slots and Buddy editors.
diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp
index e6439d71b7..4cc1e1140b 100644
--- a/src/plugins/designer/qtcreatorintegration.cpp
+++ b/src/plugins/designer/qtcreatorintegration.cpp
@@ -61,6 +61,7 @@
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
+#include <QtCore/QUrl>
enum { indentation = 4 };
@@ -101,7 +102,8 @@ QtCreatorIntegration::QtCreatorIntegration(QDesignerFormEditorInterface *core, F
void QtCreatorIntegration::slotDesignerHelpRequested(const QString &manual, const QString &document)
{
// Pass on as URL.
- emit creatorHelpRequested(QString::fromLatin1("qthelp://com.trolltech.%1/qdoc/%2").arg(manual, document));
+ emit creatorHelpRequested(QUrl(QString::fromLatin1("qthelp://com.trolltech.%1/qdoc/%2")
+ .arg(manual, document)));
}
void QtCreatorIntegration::updateSelection()
diff --git a/src/plugins/designer/qtcreatorintegration.h b/src/plugins/designer/qtcreatorintegration.h
index c667ea8504..a246a283c3 100644
--- a/src/plugins/designer/qtcreatorintegration.h
+++ b/src/plugins/designer/qtcreatorintegration.h
@@ -34,6 +34,8 @@
#include "qt_private/qdesigner_integration_p.h"
+QT_FORWARD_DECLARE_CLASS(QUrl)
+
namespace Designer {
namespace Internal {
@@ -49,7 +51,7 @@ public:
bool supportsToSlotNavigation() { return true; }
signals:
- void creatorHelpRequested(const QString &url);
+ void creatorHelpRequested(const QUrl &url);
public slots:
void updateSelection();
diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp
index d1f77bb557..9dbc069f37 100644
--- a/src/plugins/help/centralwidget.cpp
+++ b/src/plugins/help/centralwidget.cpp
@@ -45,7 +45,6 @@
#include <QtGui/QStackedWidget>
#include <QtHelp/QHelpEngine>
-#include <QtHelp/QHelpEngineCore>
#include <QtHelp/QHelpSearchEngine>
using namespace Help::Internal;
@@ -85,7 +84,7 @@ CentralWidget::~CentralWidget()
}
}
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
+ QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
@@ -314,7 +313,7 @@ void CentralWidget::highlightSearchTerms()
{
if (HelpViewer *viewer = currentHelpViewer()) {
QHelpSearchEngine *searchEngine =
- HelpManager::instance().helpEngine().searchEngine();
+ LocalHelpManager::helpEngine().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query();
QStringList terms;
diff --git a/src/plugins/help/docsettingspage.cpp b/src/plugins/help/docsettingspage.cpp
index 4933f53dd4..a860446ba5 100644
--- a/src/plugins/help/docsettingspage.cpp
+++ b/src/plugins/help/docsettingspage.cpp
@@ -29,7 +29,8 @@
#include "docsettingspage.h"
#include "helpconstants.h"
-#include "helpmanager.h"
+
+#include <coreplugin/helpmanager.h>
#include <QtCore/QCoreApplication>
@@ -37,8 +38,6 @@
#include <QtGui/QKeyEvent>
#include <QtGui/QMessageBox>
-#include <QtHelp/QHelpEngineCore>
-
using namespace Help::Internal;
DocSettingsPage::DocSettingsPage()
@@ -80,10 +79,10 @@ QWidget *DocSettingsPage::createPage(QWidget *parent)
m_ui.docsListWidget->installEventFilter(this);
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
- const QStringList &nameSpaces = engine->registeredDocumentations();
+ Core::HelpManager *manager = Core::HelpManager::instance();
+ const QStringList &nameSpaces = manager->registeredNamespaces();
foreach (const QString &nameSpace, nameSpaces)
- addItem(nameSpace, engine->documentationFileName(nameSpace));
+ addItem(nameSpace, manager->fileFromNamespace(nameSpace));
m_filesToRegister.clear();
m_filesToUnregister.clear();
@@ -103,11 +102,11 @@ void DocSettingsPage::addDocumentation()
return;
m_recentDialogPath = QFileInfo(files.first()).canonicalPath();
- const QHelpEngineCore &engine = HelpManager::helpEngineCore();
- const QStringList &nameSpaces = engine.registeredDocumentations();
+ Core::HelpManager *manager = Core::HelpManager::instance();
+ const QStringList &nameSpaces = manager->registeredNamespaces();
foreach (const QString &file, files) {
- const QString &nameSpace = engine.namespaceName(file);
+ const QString &nameSpace = manager->namespaceFromFile(file);
if (nameSpace.isEmpty())
continue;
@@ -130,14 +129,10 @@ void DocSettingsPage::removeDocumentation()
void DocSettingsPage::apply()
{
- HelpManager* manager = &HelpManager::instance();
+ Core::HelpManager *manager = Core::HelpManager::instance();
+
manager->unregisterDocumentation(m_filesToUnregister.keys());
manager->registerDocumentation(m_filesToRegister.values());
- if (manager->guiEngineNeedsUpdate()) {
- // emit this signal to the help plugin, since we don't want
- // to force gui help engine setup if we are not in help mode
- emit documentationChanged();
- }
m_filesToRegister.clear();
m_filesToUnregister.clear();
@@ -172,10 +167,10 @@ void DocSettingsPage::removeDocumentation(const QList<QListWidgetItem*> items)
return;
int row = 0;
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
+ Core::HelpManager *manager = Core::HelpManager::instance();
foreach (QListWidgetItem* item, items) {
const QString &nameSpace = item->text();
- const QString &docPath = engine->documentationFileName(nameSpace);
+ const QString &docPath = manager->fileFromNamespace(nameSpace);
if (m_filesToRegister.value(nameSpace) != docPath) {
if (!m_filesToUnregister.contains(nameSpace))
diff --git a/src/plugins/help/docsettingspage.h b/src/plugins/help/docsettingspage.h
index 66de3ac8ae..7d292b2fee 100644
--- a/src/plugins/help/docsettingspage.h
+++ b/src/plugins/help/docsettingspage.h
@@ -55,9 +55,6 @@ public:
void finish() {}
virtual bool matches(const QString &s) const;
-signals:
- void documentationChanged();
-
private slots:
void addDocumentation();
void removeDocumentation();
diff --git a/src/plugins/help/filtersettingspage.cpp b/src/plugins/help/filtersettingspage.cpp
index ed27e455d1..ccdde31a26 100644
--- a/src/plugins/help/filtersettingspage.cpp
+++ b/src/plugins/help/filtersettingspage.cpp
@@ -33,16 +33,19 @@
#include "helpconstants.h"
#include "helpmanager.h"
+#include <coreplugin/helpmanager.h>
+
#include <QtCore/QCoreApplication>
#include <QtGui/QFileDialog>
#include <QtGui/QMessageBox>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
using namespace Help::Internal;
FilterSettingsPage::FilterSettingsPage()
+ : m_helpManager(0)
{
}
@@ -76,6 +79,7 @@ QWidget *FilterSettingsPage::createPage(QWidget *parent)
QWidget *widget = new QWidget(parent);
m_ui.setupUi(widget);
+ m_helpManager->setupGuiHelpEngine();
updateFilterPage(); // does call setupData on the engine
connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
@@ -86,6 +90,8 @@ QWidget *FilterSettingsPage::createPage(QWidget *parent)
connect(m_ui.filterAddButton, SIGNAL(clicked()), this, SLOT(addFilter()));
connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this,
SLOT(removeFilter()));
+ connect(Core::HelpManager::instance(), SIGNAL(documentationChanged()),
+ this, SLOT(updateFilterPage()));
if (m_searchKeywords.isEmpty()) {
m_searchKeywords = m_ui.filterGroupBox->title() + QLatin1Char(' ')
@@ -100,7 +106,7 @@ void FilterSettingsPage::updateFilterPage()
m_ui.attributeWidget->clear();
m_filterMapBackup.clear();
- const QHelpEngineCore &engine = HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
const QStringList &filters = engine.customFilters();
foreach (const QString &filter, filters) {
const QStringList &attributes = engine.filterAttributes(filter);
@@ -210,7 +216,7 @@ void FilterSettingsPage::apply()
}
if (changed) {
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
+ QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
foreach (const QString &filter, m_removedFilters)
engine->removeCustomFilter(filter);
@@ -228,3 +234,8 @@ bool FilterSettingsPage::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
+
+void FilterSettingsPage::setHelpManager(LocalHelpManager *manager)
+{
+ m_helpManager = manager;
+}
diff --git a/src/plugins/help/filtersettingspage.h b/src/plugins/help/filtersettingspage.h
index b8f74d5359..96b2a57778 100644
--- a/src/plugins/help/filtersettingspage.h
+++ b/src/plugins/help/filtersettingspage.h
@@ -36,6 +36,8 @@
namespace Help {
namespace Internal {
+class LocalHelpManager;
+
class FilterSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
@@ -55,6 +57,8 @@ public:
void finish() {}
virtual bool matches(const QString &s) const;
+ void setHelpManager(LocalHelpManager *manager);
+
signals:
void filtersChanged();
@@ -73,6 +77,8 @@ private:
QString m_searchKeywords;
QStringList m_removedFilters;
+
+ LocalHelpManager *m_helpManager;
};
} // namespace Help
diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp
index edc20b511b..2703f9a810 100644
--- a/src/plugins/help/generalsettingspage.cpp
+++ b/src/plugins/help/generalsettingspage.cpp
@@ -44,7 +44,7 @@
#include <QtGui/QApplication>
#include <QtGui/QFileDialog>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
#if !defined(QT_NO_WEBKIT)
#include <QtWebKit/QWebSettings>
@@ -94,7 +94,7 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
m_ui.sizeComboBox->setEditable(false);
m_ui.styleComboBox->setEditable(false);
- const QHelpEngineCore &engine = HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
m_font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"), m_font));
updateFontSize();
@@ -163,7 +163,7 @@ void GeneralSettingsPage::apply()
if (weight >= 0) // Weight < 0 asserts...
newFont.setWeight(weight);
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
+ QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
engine->setCustomValue(QLatin1String("font"), newFont);
if (newFont != m_font)
@@ -197,7 +197,7 @@ void GeneralSettingsPage::setBlankPage()
void GeneralSettingsPage::setDefaultPage()
{
- const QString &defaultHomePage = HelpManager::helpEngineCore()
+ const QString &defaultHomePage = LocalHelpManager::helpEngine()
.customValue(QLatin1String("DefaultHomePage"), QString()).toString();
m_ui.homePageLineEdit->setText(defaultHomePage);
}
@@ -214,7 +214,7 @@ void GeneralSettingsPage::importBookmarks()
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
- const BookmarkManager &manager = HelpManager::bookmarkManager();
+ const BookmarkManager &manager = LocalHelpManager::bookmarkManager();
XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel());
if (reader.readFromFile(&file))
return;
@@ -237,7 +237,7 @@ void GeneralSettingsPage::exportBookmarks()
QFile file(fileName);
if (file.open(QIODevice::WriteOnly)) {
- XbelWriter writer(HelpManager::bookmarkManager().treeBookmarkModel());
+ XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
writer.writeToFile(&file);
}
}
diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp
index ff148efade..411d823691 100644
--- a/src/plugins/help/helpindexfilter.cpp
+++ b/src/plugins/help/helpindexfilter.cpp
@@ -28,197 +28,28 @@
**************************************************************************/
#include "helpindexfilter.h"
-#include "helpmanager.h"
#include <extensionsystem/pluginmanager.h>
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <QtGui/QIcon>
-#include <QtHelp/QHelpEngine>
-#include <QtHelp/QHelpIndexModel>
-
-#include <QtSql/QSqlDatabase>
-#include <QtSql/QSqlDriver>
-#include <QtSql/QSqlError>
-#include <QtSql/QSqlQuery>
-
using namespace Locator;
using namespace Help;
using namespace Help::Internal;
Q_DECLARE_METATYPE(ILocatorFilter*);
-static const char linksForKeyQuery[] = "SELECT d.Title, f.Name, e.Name, "
- "d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
- "NamespaceTable f WHERE a.FileId=d.FileId AND d.FolderId=e.Id AND "
- "a.NamespaceId=f.Id AND a.Name='%1'";
-
-// -- HelpIndexFilter::HelpFileReader
-
-class HelpIndexFilter::HelpFileReader
-{
- struct dbCleaner {
- dbCleaner(const QString &dbName)
- : name(dbName) {}
- ~dbCleaner() {
- QSqlDatabase::removeDatabase(name);
- }
- QString name;
- };
-
-public:
- HelpFileReader();
- ~HelpFileReader();
-
-public:
- void updateHelpFiles();
- QMap<QString, QUrl> linksForKey(const QString &key);
- QList<FilterEntry> matchesFor(const QString &entry, ILocatorFilter *locator,
- int maxHits = INT_MAX);
-
-private:
- QIcon m_icon;
- bool m_initialized;
- QStringList m_helpFiles;
-};
-
-HelpIndexFilter::HelpFileReader::HelpFileReader()
- : m_initialized(false)
-{
- m_icon = QIcon(QLatin1String(":/help/images/bookmark.png"));
-}
-
-HelpIndexFilter::HelpFileReader::~HelpFileReader()
-{
-}
-
-void HelpIndexFilter::HelpFileReader::updateHelpFiles()
-{
- m_helpFiles.clear();
- const QLatin1String id("HelpIndexFilter::HelpFileReader::helpFiles");
- {
- QSqlDatabase db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), id);
- if (db.driver()
- && db.driver()->lastError().type() == QSqlError::NoError) {
- db.setDatabaseName(HelpManager::collectionFilePath());
- if (db.open()) {
- QSqlQuery query = QSqlQuery(db);
- query.exec(QLatin1String("SELECT a.FilePath FROM NamespaceTable a"));
- while (query.next())
- m_helpFiles.append(query.value(0).toString());
- }
- }
- }
- QSqlDatabase::removeDatabase(id);
-}
-
-QUrl buildQUrl(const QString &nameSpace, const QString &folder,
- const QString &relFileName, const QString &anchor)
-{
- QUrl url;
- url.setScheme(QLatin1String("qthelp"));
- url.setAuthority(nameSpace);
- url.setPath(folder + QLatin1Char('/') + relFileName);
- url.setFragment(anchor);
- return url;
-}
-
-QMap<QString, QUrl>HelpIndexFilter::HelpFileReader::linksForKey(const QString &key)
-{
- if (!m_initialized) {
- updateHelpFiles();
- m_initialized = true;
- }
-
- QMap<QString, QUrl> links;
- const QLatin1String sqlite("QSQLITE");
- const QLatin1String name("HelpIndexFilter::HelpFileReader::linksForKey");
-
- dbCleaner cleaner(name);
- QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
- if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
- foreach(const QString &file, m_helpFiles) {
- if (!QFile::exists(file))
- continue;
- db.setDatabaseName(file);
- if (db.open()) {
- QSqlQuery query = QSqlQuery(db);
- query.setForwardOnly(true);
- query.exec(QString::fromLatin1(linksForKeyQuery).arg(key));
- while (query.next()) {
- QString title = query.value(0).toString();
- if (title.isEmpty()) // generate a title + corresponding path
- title = key + QLatin1String(" : ") + query.value(3).toString();
- links.insertMulti(title, buildQUrl(query.value(1).toString(),
- query.value(2).toString(), query.value(3).toString(),
- query.value(4).toString()));
- }
- }
- }
- }
- return links;
-}
-
-QList<FilterEntry> HelpIndexFilter::HelpFileReader::matchesFor(const QString &id,
- ILocatorFilter *locator, int maxHits)
-{
- if (!m_initialized) {
- updateHelpFiles();
- m_initialized = true;
- }
-
- QList<FilterEntry> entries;
- const QLatin1String sqlite("QSQLITE");
- const QLatin1String name("HelpIndexFilter::HelpFileReader::matchesFor");
-
- dbCleaner cleaner(name);
- QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
- if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
- foreach(const QString &file, m_helpFiles) {
- if (!QFile::exists(file))
- continue;
- db.setDatabaseName(file);
- if (db.open()) {
- QSqlQuery query = QSqlQuery(db);
- query.setForwardOnly(true);
- query.exec(QString::fromLatin1("SELECT DISTINCT Name FROM "
- "IndexTable WHERE Name LIKE '%%1%'").arg(id));
- while (query.next()) {
- const QString &key = query.value(0).toString();
- if (!key.isEmpty()) {
- entries.append(FilterEntry(locator, key, QVariant(),
- m_icon));
- if (entries.count() == maxHits)
- return entries;
- }
- }
- }
- }
- }
- return entries;
-}
-
-// -- HelpIndexFilter
-
HelpIndexFilter::HelpIndexFilter()
- : m_fileReader(new HelpFileReader)
{
setIncludedByDefault(false);
setShortcutString(QString(QLatin1Char('?')));
-
- connect(&HelpManager::helpEngineCore(), SIGNAL(setupFinished()), this,
- SLOT(updateHelpFiles()));
+ m_icon = QIcon(QLatin1String(":/help/images/bookmark.png"));
}
HelpIndexFilter::~HelpIndexFilter()
{
- delete m_fileReader;
-}
-
-void HelpIndexFilter::updateHelpFiles()
-{
- m_fileReader->updateHelpFiles();
}
QString HelpIndexFilter::displayName() const
@@ -238,15 +69,23 @@ ILocatorFilter::Priority HelpIndexFilter::priority() const
QList<FilterEntry> HelpIndexFilter::matchesFor(const QString &entry)
{
+ QStringList keywords;
if (entry.length() < 2)
- return m_fileReader->matchesFor(entry, this, 300);
- return m_fileReader->matchesFor(entry, this);
+ keywords = Core::HelpManager::instance()->findKeywords(entry, 300);
+ else
+ keywords = Core::HelpManager::instance()->findKeywords(entry);
+
+ QList<FilterEntry> entries;
+ foreach (const QString &keyword, keywords)
+ entries.append(FilterEntry(this, keyword, QVariant(), m_icon));
+
+ return entries;
}
void HelpIndexFilter::accept(FilterEntry selection) const
{
const QString &key = selection.displayName;
- const QMap<QString, QUrl> &links = m_fileReader->linksForKey(key);
+ const QMap<QString, QUrl> &links = Core::HelpManager::instance()->linksForKeyword(key);
if (links.size() == 1) {
emit linkActivated(links.begin().value());
} else if (!links.isEmpty()) {
diff --git a/src/plugins/help/helpindexfilter.h b/src/plugins/help/helpindexfilter.h
index 9c3a6de465..859dc5a056 100644
--- a/src/plugins/help/helpindexfilter.h
+++ b/src/plugins/help/helpindexfilter.h
@@ -32,6 +32,8 @@
#include <locator/ilocatorfilter.h>
+#include <QtGui/QIcon>
+
namespace Help {
namespace Internal {
@@ -40,7 +42,6 @@ class HelpPlugin;
class HelpIndexFilter : public Locator::ILocatorFilter
{
Q_OBJECT
- class HelpFileReader;
public:
HelpIndexFilter();
@@ -58,11 +59,8 @@ signals:
void linkActivated(const QUrl &link) const;
void linksActivated(const QMap<QString, QUrl> &urls, const QString &keyword) const;
-private slots:
- void updateHelpFiles();
-
private:
- HelpFileReader *m_fileReader;
+ QIcon m_icon;
};
} // namespace Internal
diff --git a/src/plugins/help/helpmanager.cpp b/src/plugins/help/helpmanager.cpp
index bc5bef0a46..10f4197ab9 100644
--- a/src/plugins/help/helpmanager.cpp
+++ b/src/plugins/help/helpmanager.cpp
@@ -30,38 +30,29 @@
#include "helpmanager.h"
#include "bookmarkmanager.h"
-#include <coreplugin/icore.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/helpmanager.h>
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QFileInfo>
#include <QtCore/QMutexLocker>
#include <QtHelp/QHelpEngine>
-#include <QtHelp/QHelpEngineCore>
-using namespace Help;
+using namespace Help::Internal;
-bool HelpManager::m_guiNeedsSetup = true;
-bool HelpManager::m_needsCollectionFile = true;
+QMutex LocalHelpManager::m_guiMutex;
+QHelpEngine* LocalHelpManager::m_guiEngine = 0;
-QMutex HelpManager::m_guiMutex;
-QHelpEngine* HelpManager::m_guiEngine = 0;
+QMutex LocalHelpManager::m_bkmarkMutex;
+BookmarkManager* LocalHelpManager::m_bookmarkManager = 0;
-QMutex HelpManager::m_coreMutex;
-QHelpEngineCore* HelpManager::m_coreEngine = 0;
-
-HelpManager* HelpManager::m_helpManager = 0;
-BookmarkManager* HelpManager::m_bookmarkManager = 0;
-
-HelpManager::HelpManager(QObject *parent)
+LocalHelpManager::LocalHelpManager(QObject *parent)
: QObject(parent)
+ , m_guiNeedsSetup(true)
+ , m_needsCollectionFile(true)
{
- Q_ASSERT(!m_helpManager);
- m_helpManager = this;
}
-HelpManager::~HelpManager()
+LocalHelpManager::~LocalHelpManager()
{
if (m_bookmarkManager) {
m_bookmarkManager->saveBookmarks();
@@ -71,88 +62,27 @@ HelpManager::~HelpManager()
delete m_guiEngine;
m_guiEngine = 0;
-
- delete m_coreEngine;
- m_coreEngine = 0;
}
-HelpManager& HelpManager::instance()
-{
- Q_ASSERT(m_helpManager);
- return *m_helpManager;
-}
-
-void HelpManager::setupGuiHelpEngine()
+void LocalHelpManager::setupGuiHelpEngine()
{
if (m_needsCollectionFile) {
m_needsCollectionFile = false;
- (&helpEngine())->setCollectionFile(collectionFilePath());
+ helpEngine().setCollectionFile(Core::HelpManager::collectionFilePath());
}
if (m_guiNeedsSetup) {
m_guiNeedsSetup = false;
- (&helpEngine())->setupData();
+ helpEngine().setupData();
}
}
-bool HelpManager::guiEngineNeedsUpdate() const
-{
- return m_guiNeedsSetup;
-}
-
-void HelpManager::handleHelpRequest(const QString &url)
+void LocalHelpManager::setEngineNeedsUpdate()
{
- emit helpRequested(QUrl(url));
+ m_guiNeedsSetup = true;
}
-void HelpManager::verifyDocumenation()
-{
- QStringList nameSpacesToUnregister;
- QHelpEngineCore *engine = &helpEngineCore();
- const QStringList &registeredDocs = engine->registeredDocumentations();
- foreach (const QString &nameSpace, registeredDocs) {
- const QString &file = engine->documentationFileName(nameSpace);
- if (!QFileInfo(file).exists())
- nameSpacesToUnregister.append(nameSpace);
- }
-
- if (!nameSpacesToUnregister.isEmpty())
- unregisterDocumentation(nameSpacesToUnregister);
-}
-
-void HelpManager::registerDocumentation(const QStringList &files)
-{
- QHelpEngineCore *engine = &helpEngineCore();
- foreach (const QString &file, files) {
- const QString &nameSpace = engine->namespaceName(file);
- if (nameSpace.isEmpty())
- continue;
- if (!engine->registeredDocumentations().contains(nameSpace)) {
- if (engine->registerDocumentation(file)) {
- m_guiNeedsSetup = true;
- } else {
- qWarning() << "Error registering namespace '" << nameSpace
- << "' from file '" << file << "':" << engine->error();
- }
- }
- }
-}
-
-void HelpManager::unregisterDocumentation(const QStringList &nameSpaces)
-{
- QHelpEngineCore *engine = &helpEngineCore();
- foreach (const QString &nameSpace, nameSpaces) {
- const QString &file = engine->documentationFileName(nameSpace);
- if (engine->unregisterDocumentation(nameSpace)) {
- m_guiNeedsSetup = true;
- } else {
- qWarning() << "Error unregistering namespace '" << nameSpace
- << "' from file '" << file << "': " << engine->error();
- }
- }
-}
-
-QHelpEngine &HelpManager::helpEngine()
+QHelpEngine &LocalHelpManager::helpEngine()
{
if (!m_guiEngine) {
QMutexLocker _(&m_guiMutex);
@@ -164,34 +94,18 @@ QHelpEngine &HelpManager::helpEngine()
return *m_guiEngine;
}
-QString HelpManager::collectionFilePath()
-{
- const QFileInfo fi(Core::ICore::instance()->settings()->fileName());
- const QDir directory(fi.absolutePath() + QLatin1String("/qtcreator"));
- if (!directory.exists())
- directory.mkpath(directory.absolutePath());
- return QDir::cleanPath(directory.absolutePath() + QLatin1String("/helpcollection.qhc"));
-}
-
-QHelpEngineCore& HelpManager::helpEngineCore()
-{
- if (!m_coreEngine) {
- QMutexLocker _(&m_coreMutex);
- if (!m_coreEngine) {
- m_coreEngine = new QHelpEngineCore(collectionFilePath());
- m_coreEngine->setAutoSaveFilter(false);
- m_coreEngine->setCurrentFilter(tr("Unfiltered"));
- m_coreEngine->setupData();
- }
- }
- return *m_coreEngine;
-}
-
-BookmarkManager& HelpManager::bookmarkManager()
+BookmarkManager& LocalHelpManager::bookmarkManager()
{
if (!m_bookmarkManager) {
- m_bookmarkManager = new BookmarkManager;
- m_bookmarkManager->setupBookmarkModels();
+ QMutexLocker _(&m_bkmarkMutex);
+ if (!m_bookmarkManager) {
+ m_bookmarkManager = new BookmarkManager;
+ m_bookmarkManager->setupBookmarkModels();
+ const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
+ "%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
+ .arg(IDE_VERSION_RELEASE);
+ helpEngine().setCustomValue(QLatin1String("DefaultHomePage"), url);
+ }
}
return *m_bookmarkManager;
}
diff --git a/src/plugins/help/helpmanager.h b/src/plugins/help/helpmanager.h
index 18a36bcd08..3dc333d405 100644
--- a/src/plugins/help/helpmanager.h
+++ b/src/plugins/help/helpmanager.h
@@ -27,66 +27,44 @@
**
**************************************************************************/
-#ifndef HELPMANAGER_H
-#define HELPMANAGER_H
-
-#include "help_global.h"
+#ifndef LOCALHELPMANAGER_H
+#define LOCALHELPMANAGER_H
#include <QtCore/QMutex>
#include <QtCore/QObject>
QT_FORWARD_DECLARE_CLASS(QHelpEngine)
-QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
-QT_FORWARD_DECLARE_CLASS(QString)
-QT_FORWARD_DECLARE_CLASS(QStringList)
-QT_FORWARD_DECLARE_CLASS(QUrl)
class BookmarkManager;
namespace Help {
+ namespace Internal {
-class HELP_EXPORT HelpManager : public QObject
+class LocalHelpManager : public QObject
{
Q_OBJECT
-public:
- HelpManager(QObject *parent = 0);
- ~HelpManager();
- static HelpManager& instance();
+public:
+ LocalHelpManager(QObject *parent = 0);
+ ~LocalHelpManager();
void setupGuiHelpEngine();
- bool guiEngineNeedsUpdate() const;
-
- void verifyDocumenation();
- void registerDocumentation(const QStringList &fileNames);
- void unregisterDocumentation(const QStringList &nameSpaces);
+ void setEngineNeedsUpdate();
static QHelpEngine& helpEngine();
- static QString collectionFilePath();
- static QHelpEngineCore& helpEngineCore();
-
static BookmarkManager& bookmarkManager();
-public slots:
- void handleHelpRequest(const QString &url);
-
-signals:
- void helpRequested(const QUrl &url);
-
private:
- static bool m_guiNeedsSetup;
- static bool m_needsCollectionFile;
+ bool m_guiNeedsSetup;
+ bool m_needsCollectionFile;
static QMutex m_guiMutex;
static QHelpEngine *m_guiEngine;
- static QMutex m_coreMutex;
- static QHelpEngineCore *m_coreEngine;
-
- static HelpManager *m_helpManager;
+ static QMutex m_bkmarkMutex;
static BookmarkManager *m_bookmarkManager;
};
-
+ } // Internal
} // Help
-#endif // HELPMANAGER_H
+#endif // LOCALHELPMANAGER_H
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index b03719cd10..ec515753e8 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -54,6 +54,7 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/rightpane.h>
@@ -78,10 +79,8 @@
#include <QtGui/QToolBar>
#include <QtHelp/QHelpEngine>
-#include <QtHelp/QHelpEngineCore>
using namespace Core::Constants;
-using namespace Help;
using namespace Help::Internal;
const char * const SB_INDEX = "Index";
@@ -140,22 +139,20 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
qApp->installTranslator(qhelptr);
}
- addAutoReleasedObject(m_helpManager = new HelpManager(this));
+ addAutoReleasedObject(m_helpManager = new LocalHelpManager(this));
addAutoReleasedObject(m_openPagesManager = new OpenPagesManager(this));
-
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
- connect(m_docSettingsPage, SIGNAL(documentationChanged()), m_filterSettingsPage,
- SLOT(updateFilterPage()));
connect(m_generalSettingsPage, SIGNAL(fontChanged()), this,
SLOT(fontChanged()));
- connect(m_helpManager, SIGNAL(helpRequested(QUrl)), this,
+ connect(Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this,
SLOT(handleHelpRequest(QUrl)));
+ m_filterSettingsPage->setHelpManager(m_helpManager);
connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this,
SLOT(setupHelpEngineIfNeeded()));
- connect(m_docSettingsPage, SIGNAL(documentationChanged()), this,
+ connect(Core::HelpManager::instance(), SIGNAL(documentationChanged()), this,
SLOT(setupHelpEngineIfNeeded()));
m_splitter = new Core::MiniSplitter;
@@ -313,30 +310,20 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
void HelpPlugin::extensionsInitialized()
{
- const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
+ const QString &nsInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
- const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
-
- QHelpEngineCore *engine = &m_helpManager->helpEngineCore();
- const QStringList &filters = engine->customFilters();
- foreach (const QString &filter, filters) {
- if (filterRegExp.exactMatch(filter) && filter != filterInternal)
- engine->removeCustomFilter(filter);
- }
- const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
- .arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
-
- foreach (const QString &ns, engine->registeredDocumentations()) {
+ Core::HelpManager *helpManager = Core::HelpManager::instance();
+ foreach (const QString &ns, helpManager->registeredNamespaces()) {
if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))
- && ns != docInternal)
- m_helpManager->unregisterDocumentation(QStringList() << ns);
+ && ns != nsInternal)
+ helpManager->unregisterDocumentation(QStringList() << ns);
}
QStringList filesToRegister;
// Explicitly register qml.qch if located in creator directory. This is only
// needed for the creator-qml package, were we want to ship the documentation
- // without a qt development version.
+ // without a qt development version. TODO: is this still really needed, remove
const QString &appPath = QCoreApplication::applicationDirPath();
filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qml.qch"))));
@@ -344,24 +331,6 @@ void HelpPlugin::extensionsInitialized()
// we might need to register creators inbuild help
filesToRegister.append(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qtcreator.qch")));
-
- // this comes from the installer
- const QLatin1String key("AddedDocs");
- const QString &addedDocs = engine->customValue(key).toString();
- if (!addedDocs.isEmpty()) {
- engine->removeCustomValue(key);
- filesToRegister += addedDocs.split(QLatin1Char(';'));
- }
-
- updateFilterComboBox();
- m_helpManager->verifyDocumenation();
- m_helpManager->registerDocumentation(filesToRegister);
-
- const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
- "%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
- .arg(IDE_VERSION_RELEASE);
- engine->setCustomValue(QLatin1String("DefaultHomePage"), url);
- connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
}
void HelpPlugin::aboutToShutdown()
@@ -424,7 +393,7 @@ void HelpPlugin::setupUi()
// connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
// shortcutMap.insert("Search", cmd);
- BookmarkManager *manager = &HelpManager::bookmarkManager();
+ BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false);
bookmarkWidget->setWindowTitle(tr("Bookmarks"));
m_bookmarkItem = new Core::SideBarItem(bookmarkWidget, QLatin1String(SB_BOOKMARKS));
@@ -469,24 +438,36 @@ void HelpPlugin::setupUi()
void HelpPlugin::resetFilter()
{
+ const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
+ .arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
+ const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
+
+ QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
+ const QStringList &filters = engine->customFilters();
+ foreach (const QString &filter, filters) {
+ if (filterRegExp.exactMatch(filter) && filter != filterInternal)
+ engine->removeCustomFilter(filter);
+ }
+
const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
const QLatin1String previousFilterNameKey("UnfilteredFilterName");
-
- QHelpEngineCore *core = &m_helpManager->helpEngineCore();
- if (core->customValue(weAddedFilterKey).toInt() == 1) {
+ if (engine->customValue(weAddedFilterKey).toInt() == 1) {
// we added a filter at some point, remove previously added filter
- const QString &filter = core->customValue(previousFilterNameKey).toString();
+ const QString &filter = engine->customValue(previousFilterNameKey).toString();
if (!filter.isEmpty())
- core->removeCustomFilter(filter);
+ engine->removeCustomFilter(filter);
}
// potentially remove a filter with new name
const QString filterName = tr("Unfiltered");
- core->removeCustomFilter(filterName);
- core->addCustomFilter(filterName, QStringList());
- core->setCustomValue(weAddedFilterKey, 1);
- core->setCustomValue(previousFilterNameKey, filterName);
- (&m_helpManager->helpEngine())->setCurrentFilter(filterName);
+ engine->removeCustomFilter(filterName);
+ engine->addCustomFilter(filterName, QStringList());
+ engine->setCustomValue(weAddedFilterKey, 1);
+ engine->setCustomValue(previousFilterNameKey, filterName);
+ engine->setCurrentFilter(filterName);
+
+ updateFilterComboBox();
+ connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
}
void HelpPlugin::createRightPaneContextViewer()
@@ -594,9 +575,9 @@ void HelpPlugin::modeChanged(Core::IMode *mode)
qApp->processEvents();
qApp->setOverrideCursor(Qt::WaitCursor);
+ m_helpManager->setupGuiHelpEngine();
setupUi();
resetFilter();
- m_helpManager->setupGuiHelpEngine();
OpenPagesManager::instance().setupInitialPages();
qApp->restoreOverrideCursor();
@@ -632,7 +613,7 @@ void HelpPlugin::fontChanged()
if (!m_helpViewerForSideBar)
createRightPaneContextViewer();
- const QHelpEngineCore &engine = m_helpManager->helpEngineCore();
+ const QHelpEngine &engine = LocalHelpManager::helpEngine();
QFont font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
m_helpViewerForSideBar->viewerFont()));
@@ -646,7 +627,8 @@ void HelpPlugin::fontChanged()
void HelpPlugin::setupHelpEngineIfNeeded()
{
- if (Core::ICore::instance()->modeManager()->currentMode() == m_mode)
+ m_helpManager->setEngineNeedsUpdate();
+ if (Core::ModeManager::instance()->currentMode() == m_mode)
m_helpManager->setupGuiHelpEngine();
}
@@ -655,7 +637,7 @@ HelpViewer* HelpPlugin::viewerForContextMode()
using namespace Core;
bool showSideBySide = false;
- const QHelpEngineCore &engine = m_helpManager->helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
switch (engine.customValue(QLatin1String("ContextHelpOption"), 0).toInt()) {
case 0: {
@@ -712,7 +694,7 @@ void HelpPlugin::activateContext()
// Find out what to show
if (IContext *context = m_core->currentContextObject()) {
id = context->contextHelpId();
- links = m_helpManager->helpEngineCore().linksForIdentifier(id);
+ links = Core::HelpManager::instance()->linksForIdentifier(id);
}
if (HelpViewer* viewer = viewerForContextMode()) {
@@ -802,7 +784,7 @@ QToolBar *HelpPlugin::createToolBar()
void HelpPlugin::updateFilterComboBox()
{
- const QHelpEngine &engine = m_helpManager->helpEngine();
+ const QHelpEngine &engine = LocalHelpManager::helpEngine();
QString curFilter = m_filterComboBox->currentText();
if (curFilter.isEmpty())
curFilter = engine.currentFilter();
@@ -816,7 +798,7 @@ void HelpPlugin::updateFilterComboBox()
void HelpPlugin::filterDocumentation(const QString &customFilter)
{
- (&m_helpManager->helpEngine())->setCurrentFilter(customFilter);
+ LocalHelpManager::helpEngine().setCurrentFilter(customFilter);
}
void HelpPlugin::addBookmark()
@@ -827,7 +809,7 @@ void HelpPlugin::addBookmark()
if (url.isEmpty() || url == Help::Constants::AboutBlank)
return;
- BookmarkManager *manager = &HelpManager::bookmarkManager();
+ BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
manager->showBookmarkDialog(m_centralWidget, viewer->title(), url);
}
@@ -836,7 +818,7 @@ void HelpPlugin::handleHelpRequest(const QUrl &url)
if (HelpViewer::launchWithExternalApp(url))
return;
- if (m_helpManager->helpEngineCore().findFile(url).isValid()) {
+ if (Core::HelpManager::instance()->findFile(url).isValid()) {
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(url);
diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h
index 1ac051cdfb..9ad6644eb0 100644
--- a/src/plugins/help/helpplugin.h
+++ b/src/plugins/help/helpplugin.h
@@ -49,8 +49,6 @@ class SideBarItem;
} // Core
namespace Help {
-class HelpManager;
-
namespace Internal {
class CentralWidget;
class DocSettingsPage;
@@ -58,6 +56,7 @@ class FilterSettingsPage;
class GeneralSettingsPage;
class HelpMode;
class HelpViewer;
+class LocalHelpManager;
class OpenPagesManager;
class SearchWidget;
@@ -129,7 +128,7 @@ private:
Core::SideBar *m_sideBar;
bool m_firstModeChange;
- HelpManager *m_helpManager;
+ LocalHelpManager *m_helpManager;
OpenPagesManager *m_openPagesManager;
Core::MiniSplitter *m_splitter;
diff --git a/src/plugins/help/helpviewer.cpp b/src/plugins/help/helpviewer.cpp
index 3fa9fcc948..d351a98226 100644
--- a/src/plugins/help/helpviewer.cpp
+++ b/src/plugins/help/helpviewer.cpp
@@ -40,7 +40,7 @@
#include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
using namespace Help::Internal;
@@ -126,7 +126,7 @@ QString HelpViewer::mimeFromUrl(const QUrl &url)
bool HelpViewer::launchWithExternalApp(const QUrl &url)
{
if (isLocalUrl(url)) {
- const QHelpEngineCore &helpEngine = Help::HelpManager::helpEngineCore();
+ const QHelpEngineCore &helpEngine = LocalHelpManager::helpEngine();
const QUrl &resolvedUrl = helpEngine.findFile(url);
if (!resolvedUrl.isValid())
return false;
@@ -155,7 +155,7 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
void HelpViewer::home()
{
- const QHelpEngineCore &engine = Help::HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
QString homepage = engine.customValue(QLatin1String("HomePage"),
QLatin1String("")).toString();
diff --git a/src/plugins/help/helpviewer_qwv.cpp b/src/plugins/help/helpviewer_qwv.cpp
index abf812797e..461eefafd9 100644
--- a/src/plugins/help/helpviewer_qwv.cpp
+++ b/src/plugins/help/helpviewer_qwv.cpp
@@ -44,7 +44,7 @@
#include <QtGui/QApplication>
#include <QtGui/QWheelEvent>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
@@ -125,7 +125,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{
QString url = request.url().toString();
- const QHelpEngineCore &engine = HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
// 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
@@ -265,7 +265,7 @@ QFont HelpViewer::viewerFont() const
QWebSettings* webSettings = QWebSettings::globalSettings();
QFont font(QApplication::font().family(),
webSettings->fontSize(QWebSettings::DefaultFontSize));
- const QHelpEngineCore &engine = HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
return qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
font));
}
diff --git a/src/plugins/help/openpagesmanager.cpp b/src/plugins/help/openpagesmanager.cpp
index 5396f05aac..5762ee7686 100644
--- a/src/plugins/help/openpagesmanager.cpp
+++ b/src/plugins/help/openpagesmanager.cpp
@@ -41,7 +41,7 @@
#include <QtGui/QComboBox>
#include <QtGui/QTreeView>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
using namespace Help::Internal;
@@ -118,7 +118,7 @@ QStringList splitString(const QVariant &value)
void OpenPagesManager::setupInitialPages()
{
- const QHelpEngineCore &engine = HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
const int option = engine.customValue(QLatin1String("StartOption"),
Help::Constants::ShowLastPages).toInt();
QString homePage = engine.customValue(QLatin1String("DefaultHomePage"),
diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp
index 933abd3689..5e564388a7 100644
--- a/src/plugins/help/searchwidget.cpp
+++ b/src/plugins/help/searchwidget.cpp
@@ -100,7 +100,7 @@ void SearchWidget::showEvent(QShowEvent *event)
QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setMargin(4);
- searchEngine = (&HelpManager::helpEngine())->searchEngine();
+ searchEngine = (&LocalHelpManager::helpEngine())->searchEngine();
resultWidget = searchEngine->resultWidget();
QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();
@@ -126,7 +126,7 @@ void SearchWidget::showEvent(QShowEvent *event)
connect(searchEngine, SIGNAL(indexingFinished()), this,
SLOT(indexingFinished()));
- QMetaObject::invokeMethod(&HelpManager::helpEngine(), "setupFinished",
+ QMetaObject::invokeMethod(&LocalHelpManager::helpEngine(), "setupFinished",
Qt::QueuedConnection);
}
}
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 156d5ce9f8..f59ddb97a4 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -114,7 +114,6 @@ plugin_qt4projectmanager.depends = plugin_texteditor
plugin_qt4projectmanager.depends += plugin_projectexplorer
plugin_qt4projectmanager.depends += plugin_cpptools
plugin_qt4projectmanager.depends += plugin_cppeditor
-plugin_qt4projectmanager.depends += plugin_help
plugin_qt4projectmanager.depends += plugin_designer
plugin_qt4projectmanager.depends += plugin_debugger
diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro
index 0f0c3e238c..d7f95441dd 100644
--- a/src/plugins/qmljseditor/qmljseditor.pro
+++ b/src/plugins/qmljseditor/qmljseditor.pro
@@ -3,7 +3,6 @@ TARGET = QmlJSEditor
include(../../qtcreatorplugin.pri)
include(qmljseditor_dependencies.pri)
-CONFIG += help
DEFINES += \
QMLJSEDITOR_LIBRARY \
QT_CREATOR
diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp
index 38cc47cae5..e3ed501186 100644
--- a/src/plugins/qmljseditor/qmljshoverhandler.cpp
+++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp
@@ -32,6 +32,7 @@
#include "qmljshoverhandler.h"
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <debugger/debuggerconstants.h>
@@ -52,7 +53,6 @@
#include <QtGui/QToolTip>
#include <QtGui/QTextCursor>
#include <QtGui/QTextBlock>
-#include <QtHelp/QHelpEngineCore>
using namespace Core;
using namespace QmlJS;
@@ -61,27 +61,11 @@ using namespace QmlJSEditor::Internal;
HoverHandler::HoverHandler(QObject *parent)
: QObject(parent)
- , m_helpEngineNeedsSetup(false)
{
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<ModelManagerInterface>();
- ICore *core = ICore::instance();
- QFileInfo fi(core->settings()->fileName());
- // FIXME shouldn't the help engine create the directory if it doesn't exist?
- QDir directory(fi.absolutePath()+"/qtcreator");
- if (!directory.exists())
- directory.mkpath(directory.absolutePath());
-
- m_helpEngine = new QHelpEngineCore(directory.absolutePath()
- + QLatin1String("/helpcollection.qhc"), this);
- if (!m_helpEngine->setupData())
- qWarning() << "Could not initialize help engine:" << m_helpEngine->error();
- m_helpEngine->setAutoSaveFilter(false);
- m_helpEngine->setCurrentFilter(tr("Unfiltered"));
- m_helpEngineNeedsSetup = m_helpEngine->registeredDocumentations().count() == 0;
-
// Listen for editor opened events in order to connect to tooltip/helpid requests
- connect(core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
+ connect(ICore::instance()->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
this, SLOT(editorOpened(Core::IEditor *)));
}
@@ -151,11 +135,6 @@ void HoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int p
const Snapshot snapshot = semanticInfo.snapshot;
const Document::Ptr qmlDocument = semanticInfo.document;
- if (m_helpEngineNeedsSetup && m_helpEngine->registeredDocumentations().count() > 0) {
- m_helpEngine->setupData();
- m_helpEngineNeedsSetup = false;
- }
-
// We only want to show F1 if the tooltip matches the help id
bool showF1 = true;
@@ -188,7 +167,7 @@ void HoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int p
QString helpId = QLatin1String("QML.");
helpId += baseClass;
- if (! m_helpEngine->linksForIdentifier(helpId).isEmpty()) {
+ if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) {
m_helpId = helpId;
break;
}
diff --git a/src/plugins/qmljseditor/qmljshoverhandler.h b/src/plugins/qmljseditor/qmljshoverhandler.h
index f41ad62867..2cffd888e0 100644
--- a/src/plugins/qmljseditor/qmljshoverhandler.h
+++ b/src/plugins/qmljseditor/qmljshoverhandler.h
@@ -35,7 +35,6 @@
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
-class QHelpEngineCore;
class QPoint;
class QStringList;
QT_END_NAMESPACE
@@ -80,10 +79,8 @@ private:
private:
ModelManagerInterface *m_modelManager;
- QHelpEngineCore *m_helpEngine;
QString m_helpId;
QString m_toolTip;
- bool m_helpEngineNeedsSetup;
};
} // namespace Internal
diff --git a/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec b/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec
index 3a5b5e62c4..2b2e73472d 100644
--- a/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec
+++ b/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec
@@ -18,7 +18,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<dependency name="ProjectExplorer" version="1.3.86"/>
<dependency name="CppTools" version="1.3.86"/>
<dependency name="CppEditor" version="1.3.86"/>
- <dependency name="Help" version="1.3.86"/>
<dependency name="Designer" version="1.3.86"/>
<dependency name="Debugger" version="1.3.86"/>
</dependencyList>
diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
index 1e82fc64e0..c84cd25a88 100644
--- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
+++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp
@@ -31,6 +31,7 @@
#include "ui_gettingstartedwelcomepagewidget.h"
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/mainwindow.h>
@@ -38,8 +39,6 @@
#include <extensionsystem/pluginmanager.h>
-#include <help/helpmanager.h>
-
#include <QtCore/QDateTime>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
@@ -338,15 +337,13 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url)
{
- Help::HelpManager *helpManager
- = ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
+ Core::HelpManager *helpManager = Core::HelpManager::instance();
Q_ASSERT(helpManager);
helpManager->handleHelpRequest(url);
}
void GettingStartedWelcomePageWidget::slotOpenContextHelpPage(const QString& url)
{
- Help::HelpManager *helpManager
- = ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
+ Core::HelpManager *helpManager = Core::HelpManager::instance();
Q_ASSERT(helpManager);
helpManager->handleHelpRequest(url % QLatin1String("?view=split"));
}
diff --git a/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri b/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri
index 5e11deb8b5..e40eac29c4 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri
+++ b/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri
@@ -1,7 +1,6 @@
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/cpptools/cpptools.pri)
include(../../plugins/cppeditor/cppeditor.pri)
-include(../../plugins/help/help.pri)
include(../../plugins/designer/designer.pri)
include(../../plugins/debugger/debugger.pri)
include(../../libs/symbianutils/symbianutils.pri)
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 4b7fc1f1c8..02246c7c98 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -43,6 +43,7 @@
#include <projectexplorer/cesdkhandler.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <help/helpmanager.h>
#include <utils/qtcassert.h>
@@ -211,8 +212,7 @@ QSet<QString> QtVersionManager::supportedTargetIds() const
void QtVersionManager::updateDocumentation()
{
- Help::HelpManager *helpManager
- = ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
+ Core::HelpManager *helpManager = Core::HelpManager::instance();
Q_ASSERT(helpManager);
QStringList files;
foreach (QtVersion *version, m_versions) {
diff --git a/src/shared/help/bookmarkmanager.cpp b/src/shared/help/bookmarkmanager.cpp
index e8619922e0..21406b0647 100644
--- a/src/shared/help/bookmarkmanager.cpp
+++ b/src/shared/help/bookmarkmanager.cpp
@@ -50,10 +50,11 @@
#include <QtGui/QToolButton>
#include <QtGui/QPushButton>
#include <QtGui/QApplication>
-#include <QtHelp/QHelpEngineCore>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QSortFilterProxyModel>
+#include <QtHelp/QHelpEngine>
+
using namespace Help::Internal;
BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
@@ -646,7 +647,7 @@ void BookmarkManager::saveBookmarks()
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
- (&Help::HelpManager::helpEngineCore())->setCustomValue(QLatin1String("Bookmarks"),
+ (&LocalHelpManager::helpEngine())->setCustomValue(QLatin1String("Bookmarks"),
bookmarks);
}
@@ -765,7 +766,7 @@ void BookmarkManager::setupBookmarkModels()
QList<int> lastDepths;
QList<QStandardItem*> parents;
- QByteArray ba = Help::HelpManager::helpEngineCore()
+ QByteArray ba = LocalHelpManager::helpEngine()
.customValue(QLatin1String("Bookmarks")).toByteArray();
QDataStream stream(ba);
while (!stream.atEnd()) {
diff --git a/src/shared/help/contentwindow.cpp b/src/shared/help/contentwindow.cpp
index a8ed1f1613..ef3479f170 100644
--- a/src/shared/help/contentwindow.cpp
+++ b/src/shared/help/contentwindow.cpp
@@ -45,7 +45,7 @@ ContentWindow::ContentWindow()
: m_contentWidget(0)
, m_expandDepth(-2)
{
- m_contentWidget = (&Help::HelpManager::helpEngine())->contentWidget();
+ m_contentWidget = (&LocalHelpManager::helpEngine())->contentWidget();
m_contentWidget->installEventFilter(this);
m_contentWidget->viewport()->installEventFilter(this);
m_contentWidget->setContextMenuPolicy(Qt::CustomContextMenu);
diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp
index 1bc86d60ec..b12d517c6d 100644
--- a/src/shared/help/indexwindow.cpp
+++ b/src/shared/help/indexwindow.cpp
@@ -80,7 +80,7 @@ IndexWindow::IndexWindow()
toolbar->setLayout(tbLayout);
layout->addWidget(toolbar);
- QHelpEngine *engine = &Help::HelpManager::helpEngine();
+ QHelpEngine *engine = &LocalHelpManager::helpEngine();
m_indexWidget = engine->indexWidget();
m_indexWidget->installEventFilter(this);
connect(engine->indexModel(), SIGNAL(indexCreationStarted()), this,