diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2019-11-29 09:54:30 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2019-12-10 13:57:14 +0100 |
commit | 1c39ee57d151d3b06d9c6fda9c99b02ebf9d94d5 (patch) | |
tree | 8d7af461970b6ca0ab96f85f7d666cec0f55b019 | |
parent | 8ff052f51642b6243db9ede23bf4d2ff695bc6a5 (diff) | |
download | qttools-1c39ee57d151d3b06d9c6fda9c99b02ebf9d94d5.tar.gz |
QtHelp: add new useful methods
This methods are going to be used in QtCreator help
integration.
Change-Id: If226ba3e612af013694afc8508527516e3e0daea
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler.cpp | 6 | ||||
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler_p.h | 2 | ||||
-rw-r--r-- | src/assistant/help/qhelpenginecore.cpp | 43 | ||||
-rw-r--r-- | src/assistant/help/qhelpenginecore.h | 2 | ||||
-rw-r--r-- | src/assistant/help/qhelpfilterengine.cpp | 41 | ||||
-rw-r--r-- | src/assistant/help/qhelpfilterengine.h | 4 |
6 files changed, 90 insertions, 8 deletions
diff --git a/src/assistant/help/qhelpcollectionhandler.cpp b/src/assistant/help/qhelpcollectionhandler.cpp index a7bea5494..1ef0ffa9a 100644 --- a/src/assistant/help/qhelpcollectionhandler.cpp +++ b/src/assistant/help/qhelpcollectionhandler.cpp @@ -588,13 +588,13 @@ QStringList QHelpCollectionHandler::availableComponents() const return list; } -QStringList QHelpCollectionHandler::availableVersions() const +QList<QVersionNumber> QHelpCollectionHandler::availableVersions() const { - QStringList list; + QList<QVersionNumber> list; if (m_query) { m_query->exec(QLatin1String("SELECT DISTINCT Version FROM VersionTable ORDER BY Version")); while (m_query->next()) - list.append(m_query->value(0).toString()); + list.append(QVersionNumber::fromString(m_query->value(0).toString())); } return list; } diff --git a/src/assistant/help/qhelpcollectionhandler_p.h b/src/assistant/help/qhelpcollectionhandler_p.h index 7679fccf7..5c0170d8c 100644 --- a/src/assistant/help/qhelpcollectionhandler_p.h +++ b/src/assistant/help/qhelpcollectionhandler_p.h @@ -158,7 +158,7 @@ public: QStringList filters() const; QStringList availableComponents() const; - QStringList availableVersions() const; + QList<QVersionNumber> availableVersions() const; QMap<QString, QString> namespaceToComponent() const; QMap<QString, QVersionNumber> namespaceToVersion() const; QHelpFilterData filterData(const QString &filterName) const; diff --git a/src/assistant/help/qhelpenginecore.cpp b/src/assistant/help/qhelpenginecore.cpp index f61c2207d..c9fbde232 100644 --- a/src/assistant/help/qhelpenginecore.cpp +++ b/src/assistant/help/qhelpenginecore.cpp @@ -620,14 +620,30 @@ QByteArray QHelpEngineCore::fileData(const QUrl &url) const */ QMap<QString, QUrl> QHelpEngineCore::linksForIdentifier(const QString &id) const { + return linksForIdentifier(id, d->usesFilterEngine + ? d->filterEngine->activeFilter() + : d->currentFilter); +} + +/*! + \since 5.15 + + Returns a map of the documents found for the \a id, filtered by \a filterName. + The map contains the document titles and their URLs. The returned map contents depend on + the passed filter, and therefore only the identifiers registered for + this filter will be returned. If you want to get all results unfiltered, + pass empty string as \a filterName. +*/ +QMap<QString, QUrl> QHelpEngineCore::linksForIdentifier(const QString &id, const QString &filterName) const +{ if (!d->setup()) return QMap<QString, QUrl>(); if (d->usesFilterEngine) - return d->collectionHandler->linksForIdentifier(id, d->filterEngine->activeFilter()); + return d->collectionHandler->linksForIdentifier(id, filterName); // obsolete - return d->collectionHandler->linksForIdentifier(id, filterAttributes(d->currentFilter)); + return d->collectionHandler->linksForIdentifier(id, filterAttributes(filterName)); } /*! @@ -638,15 +654,34 @@ QMap<QString, QUrl> QHelpEngineCore::linksForIdentifier(const QString &id) const */ QMap<QString, QUrl> QHelpEngineCore::linksForKeyword(const QString &keyword) const { + return linksForKeyword(keyword, d->usesFilterEngine + ? d->filterEngine->activeFilter() + : d->currentFilter); +} + +/*! + \since 5.15 + + Returns a map of the documents found for the \a keyword, filtered by \a filterName. + The map contains the document titles and their URLs. The returned map contents depend on + the passed filter, and therefore only the keywords registered for + this filter will be returned. If you want to get all results unfiltered, + pass empty string as \a filterName. + +*/ +QMap<QString, QUrl> QHelpEngineCore::linksForKeyword(const QString &keyword, const QString &filterName) const +{ if (!d->setup()) return QMap<QString, QUrl>(); if (d->usesFilterEngine) - return d->collectionHandler->linksForKeyword(keyword, d->filterEngine->activeFilter()); + return d->collectionHandler->linksForKeyword(keyword, filterName); - return d->collectionHandler->linksForKeyword(keyword, filterAttributes(d->currentFilter)); + // obsolete + return d->collectionHandler->linksForKeyword(keyword, filterAttributes(filterName)); } + /*! Removes the \a key from the settings section in the collection file. Returns true if the value was removed diff --git a/src/assistant/help/qhelpenginecore.h b/src/assistant/help/qhelpenginecore.h index 91950290e..cf0cf96c9 100644 --- a/src/assistant/help/qhelpenginecore.h +++ b/src/assistant/help/qhelpenginecore.h @@ -103,7 +103,9 @@ public: QUrl findFile(const QUrl &url) const; QMap<QString, QUrl> linksForIdentifier(const QString &id) const; + QMap<QString, QUrl> linksForIdentifier(const QString &id, const QString &filterName) const; QMap<QString, QUrl> linksForKeyword(const QString &keyword) const; + QMap<QString, QUrl> linksForKeyword(const QString &keyword, const QString &filterName) const; bool removeCustomValue(const QString &key); QVariant customValue(const QString &key, diff --git a/src/assistant/help/qhelpfilterengine.cpp b/src/assistant/help/qhelpfilterengine.cpp index a53be506e..a25976269 100644 --- a/src/assistant/help/qhelpfilterengine.cpp +++ b/src/assistant/help/qhelpfilterengine.cpp @@ -204,6 +204,19 @@ QStringList QHelpFilterEngine::availableComponents() const } /*! + \since 5.15 + + Returns the list of all available versions defined in all + registered documentation files. +*/ +QList<QVersionNumber> QHelpFilterEngine::availableVersions() const +{ + if (!d->setup()) + return QList<QVersionNumber>(); + return d->m_collectionHandler->availableVersions(); +} + +/*! Returns the filter details associated with \a filterName. */ QHelpFilterData QHelpFilterEngine::filterData(const QString &filterName) const @@ -287,4 +300,32 @@ QStringList QHelpFilterEngine::namespacesForFilter(const QString &filterName) co return d->m_collectionHandler->namespacesForFilter(filterName); } +/*! + \since 5.15 + + Returns a sorted list of available indices. + The returned list contents depend on the active filter, and therefore only + the indices registered for the active filter will be returned. +*/ +QStringList QHelpFilterEngine::indices() const +{ + return indices(activeFilter()); +} + +/*! + \since 5.15 + + Returns a sorted list of available indices, filtered by \a filterName. + The returned list contents depend on the passed filter, and therefore only + the indices registered for this filter will be returned. + If you want to get all available indices unfiltered, + pass empty string as \a filterName. +*/ +QStringList QHelpFilterEngine::indices(const QString &filterName) const +{ + if (!d->setup()) + return QStringList(); + return d->m_collectionHandler->indicesForFilter(filterName); +} + QT_END_NAMESPACE diff --git a/src/assistant/help/qhelpfilterengine.h b/src/assistant/help/qhelpfilterengine.h index c4bd139f2..d06d18b04 100644 --- a/src/assistant/help/qhelpfilterengine.h +++ b/src/assistant/help/qhelpfilterengine.h @@ -68,6 +68,7 @@ public: bool setActiveFilter(const QString &filterName); QStringList availableComponents() const; + QList<QVersionNumber> availableVersions() const; QHelpFilterData filterData(const QString &filterName) const; bool setFilterData(const QString &filterName, const QHelpFilterData &filterData); @@ -76,6 +77,9 @@ public: QStringList namespacesForFilter(const QString &filterName) const; + QStringList indices() const; + QStringList indices(const QString &filterName) const; + Q_SIGNALS: void filterActivated(const QString &newFilter); |