return m_mainwindow->mimeDatabase();
}
+HelpManager *CoreImpl::helpManager() const
+{
+ return m_mainwindow->helpManager();
+}
+
QSettings *CoreImpl::settings(QSettings::Scope scope) const
{
return m_mainwindow->settings(scope);
VCSManager *vcsManager() const;
ModeManager *modeManager() const;
MimeDatabase *mimeDatabase() const;
+ HelpManager *helpManager() const;
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
SettingsDatabase *settingsDatabase() const;
script \
svg \
sql
+CONFIG += help
include(../../qtcreatorplugin.pri)
include(../../libs/utils/utils.pri)
include(../../shared/scriptwrapper/scriptwrapper.pri)
editortoolbar.cpp \
ssh/ne7sshobject.cpp \
ssh/sshconnection.cpp \
- ssh/sshkeygenerator.cpp
+ ssh/sshkeygenerator.cpp \
+ helpmanager.cpp
HEADERS += mainwindow.h \
editmode.h \
editortoolbar.h \
ssh/ne7sshobject.h \
ssh/sshconnection.h \
- ssh/sshkeygenerator.h
+ ssh/sshkeygenerator.h \
+ helpmanager.h
FORMS += dialogs/newdialog.ui \
actionmanager/commandmappings.ui \
--- /dev/null
+/**************************************************************************
+**
+** 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 ®isteredDocs = 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 ®isteredDocs = 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 ®isteredDocs = 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
--- /dev/null
+/**************************************************************************
+**
+** 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
class ActionManager;
class EditorManager;
class FileManager;
+class HelpManager;
class IContext;
class MessageManager;
class MimeDatabase;
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;
#include "fancytabwidget.h"
#include "filemanager.h"
#include "generalsettings.h"
+#include "helpmanager.h"
#include "ifilefactory.h"
#include "messagemanager.h"
#include "modemanager.h"
m_statusBarManager(0),
m_modeManager(0),
m_mimeDatabase(new MimeDatabase),
+ m_helpManager(new HelpManager),
m_navigationWidget(0),
m_rightPaneWidget(0),
m_versionDialog(0),
m_modeManager = 0;
delete m_mimeDatabase;
m_mimeDatabase = 0;
+
+ delete m_helpManager;
+ m_helpManager = 0;
}
bool MainWindow::init(QString *errorMessage)
return m_mimeDatabase;
}
+HelpManager *MainWindow::helpManager() const
+{
+ return m_helpManager;
+}
+
IContext *MainWindow::contextObject(QWidget *widget)
{
return m_contextWidgets.value(widget);
class StatusBarWidget;
class EditorManager;
class FileManager;
+class HelpManager;
class IContext;
class IWizard;
class MessageManager;
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;
StatusBarManager *m_statusBarManager;
ModeManager *m_modeManager;
MimeDatabase *m_mimeDatabase;
+ HelpManager *m_helpManager;
FancyTabWidget *m_modeStack;
NavigationWidget *m_navigationWidget;
RightPaneWidget *m_rightPaneWidget;
TEMPLATE = lib
TARGET = CppEditor
DEFINES += CPPEDITOR_LIBRARY
-CONFIG += help
include(../../qtcreatorplugin.pri)
include(../../libs/utils/utils.pri)
include(../../shared/indenter/indenter.pri)
#include "cppplugin.h"
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <QtGui/QToolTip>
#include <QtGui/QTextCursor>
#include <QtGui/QTextBlock>
-#include <QtHelp/QHelpEngineCore>
using namespace CppEditor::Internal;
using namespace CPlusPlus;
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 *)));
}
}
}
- 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;
}
}
// 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;
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
-class QHelpEngineCore;
class QPoint;
QT_END_NAMESPACE
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
#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>
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.
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
+#include <QtCore/QUrl>
enum { indentation = 4 };
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()
#include "qt_private/qdesigner_integration_p.h"
+QT_FORWARD_DECLARE_CLASS(QUrl)
+
namespace Designer {
namespace Internal {
bool supportsToSlotNavigation() { return true; }
signals:
- void creatorHelpRequested(const QString &url);
+ void creatorHelpRequested(const QUrl &url);
public slots:
void updateSelection();
#include <QtGui/QStackedWidget>
#include <QtHelp/QHelpEngine>
-#include <QtHelp/QHelpEngineCore>
#include <QtHelp/QHelpSearchEngine>
using namespace Help::Internal;
}
}
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
+ QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
{
if (HelpViewer *viewer = currentHelpViewer()) {
QHelpSearchEngine *searchEngine =
- HelpManager::instance().helpEngine().searchEngine();
+ LocalHelpManager::helpEngine().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query();
QStringList terms;
#include "docsettingspage.h"
#include "helpconstants.h"
-#include "helpmanager.h"
+
+#include <coreplugin/helpmanager.h>
#include <QtCore/QCoreApplication>
#include <QtGui/QKeyEvent>
#include <QtGui/QMessageBox>
-#include <QtHelp/QHelpEngineCore>
-
using namespace Help::Internal;
DocSettingsPage::DocSettingsPage()
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();
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;
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();
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))
void finish() {}
virtual bool matches(const QString &s) const;
-signals:
- void documentationChanged();
-
private slots:
void addDocumentation();
void removeDocumentation();
#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)
{
}
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)),
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(' ')
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);
}
if (changed) {
- QHelpEngineCore *engine = &HelpManager::helpEngineCore();
+ QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
foreach (const QString &filter, m_removedFilters)
engine->removeCustomFilter(filter);
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
+
+void FilterSettingsPage::setHelpManager(LocalHelpManager *manager)
+{
+ m_helpManager = manager;
+}
namespace Help {
namespace Internal {
+class LocalHelpManager;
+
class FilterSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
void finish() {}
virtual bool matches(const QString &s) const;
+ void setHelpManager(LocalHelpManager *manager);
+
signals:
void filtersChanged();
QString m_searchKeywords;
QStringList m_removedFilters;
+
+ LocalHelpManager *m_helpManager;
};
} // namespace Help
#include <QtGui/QApplication>
#include <QtGui/QFileDialog>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
#if !defined(QT_NO_WEBKIT)
#include <QtWebKit/QWebSettings>
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();
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)
void GeneralSettingsPage::setDefaultPage()
{
- const QString &defaultHomePage = HelpManager::helpEngineCore()
+ const QString &defaultHomePage = LocalHelpManager::helpEngine()
.customValue(QLatin1String("DefaultHomePage"), QString()).toString();
m_ui.homePageLineEdit->setText(defaultHomePage);
}
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;
QFile file(fileName);
if (file.open(QIODevice::WriteOnly)) {
- XbelWriter writer(HelpManager::bookmarkManager().treeBookmarkModel());
+ XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
writer.writeToFile(&file);
}
}
**************************************************************************/
#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
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()) {
#include <locator/ilocatorfilter.h>
+#include <QtGui/QIcon>
+
namespace Help {
namespace Internal {
class HelpIndexFilter : public Locator::ILocatorFilter
{
Q_OBJECT
- class HelpFileReader;
public:
HelpIndexFilter();
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
#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();
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 ®isteredDocs = 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);
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;
}
**
**************************************************************************/
-#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
#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>
#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";
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;
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"))));
// 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()
// 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));
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()
qApp->processEvents();
qApp->setOverrideCursor(Qt::WaitCursor);
+ m_helpManager->setupGuiHelpEngine();
setupUi();
resetFilter();
- m_helpManager->setupGuiHelpEngine();
OpenPagesManager::instance().setupInitialPages();
qApp->restoreOverrideCursor();
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()));
void HelpPlugin::setupHelpEngineIfNeeded()
{
- if (Core::ICore::instance()->modeManager()->currentMode() == m_mode)
+ m_helpManager->setEngineNeedsUpdate();
+ if (Core::ModeManager::instance()->currentMode() == m_mode)
m_helpManager->setupGuiHelpEngine();
}
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: {
// 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()) {
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();
void HelpPlugin::filterDocumentation(const QString &customFilter)
{
- (&m_helpManager->helpEngine())->setCurrentFilter(customFilter);
+ LocalHelpManager::helpEngine().setCurrentFilter(customFilter);
}
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);
}
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);
} // Core
namespace Help {
-class HelpManager;
-
namespace Internal {
class CentralWidget;
class DocSettingsPage;
class GeneralSettingsPage;
class HelpMode;
class HelpViewer;
+class LocalHelpManager;
class OpenPagesManager;
class SearchWidget;
Core::SideBar *m_sideBar;
bool m_firstModeChange;
- HelpManager *m_helpManager;
+ LocalHelpManager *m_helpManager;
OpenPagesManager *m_openPagesManager;
Core::MiniSplitter *m_splitter;
#include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
using namespace Help::Internal;
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;
void HelpViewer::home()
{
- const QHelpEngineCore &engine = Help::HelpManager::helpEngineCore();
+ const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
QString homepage = engine.customValue(QLatin1String("HomePage"),
QLatin1String("")).toString();
#include <QtGui/QApplication>
#include <QtGui/QWheelEvent>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
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
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));
}
#include <QtGui/QComboBox>
#include <QtGui/QTreeView>
-#include <QtHelp/QHelpEngineCore>
+#include <QtHelp/QHelpEngine>
using namespace Help::Internal;
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"),
QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setMargin(4);
- searchEngine = (&HelpManager::helpEngine())->searchEngine();
+ searchEngine = (&LocalHelpManager::helpEngine())->searchEngine();
resultWidget = searchEngine->resultWidget();
QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();
connect(searchEngine, SIGNAL(indexingFinished()), this,
SLOT(indexingFinished()));
- QMetaObject::invokeMethod(&HelpManager::helpEngine(), "setupFinished",
+ QMetaObject::invokeMethod(&LocalHelpManager::helpEngine(), "setupFinished",
Qt::QueuedConnection);
}
}
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
include(../../qtcreatorplugin.pri)
include(qmljseditor_dependencies.pri)
-CONFIG += help
DEFINES += \
QMLJSEDITOR_LIBRARY \
QT_CREATOR
#include "qmljshoverhandler.h"
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <debugger/debuggerconstants.h>
#include <QtGui/QToolTip>
#include <QtGui/QTextCursor>
#include <QtGui/QTextBlock>
-#include <QtHelp/QHelpEngineCore>
using namespace Core;
using namespace QmlJS;
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 *)));
}
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;
QString helpId = QLatin1String("QML.");
helpId += baseClass;
- if (! m_helpEngine->linksForIdentifier(helpId).isEmpty()) {
+ if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) {
m_helpId = helpId;
break;
}
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
-class QHelpEngineCore;
class QPoint;
class QStringList;
QT_END_NAMESPACE
private:
ModelManagerInterface *m_modelManager;
- QHelpEngineCore *m_helpEngine;
QString m_helpId;
QString m_toolTip;
- bool m_helpEngineNeedsSetup;
};
} // namespace Internal
<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>
#include "ui_gettingstartedwelcomepagewidget.h"
#include <coreplugin/icore.h>
+#include <coreplugin/helpmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/mainwindow.h>
#include <extensionsystem/pluginmanager.h>
-#include <help/helpmanager.h>
-
#include <QtCore/QDateTime>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
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"));
}
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)
#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>
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) {
#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,
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
- (&Help::HelpManager::helpEngineCore())->setCustomValue(QLatin1String("Bookmarks"),
+ (&LocalHelpManager::helpEngine())->setCustomValue(QLatin1String("Bookmarks"),
bookmarks);
}
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()) {
: 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);
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,