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:
@@ -211,7 +211,7 @@ const HelpItem::Links &HelpItem::links() const
|
||||
m_helpLinks.emplace(Links{{m_keyword, m_helpUrl}});
|
||||
} else {
|
||||
m_helpLinks.emplace(); // set a value even if there are no help IDs
|
||||
QMap<QString, QUrl> helpLinks;
|
||||
QMultiMap<QString, QUrl> helpLinks;
|
||||
for (const QString &id : m_helpIds) {
|
||||
helpLinks = Core::HelpManager::linksForIdentifier(id);
|
||||
if (!helpLinks.isEmpty()) {
|
||||
|
@@ -86,14 +86,14 @@ void unregisterDocumentation(const QStringList &fileNames)
|
||||
m_instance->unregisterDocumentation(fileNames);
|
||||
}
|
||||
|
||||
QMap<QString, QUrl> linksForIdentifier(const QString &id)
|
||||
QMultiMap<QString, QUrl> linksForIdentifier(const QString &id)
|
||||
{
|
||||
return checkInstance() ? m_instance->linksForIdentifier(id) : QMap<QString, QUrl>();
|
||||
return checkInstance() ? m_instance->linksForIdentifier(id) : QMultiMap<QString, QUrl>();
|
||||
}
|
||||
|
||||
QMap<QString, QUrl> linksForKeyword(const QString &keyword)
|
||||
QMultiMap<QString, QUrl> linksForKeyword(const QString &keyword)
|
||||
{
|
||||
return checkInstance() ? m_instance->linksForKeyword(keyword) : QMap<QString, QUrl>();
|
||||
return checkInstance() ? m_instance->linksForKeyword(keyword) : QMultiMap<QString, QUrl>();
|
||||
}
|
||||
|
||||
QByteArray fileData(const QUrl &url)
|
||||
|
@@ -63,8 +63,8 @@ CORE_EXPORT QString documentationPath();
|
||||
CORE_EXPORT void registerDocumentation(const QStringList &fileNames);
|
||||
CORE_EXPORT void unregisterDocumentation(const QStringList &fileNames);
|
||||
|
||||
CORE_EXPORT QMap<QString, QUrl> linksForIdentifier(const QString &id);
|
||||
CORE_EXPORT QMap<QString, QUrl> linksForKeyword(const QString &id);
|
||||
CORE_EXPORT QMultiMap<QString, QUrl> linksForIdentifier(const QString &id);
|
||||
CORE_EXPORT QMultiMap<QString, QUrl> linksForKeyword(const QString &id);
|
||||
CORE_EXPORT QByteArray fileData(const QUrl &url);
|
||||
|
||||
CORE_EXPORT void showHelpUrl(const QUrl &url, HelpViewerLocation location = HelpModeAlways);
|
||||
|
@@ -40,8 +40,8 @@ protected:
|
||||
public:
|
||||
virtual void registerDocumentation(const QStringList &fileNames) = 0;
|
||||
virtual void unregisterDocumentation(const QStringList &fileNames) = 0;
|
||||
virtual QMap<QString, QUrl> linksForIdentifier(const QString &id) = 0;
|
||||
virtual QMap<QString, QUrl> linksForKeyword(const QString &keyword) = 0;
|
||||
virtual QMultiMap<QString, QUrl> linksForIdentifier(const QString &id) = 0;
|
||||
virtual QMultiMap<QString, QUrl> linksForKeyword(const QString &keyword) = 0;
|
||||
virtual QByteArray fileData(const QUrl &url) = 0;
|
||||
virtual void showHelpUrl(const QUrl &url, HelpViewerLocation location = HelpModeAlways) = 0;
|
||||
};
|
||||
|
@@ -24,8 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "filtersettingspage.h"
|
||||
|
||||
#include "helpconstants.h"
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
#include "helpmanager.h"
|
||||
|
||||
#include <filternamedialog.h>
|
||||
@@ -38,6 +40,15 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#else
|
||||
|
||||
#include <QtCore/QVersionNumber>
|
||||
#include <QtHelp/QHelpFilterEngine>
|
||||
#include <QtHelp/QHelpFilterSettingsWidget>
|
||||
#include "localhelpmanager.h"
|
||||
|
||||
#endif
|
||||
|
||||
using namespace Help::Internal;
|
||||
|
||||
FilterSettingsPage::FilterSettingsPage()
|
||||
@@ -47,6 +58,8 @@ FilterSettingsPage::FilterSettingsPage()
|
||||
setCategory(Help::Constants::HELP_CATEGORY);
|
||||
}
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
QWidget *FilterSettingsPage::widget()
|
||||
{
|
||||
if (!m_widget) {
|
||||
@@ -254,3 +267,48 @@ void FilterSettingsPage::updateFilterDescription(const QString &filter)
|
||||
{
|
||||
m_ui.label->setText(msgFilterLabel(filter));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
QWidget *FilterSettingsPage::widget()
|
||||
{
|
||||
if (!m_widget) {
|
||||
LocalHelpManager::setupGuiHelpEngine();
|
||||
m_widget = new QHelpFilterSettingsWidget(nullptr);
|
||||
m_widget->readSettings(LocalHelpManager::filterEngine());
|
||||
|
||||
connect(Core::HelpManager::Signals::instance(),
|
||||
&Core::HelpManager::Signals::documentationChanged,
|
||||
this,
|
||||
&FilterSettingsPage::updateFilterPage);
|
||||
|
||||
updateFilterPage();
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void FilterSettingsPage::apply()
|
||||
{
|
||||
if (m_widget->applySettings(LocalHelpManager::filterEngine()))
|
||||
emit filtersChanged();
|
||||
|
||||
m_widget->readSettings(LocalHelpManager::filterEngine());
|
||||
}
|
||||
|
||||
void FilterSettingsPage::finish()
|
||||
{
|
||||
disconnect(Core::HelpManager::Signals::instance(),
|
||||
&Core::HelpManager::Signals::documentationChanged,
|
||||
this,
|
||||
&FilterSettingsPage::updateFilterPage);
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
void FilterSettingsPage::updateFilterPage()
|
||||
{
|
||||
m_widget->setAvailableComponents(LocalHelpManager::filterEngine()->availableComponents());
|
||||
m_widget->setAvailableVersions(LocalHelpManager::filterEngine()->availableVersions());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -25,11 +25,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_filtersettingspage.h"
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
#include "ui_filtersettingspage.h"
|
||||
#else
|
||||
class QHelpFilterSettingsWidget;
|
||||
#endif
|
||||
|
||||
namespace Help {
|
||||
namespace Internal {
|
||||
|
||||
@@ -48,9 +53,11 @@ signals:
|
||||
void filtersChanged();
|
||||
|
||||
private:
|
||||
|
||||
void updateFilterPage();
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
void updateAttributes(QListWidgetItem *item);
|
||||
void updateFilterMap();
|
||||
void updateFilterPage();
|
||||
void addFilter();
|
||||
void removeFilter();
|
||||
void updateFilterDescription(const QString &filter);
|
||||
@@ -64,6 +71,10 @@ private:
|
||||
FilterMap m_filterMapBackup;
|
||||
|
||||
QStringList m_removedFilters;
|
||||
#else
|
||||
QPointer<QHelpFilterSettingsWidget> m_widget;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
} // namespace Help
|
||||
|
@@ -4,6 +4,10 @@ INCLUDEPATH += $$PWD
|
||||
|
||||
include(../../qtcreatorplugin.pri)
|
||||
|
||||
minQtVersion(5, 15, 0) {
|
||||
DEFINES += HELP_NEW_FILTER_ENGINE
|
||||
}
|
||||
|
||||
DEFINES += \
|
||||
QT_CLUCENE_SUPPORT \
|
||||
HELP_LIBRARY
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import qbs 1.0
|
||||
import qbs.Utilities
|
||||
|
||||
Project {
|
||||
name: "Help"
|
||||
@@ -28,6 +28,8 @@ Project {
|
||||
defines.push("QTC_WEBENGINE_HELPVIEWER");
|
||||
if (qlitehtml.present)
|
||||
defines.push("QTC_LITEHTML_HELPVIEWER")
|
||||
if (Utilities.versionCompare(Qt.core.version, "5.15") >= 0)
|
||||
defines.push("HELP_NEW_FILTER_ENGINE");
|
||||
return defines;
|
||||
}
|
||||
|
||||
|
@@ -32,15 +32,27 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlDriver>
|
||||
#include <QSqlError>
|
||||
#include <QSqlQuery>
|
||||
|
||||
#else
|
||||
|
||||
#include "localhelpmanager.h"
|
||||
#include <QtHelp/QHelpEngine>
|
||||
#include <QtHelp/QHelpFilterEngine>
|
||||
#include <QtHelp/QHelpLink>
|
||||
|
||||
#endif
|
||||
|
||||
using namespace Core;
|
||||
using namespace Help;
|
||||
@@ -66,6 +78,8 @@ HelpIndexFilter::HelpIndexFilter()
|
||||
|
||||
HelpIndexFilter::~HelpIndexFilter() = default;
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
void HelpIndexFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
Q_UNUSED(entry)
|
||||
@@ -133,6 +147,70 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
|
||||
return entries;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool HelpIndexFilter::updateCache(QFutureInterface<LocatorFilterEntry> &future,
|
||||
const QStringList &cache, const QString &entry)
|
||||
{
|
||||
const Qt::CaseSensitivity cs = caseSensitivity(entry);
|
||||
QStringList bestKeywords;
|
||||
QStringList worseKeywords;
|
||||
bestKeywords.reserve(cache.size());
|
||||
worseKeywords.reserve(cache.size());
|
||||
for (const QString &keyword : cache) {
|
||||
if (future.isCanceled())
|
||||
return false;
|
||||
if (keyword.startsWith(entry, cs))
|
||||
bestKeywords.append(keyword);
|
||||
else if (keyword.contains(entry, cs))
|
||||
worseKeywords.append(keyword);
|
||||
}
|
||||
bestKeywords << worseKeywords;
|
||||
m_lastIndicesCache = bestKeywords;
|
||||
m_lastEntry = entry;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry)
|
||||
{
|
||||
m_mutex.lock(); // guard m_needsUpdate
|
||||
bool forceUpdate = m_needsUpdate;
|
||||
m_mutex.unlock();
|
||||
|
||||
if (forceUpdate) {
|
||||
QStringList indices;
|
||||
QMetaObject::invokeMethod(this, "allIndices", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(QStringList, indices));
|
||||
m_mutex.lock(); // guard m_needsUpdate
|
||||
m_needsUpdate = false;
|
||||
m_mutex.unlock();
|
||||
m_allIndicesCache = indices;
|
||||
// force updating the cache taking the m_allIndicesCache
|
||||
m_lastIndicesCache = QStringList();
|
||||
m_lastEntry = QString();
|
||||
}
|
||||
|
||||
const QStringList cacheBase = m_lastEntry.isEmpty() || !entry.contains(m_lastEntry)
|
||||
? m_allIndicesCache : m_lastIndicesCache;
|
||||
|
||||
if (!updateCache(future, cacheBase, entry))
|
||||
return QList<LocatorFilterEntry>();
|
||||
|
||||
const Qt::CaseSensitivity cs = caseSensitivity(entry);
|
||||
QList<LocatorFilterEntry> entries;
|
||||
for (const QString &keyword : qAsConst(m_lastIndicesCache)) {
|
||||
const int index = keyword.indexOf(entry, 0, cs);
|
||||
LocatorFilterEntry filterEntry(this, keyword, QVariant(), m_icon);
|
||||
filterEntry.highlightInfo = {index, entry.length()};
|
||||
entries.append(filterEntry);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HelpIndexFilter::accept(LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const
|
||||
{
|
||||
@@ -140,7 +218,14 @@ void HelpIndexFilter::accept(LocatorFilterEntry selection,
|
||||
Q_UNUSED(selectionStart)
|
||||
Q_UNUSED(selectionLength)
|
||||
const QString &key = selection.displayName;
|
||||
const QMap<QString, QUrl> &links = HelpManager::instance()->linksForKeyword(key);
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
const QMultiMap<QString, QUrl> &links = HelpManager::instance()->linksForKeyword(key);
|
||||
#else
|
||||
QMultiMap<QString, QUrl> links;
|
||||
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(key, QString());
|
||||
for (const auto doc : docs)
|
||||
links.insert(doc.title, doc.url);
|
||||
#endif
|
||||
emit linksActivated(links, key);
|
||||
}
|
||||
|
||||
@@ -150,6 +235,8 @@ void HelpIndexFilter::refresh(QFutureInterface<void> &future)
|
||||
invalidateCache();
|
||||
}
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
QSet<QString> HelpIndexFilter::searchMatches(const QString &databaseFilePath,
|
||||
const QString &term, int limit)
|
||||
{
|
||||
@@ -180,6 +267,16 @@ QSet<QString> HelpIndexFilter::searchMatches(const QString &databaseFilePath,
|
||||
return keywords;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
QStringList HelpIndexFilter::allIndices() const
|
||||
{
|
||||
LocalHelpManager::setupGuiHelpEngine();
|
||||
return LocalHelpManager::filterEngine()->indices(QString());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HelpIndexFilter::invalidateCache()
|
||||
{
|
||||
m_mutex.lock();
|
||||
|
@@ -42,24 +42,38 @@ public:
|
||||
~HelpIndexFilter() final;
|
||||
|
||||
// ILocatorFilter
|
||||
void prepareSearch(const QString &entry) override;
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
void accept(Core::LocatorFilterEntry selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
void refresh(QFutureInterface<void> &future) override;
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
void prepareSearch(const QString &entry) override;
|
||||
Q_INVOKABLE QSet<QString> searchMatches(const QString &databaseFilePath,
|
||||
const QString &term, int limit);
|
||||
#else
|
||||
Q_INVOKABLE QStringList allIndices() const;
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void linksActivated(const QMap<QString, QUrl> &links, const QString &key) const;
|
||||
void linksActivated(const QMultiMap<QString, QUrl> &links, const QString &key) const;
|
||||
|
||||
private:
|
||||
void invalidateCache();
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
QStringList m_helpDatabases;
|
||||
QSet<QString> m_keywordCache;
|
||||
QString m_searchTermCache;
|
||||
#else
|
||||
bool updateCache(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QStringList &cache, const QString &entry);
|
||||
|
||||
QStringList m_allIndicesCache;
|
||||
QStringList m_lastIndicesCache;
|
||||
QString m_lastEntry;
|
||||
#endif
|
||||
bool m_needsUpdate = true;
|
||||
QMutex m_mutex;
|
||||
QIcon m_icon;
|
||||
|
@@ -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())
|
||||
|
@@ -40,8 +40,6 @@ class HelpManager : public QObject, public Core::HelpManager::Implementation
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using Filters = QHash<QString, QStringList>;
|
||||
|
||||
explicit HelpManager(QObject *parent = nullptr);
|
||||
~HelpManager() override;
|
||||
|
||||
@@ -56,8 +54,8 @@ public:
|
||||
static void registerUserDocumentation(const QStringList &filePaths);
|
||||
static QSet<QString> userDocumentationPaths();
|
||||
|
||||
QMap<QString, QUrl> linksForIdentifier(const QString &id) override;
|
||||
QMap<QString, QUrl> linksForKeyword(const QString &key) override;
|
||||
QMultiMap<QString, QUrl> linksForIdentifier(const QString &id) override;
|
||||
QMultiMap<QString, QUrl> linksForKeyword(const QString &key) override;
|
||||
|
||||
static QUrl findFile(const QUrl &url);
|
||||
QByteArray fileData(const QUrl &url) override;
|
||||
@@ -69,12 +67,16 @@ public:
|
||||
static void setCustomValue(const QString &key, const QVariant &value);
|
||||
static QVariant customValue(const QString &key, const QVariant &value = QVariant());
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
using Filters = QHash<QString, QStringList>;
|
||||
|
||||
static Filters filters();
|
||||
static Filters fixedFilters();
|
||||
|
||||
static Filters userDefinedFilters();
|
||||
static void removeUserDefinedFilter(const QString &filter);
|
||||
static void addUserDefinedFilter(const QString &filter, const QStringList &attr);
|
||||
#endif
|
||||
|
||||
static void aboutToShutdown();
|
||||
|
||||
|
@@ -116,7 +116,7 @@ public:
|
||||
void activateContents();
|
||||
|
||||
void saveExternalWindowSettings();
|
||||
void showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key);
|
||||
void showLinksInCurrentViewer(const QMultiMap<QString, QUrl> &links, const QString &key);
|
||||
|
||||
void setupHelpEngineIfNeeded();
|
||||
|
||||
@@ -124,7 +124,10 @@ public:
|
||||
|
||||
void slotSystemInformation();
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
void resetFilter();
|
||||
#endif
|
||||
|
||||
static void activateHelpMode() { ModeManager::activateMode(Constants::ID_MODE_HELP); }
|
||||
static bool canShowHelpSideBySide();
|
||||
|
||||
@@ -314,6 +317,8 @@ ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
void HelpPluginPrivate::resetFilter()
|
||||
{
|
||||
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
|
||||
@@ -348,6 +353,8 @@ void HelpPluginPrivate::resetFilter()
|
||||
LocalHelpManager::instance(), &LocalHelpManager::updateFilterModel);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HelpPluginPrivate::saveExternalWindowSettings()
|
||||
{
|
||||
if (!m_externalWindow)
|
||||
@@ -436,7 +443,7 @@ HelpWidget *HelpPlugin::modeHelpWidget()
|
||||
return dd->m_centralWidget;
|
||||
}
|
||||
|
||||
void HelpPluginPrivate::showLinksInCurrentViewer(const QMap<QString, QUrl> &links, const QString &key)
|
||||
void HelpPluginPrivate::showLinksInCurrentViewer(const QMultiMap<QString, QUrl> &links, const QString &key)
|
||||
{
|
||||
if (links.size() < 1)
|
||||
return;
|
||||
@@ -577,7 +584,7 @@ void HelpPluginPrivate::showContextHelp(const HelpItem &contextHelp)
|
||||
} else if (links.size() == 1 && !contextHelp.isFuzzyMatch()) {
|
||||
showHelpUrl(links.front().second, LocalHelpManager::contextHelpOption());
|
||||
} else {
|
||||
QMap<QString, QUrl> map;
|
||||
QMultiMap<QString, QUrl> map;
|
||||
for (const HelpItem::Link &link : links)
|
||||
map.insert(link.first, link.second);
|
||||
auto tc = new TopicChooser(ICore::dialogParent(), contextHelp.keyword(), map);
|
||||
@@ -683,7 +690,9 @@ void HelpPluginPrivate::doSetupIfNeeded()
|
||||
{
|
||||
LocalHelpManager::setupGuiHelpEngine();
|
||||
if (m_setupNeeded) {
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
resetFilter();
|
||||
#endif
|
||||
m_setupNeeded = false;
|
||||
m_centralWidget->openPagesManager()->setupInitialPages();
|
||||
LocalHelpManager::bookmarkManager().setupBookmarkModels();
|
||||
|
@@ -61,6 +61,11 @@
|
||||
#include <QStatusBar>
|
||||
#include <QToolButton>
|
||||
|
||||
#ifdef HELP_NEW_FILTER_ENGINE
|
||||
#include <QtHelp/QHelpEngine>
|
||||
#include <QtHelp/QHelpFilterEngine>
|
||||
#endif
|
||||
|
||||
static const char kWindowSideBarSettingsKey[] = "Help/WindowSideBar";
|
||||
static const char kModeSideBarSettingsKey[] = "Help/ModeSideBar";
|
||||
|
||||
@@ -359,15 +364,24 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
||||
|
||||
m_filterComboBox = new QComboBox;
|
||||
m_filterComboBox->setMinimumContentsLength(15);
|
||||
layout->addWidget(m_filterComboBox);
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
m_filterComboBox->setModel(LocalHelpManager::filterModel());
|
||||
m_filterComboBox->setCurrentIndex(LocalHelpManager::filterIndex());
|
||||
layout->addWidget(m_filterComboBox);
|
||||
connect(m_filterComboBox, QOverload<int>::of(&QComboBox::activated),
|
||||
LocalHelpManager::instance(), &LocalHelpManager::setFilterIndex);
|
||||
connect(LocalHelpManager::instance(),
|
||||
&LocalHelpManager::filterIndexChanged,
|
||||
m_filterComboBox,
|
||||
&QComboBox::setCurrentIndex);
|
||||
#else
|
||||
connect(&LocalHelpManager::helpEngine(), &QHelpEngine::setupFinished,
|
||||
this, &HelpWidget::setupFilterCombo, Qt::QueuedConnection);
|
||||
connect(m_filterComboBox, QOverload<int>::of(&QComboBox::activated),
|
||||
this, &HelpWidget::filterDocumentation);
|
||||
connect(LocalHelpManager::filterEngine(), &QHelpFilterEngine::filterActivated,
|
||||
this, &HelpWidget::currentFilterChanged);
|
||||
#endif
|
||||
|
||||
Core::ActionContainer *windowMenu = Core::ActionManager::actionContainer(
|
||||
Core::Constants::M_WINDOW);
|
||||
@@ -487,6 +501,41 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
void HelpWidget::setupFilterCombo()
|
||||
{
|
||||
const QString currentFilter = LocalHelpManager::filterEngine()->activeFilter();
|
||||
m_filterComboBox->clear();
|
||||
m_filterComboBox->addItem(tr("Unfiltered"));
|
||||
const QStringList allFilters = LocalHelpManager::filterEngine()->filters();
|
||||
if (!allFilters.isEmpty())
|
||||
m_filterComboBox->insertSeparator(1);
|
||||
for (const QString &filter : allFilters)
|
||||
m_filterComboBox->addItem(filter, filter);
|
||||
|
||||
int idx = m_filterComboBox->findData(currentFilter);
|
||||
if (idx < 0)
|
||||
idx = 0;
|
||||
m_filterComboBox->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
void HelpWidget::filterDocumentation(int filterIndex)
|
||||
{
|
||||
const QString filter = m_filterComboBox->itemData(filterIndex).toString();
|
||||
LocalHelpManager::filterEngine()->setActiveFilter(filter);
|
||||
}
|
||||
|
||||
void HelpWidget::currentFilterChanged(const QString &filter)
|
||||
{
|
||||
int index = m_filterComboBox->findData(filter);
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
m_filterComboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HelpWidget::~HelpWidget()
|
||||
{
|
||||
saveState();
|
||||
@@ -753,7 +802,7 @@ HelpViewer *HelpWidget::openNewPage(const QUrl &url)
|
||||
return page;
|
||||
}
|
||||
|
||||
void HelpWidget::showLinks(const QMap<QString, QUrl> &links,
|
||||
void HelpWidget::showLinks(const QMultiMap<QString, QUrl> &links,
|
||||
const QString &keyword, bool newPage)
|
||||
{
|
||||
if (links.size() < 1)
|
||||
|
@@ -96,7 +96,7 @@ public:
|
||||
void open(const QUrl &url, bool newPage = false);
|
||||
HelpViewer *openNewPage(const QUrl &url);
|
||||
void openFromSearch(const QUrl &url, const QStringList &searchTerms, bool newPage = false);
|
||||
void showLinks(const QMap<QString, QUrl> &links, const QString &key,
|
||||
void showLinks(const QMultiMap<QString, QUrl> &links, const QString &key,
|
||||
bool newPage = false);
|
||||
void activateSideBarItem(const QString &id);
|
||||
|
||||
@@ -142,6 +142,12 @@ private:
|
||||
void addSideBar();
|
||||
QString sideBarSettingsKey() const;
|
||||
|
||||
#ifdef HELP_NEW_FILTER_ENGINE
|
||||
void setupFilterCombo();
|
||||
void filterDocumentation(int filterIndex);
|
||||
void currentFilterChanged(const QString &filter);
|
||||
#endif
|
||||
|
||||
OpenPagesModel m_model;
|
||||
OpenPagesManager *m_openPagesManager = nullptr;
|
||||
Core::IContext *m_context = nullptr;
|
||||
|
@@ -70,10 +70,14 @@ QHelpEngine* LocalHelpManager::m_guiEngine = nullptr;
|
||||
QMutex LocalHelpManager::m_bkmarkMutex;
|
||||
BookmarkManager* LocalHelpManager::m_bookmarkManager = nullptr;
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
QStandardItemModel *LocalHelpManager::m_filterModel = nullptr;
|
||||
QString LocalHelpManager::m_currentFilter = QString();
|
||||
int LocalHelpManager::m_currentFilterIndex = -1;
|
||||
|
||||
#endif
|
||||
|
||||
static const char kHelpHomePageKey[] = "Help/HomePage";
|
||||
static const char kFontFamilyKey[] = "Help/FallbackFontFamily";
|
||||
static const char kFontStyleNameKey[] = "Help/FallbackFontStyleName";
|
||||
@@ -123,7 +127,9 @@ LocalHelpManager::LocalHelpManager(QObject *parent)
|
||||
{
|
||||
m_instance = this;
|
||||
qRegisterMetaType<Help::Internal::LocalHelpManager::HelpData>("Help::Internal::LocalHelpManager::HelpData");
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
m_filterModel = new QStandardItemModel(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
LocalHelpManager::~LocalHelpManager()
|
||||
@@ -396,8 +402,12 @@ QHelpEngine &LocalHelpManager::helpEngine()
|
||||
{
|
||||
if (!m_guiEngine) {
|
||||
QMutexLocker _(&m_guiMutex);
|
||||
if (!m_guiEngine)
|
||||
if (!m_guiEngine) {
|
||||
m_guiEngine = new QHelpEngine(QString());
|
||||
#ifdef HELP_NEW_FILTER_ENGINE
|
||||
m_guiEngine->setUsesFilterEngine(true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return *m_guiEngine;
|
||||
}
|
||||
@@ -495,6 +505,8 @@ LocalHelpManager::HelpData LocalHelpManager::helpData(const QUrl &url)
|
||||
return data;
|
||||
}
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
|
||||
QAbstractItemModel *LocalHelpManager::filterModel()
|
||||
{
|
||||
return m_filterModel;
|
||||
@@ -544,6 +556,15 @@ void LocalHelpManager::updateFilterModel()
|
||||
emit m_instance->filterIndexChanged(m_currentFilterIndex);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
QHelpFilterEngine *LocalHelpManager::filterEngine()
|
||||
{
|
||||
return helpEngine().filterEngine();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool LocalHelpManager::canOpenOnlineHelp(const QUrl &url)
|
||||
{
|
||||
const QString address = url.toString();
|
||||
|
@@ -31,9 +31,12 @@
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <functional>
|
||||
#else
|
||||
QT_FORWARD_DECLARE_CLASS(QHelpFilterEngine)
|
||||
#endif
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QHelpEngine)
|
||||
|
||||
@@ -116,17 +119,23 @@ public:
|
||||
static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString);
|
||||
Q_INVOKABLE static Help::Internal::LocalHelpManager::HelpData helpData(const QUrl &url);
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
static QAbstractItemModel *filterModel();
|
||||
static void setFilterIndex(int index);
|
||||
static int filterIndex();
|
||||
|
||||
static void updateFilterModel();
|
||||
#else
|
||||
static QHelpFilterEngine *filterEngine();
|
||||
#endif
|
||||
|
||||
static bool canOpenOnlineHelp(const QUrl &url);
|
||||
static bool openOnlineHelp(const QUrl &url);
|
||||
|
||||
signals:
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
void filterIndexChanged(int index);
|
||||
#endif
|
||||
void fallbackFontChanged(const QFont &font);
|
||||
void returnOnCloseChanged();
|
||||
void scrollWheelZoomingEnabledChanged(bool enabled);
|
||||
@@ -136,9 +145,11 @@ private:
|
||||
static bool m_guiNeedsSetup;
|
||||
static bool m_needsCollectionFile;
|
||||
|
||||
#ifndef HELP_NEW_FILTER_ENGINE
|
||||
static QStandardItemModel *m_filterModel;
|
||||
static QString m_currentFilter;
|
||||
static int m_currentFilterIndex;
|
||||
#endif
|
||||
|
||||
static QMutex m_guiMutex;
|
||||
static QHelpEngine *m_guiEngine;
|
||||
|
@@ -196,7 +196,7 @@ void IndexWindow::disableSearchLineEdit()
|
||||
void IndexWindow::open(const QModelIndex &index, bool newPage)
|
||||
{
|
||||
QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
|
||||
QMap<QString, QUrl> links = LocalHelpManager::helpEngine().indexModel()->linksForKeyword(keyword);
|
||||
QMultiMap<QString, QUrl> links = LocalHelpManager::helpEngine().indexModel()->linksForKeyword(keyword);
|
||||
emit linksActivated(links, keyword, newPage);
|
||||
}
|
||||
|
||||
|
@@ -88,7 +88,7 @@ public:
|
||||
void setOpenInNewPageActionVisible(bool visible);
|
||||
|
||||
signals:
|
||||
void linksActivated(const QMap<QString, QUrl> &links,
|
||||
void linksActivated(const QMultiMap<QString, QUrl> &links,
|
||||
const QString &keyword, bool newPage);
|
||||
|
||||
private:
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
||||
const QMap<QString, QUrl> &links)
|
||||
const QMultiMap<QString, QUrl> &links)
|
||||
: QDialog(parent)
|
||||
, m_filterModel(new QSortFilterProxyModel(this))
|
||||
{
|
||||
@@ -49,7 +49,7 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
||||
m_filterModel->setSourceModel(model);
|
||||
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
||||
QMap<QString, QUrl>::const_iterator it = links.constBegin();
|
||||
QMultiMap<QString, QUrl>::const_iterator it = links.constBegin();
|
||||
for (; it != links.constEnd(); ++it) {
|
||||
m_links.append(it.value());
|
||||
QStandardItem *item = new QStandardItem(it.key());
|
||||
|
@@ -42,7 +42,7 @@ class TopicChooser : public QDialog
|
||||
|
||||
public:
|
||||
TopicChooser(QWidget *parent, const QString &keyword,
|
||||
const QMap<QString, QUrl> &links);
|
||||
const QMultiMap<QString, QUrl> &links);
|
||||
|
||||
QUrl link() const;
|
||||
|
||||
|
Reference in New Issue
Block a user