forked from qt-creator/qt-creator
Integrate new filter engine
Adapt the code to deprecated usage of map as a multi map, hence all cases replaced by QMultiMap. Change-Id: I2d480467cd6e91d3e880555e6a21058dec056b3f Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
This commit is contained in:
@@ -43,10 +43,15 @@
|
||||
#include <QHelpEngineCore>
|
||||
|
||||
#include <QMutexLocker>
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlDriver>
|
||||
#include <QSqlError>
|
||||
#include <QSqlQuery>
|
||||
#else
|
||||
#include <QtHelp/QHelpLink>
|
||||
#endif
|
||||
|
||||
using namespace Core;
|
||||
|
||||
@@ -84,6 +89,8 @@ struct HelpManagerPrivate
|
||||
static HelpManager *m_instance = nullptr;
|
||||
static HelpManagerPrivate *d = nullptr;
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
// -- DbCleaner
|
||||
|
||||
struct DbCleaner
|
||||
@@ -93,6 +100,8 @@ struct DbCleaner
|
||||
QString name;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// -- HelpManager
|
||||
|
||||
HelpManager::HelpManager(QObject *parent) :
|
||||
@@ -225,20 +234,36 @@ QSet<QString> HelpManager::userDocumentationPaths()
|
||||
}
|
||||
|
||||
// This should go into Qt 4.8 once we start using it for Qt Creator
|
||||
QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key)
|
||||
QMultiMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key)
|
||||
{
|
||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
||||
if (key.isEmpty())
|
||||
return {};
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
return d->m_helpEngine->linksForKeyword(key);
|
||||
#else
|
||||
QMultiMap<QString, QUrl> links;
|
||||
const QList<QHelpLink> docs = d->m_helpEngine->documentsForKeyword(key, QString());
|
||||
for (const auto doc : docs)
|
||||
links.insert(doc.title, doc.url);
|
||||
return links;
|
||||
#endif
|
||||
}
|
||||
|
||||
QMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
||||
QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
||||
{
|
||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
||||
if (id.isEmpty())
|
||||
return {};
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
return d->m_helpEngine->linksForIdentifier(id);
|
||||
#else
|
||||
QMultiMap<QString, QUrl> links;
|
||||
const QList<QHelpLink> docs = d->m_helpEngine->documentsForIdentifier(id, QString());
|
||||
for (const auto doc : docs)
|
||||
links.insert(doc.title, doc.url);
|
||||
return links;
|
||||
#endif
|
||||
}
|
||||
|
||||
QUrl HelpManager::findFile(const QUrl &url)
|
||||
@@ -292,6 +317,8 @@ QVariant HelpManager::customValue(const QString &key, const QVariant &value)
|
||||
return d->m_helpEngine->customValue(key, value);
|
||||
}
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
HelpManager::Filters HelpManager::filters()
|
||||
{
|
||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
||||
@@ -358,6 +385,8 @@ void HelpManager::addUserDefinedFilter(const QString &filter, const QStringList
|
||||
emit m_instance->collectionFileChanged();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HelpManager::aboutToShutdown()
|
||||
{
|
||||
if (d && d->m_registerFuture.isRunning()) {
|
||||
@@ -378,6 +407,9 @@ void HelpManager::setupHelpManager()
|
||||
|
||||
// create the help engine
|
||||
d->m_helpEngine = new QHelpEngineCore(collectionFilePath(), m_instance);
|
||||
#ifdef HELP_NEW_FILTER_ENGINE
|
||||
d->m_helpEngine->setUsesFilterEngine(true);
|
||||
#endif
|
||||
d->m_helpEngine->setupData();
|
||||
|
||||
for (const QString &filePath : d->documentationFromInstaller())
|
||||
|
||||
Reference in New Issue
Block a user