diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-08-31 10:33:58 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-09-16 12:24:58 +0200 |
commit | 0833db3f366eb59f08d4497dc424dd46b08da7ae (patch) | |
tree | d149c9bb3b2546e2343f227cb228de94fff038c9 | |
parent | 0aad0fa07bfc27c71df27ab433916166b87148b7 (diff) | |
download | qttools-0833db3f366eb59f08d4497dc424dd46b08da7ae.tar.gz |
QtHelp: Fix documentsFor() when not using filter engine
Fixes: QTBUG-84727
Change-Id: Id66cc071a24cc761dc63d044b7f74d0e1959cd22
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
(cherry picked from commit dbe178044b591490cb98c071da8b91342129e030)
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler.cpp | 38 | ||||
-rw-r--r-- | src/assistant/help/qhelpcollectionhandler_p.h | 7 | ||||
-rw-r--r-- | src/assistant/help/qhelpenginecore.cpp | 14 |
3 files changed, 48 insertions, 11 deletions
diff --git a/src/assistant/help/qhelpcollectionhandler.cpp b/src/assistant/help/qhelpcollectionhandler.cpp index 48b09594d..69782d45f 100644 --- a/src/assistant/help/qhelpcollectionhandler.cpp +++ b/src/assistant/help/qhelpcollectionhandler.cpp @@ -2313,14 +2313,38 @@ QMap<QString, QUrl> QHelpCollectionHandler::linksForKeyword(const QString &keywo return linksForField(QLatin1String("Name"), keyword, filterAttributes); } +QList<QHelpLink> QHelpCollectionHandler::documentsForIdentifier(const QString &id, + const QStringList &filterAttributes) const +{ + return documentsForField(QLatin1String("Identifier"), id, filterAttributes); +} + +QList<QHelpLink> QHelpCollectionHandler::documentsForKeyword(const QString &keyword, + const QStringList &filterAttributes) const +{ + return documentsForField(QLatin1String("Name"), keyword, filterAttributes); +} + QMap<QString, QUrl> QHelpCollectionHandler::linksForField(const QString &fieldName, const QString &fieldValue, const QStringList &filterAttributes) const { QMap<QString, QUrl> linkMap; + const auto documents = documentsForField(fieldName, fieldValue, filterAttributes); + for (const auto &document : documents) + static_cast<QMultiMap<QString, QUrl> &>(linkMap).insert(document.title, document.url); + + return linkMap; +} + +QList<QHelpLink> QHelpCollectionHandler::documentsForField(const QString &fieldName, + const QString &fieldValue, + const QStringList &filterAttributes) const +{ + QList<QHelpLink> docList; if (!isDBOpened()) - return linkMap; + return docList; const QString filterlessQuery = QString::fromLatin1( "SELECT " @@ -2357,13 +2381,13 @@ QMap<QString, QUrl> QHelpCollectionHandler::linksForField(const QString &fieldNa if (title.isEmpty()) // generate a title + corresponding path title = fieldValue + QLatin1String(" : ") + m_query->value(3).toString(); - static_cast<QMultiMap<QString, QUrl> &>(linkMap).insert(title, buildQUrl( - m_query->value(1).toString(), - m_query->value(2).toString(), - m_query->value(3).toString(), - m_query->value(4).toString())); + const QUrl url = buildQUrl(m_query->value(1).toString(), + m_query->value(2).toString(), + m_query->value(3).toString(), + m_query->value(4).toString()); + docList.append(QHelpLink {url, title}); } - return linkMap; + return docList; } QMap<QString, QUrl> QHelpCollectionHandler::linksForIdentifier(const QString &id, diff --git a/src/assistant/help/qhelpcollectionhandler_p.h b/src/assistant/help/qhelpcollectionhandler_p.h index 83178f388..bb9d102c9 100644 --- a/src/assistant/help/qhelpcollectionhandler_p.h +++ b/src/assistant/help/qhelpcollectionhandler_p.h @@ -208,6 +208,10 @@ public: const QString &filterName) const; QList<QHelpLink> documentsForKeyword(const QString &keyword, const QString &filterName) const; + QList<QHelpLink> documentsForIdentifier(const QString &id, + const QStringList &filterAttributes) const; + QList<QHelpLink> documentsForKeyword(const QString &keyword, + const QStringList &filterAttributes) const; QStringList namespacesForFilter(const QString &filterName) const; @@ -221,6 +225,9 @@ private: QMap<QString, QUrl> linksForField(const QString &fieldName, const QString &fieldValue, const QStringList &filterAttributes) const; + QList<QHelpLink> documentsForField(const QString &fieldName, + const QString &fieldValue, + const QStringList &filterAttributes) const; QString namespaceVersion(const QString &namespaceName) const; QMap<QString, QUrl> linksForField(const QString &fieldName, diff --git a/src/assistant/help/qhelpenginecore.cpp b/src/assistant/help/qhelpenginecore.cpp index 2e640da7e..3c3e4bd32 100644 --- a/src/assistant/help/qhelpenginecore.cpp +++ b/src/assistant/help/qhelpenginecore.cpp @@ -659,10 +659,13 @@ QList<QHelpLink> QHelpEngineCore::documentsForIdentifier(const QString &id) cons */ QList<QHelpLink> QHelpEngineCore::documentsForIdentifier(const QString &id, const QString &filterName) const { - if (!d->setup() || !d->usesFilterEngine) + if (!d->setup()) return QList<QHelpLink>(); - return d->collectionHandler->documentsForIdentifier(id, filterName); + if (d->usesFilterEngine) + return d->collectionHandler->documentsForIdentifier(id, filterName); + + return d->collectionHandler->documentsForIdentifier(id, filterAttributes(filterName)); } #if QT_DEPRECATED_SINCE(5, 15) @@ -713,10 +716,13 @@ QList<QHelpLink> QHelpEngineCore::documentsForKeyword(const QString &keyword) co */ QList<QHelpLink> QHelpEngineCore::documentsForKeyword(const QString &keyword, const QString &filterName) const { - if (!d->setup() || !d->usesFilterEngine) + if (!d->setup()) return QList<QHelpLink>(); - return d->collectionHandler->documentsForKeyword(keyword, filterName); + if (d->usesFilterEngine) + return d->collectionHandler->documentsForKeyword(keyword, filterName); + + return d->collectionHandler->documentsForKeyword(keyword, filterAttributes(filterName)); } /*! |