summaryrefslogtreecommitdiffstats
path: root/src/assistant/help/qhelpcollectionhandler.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2019-02-19 14:00:39 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2019-03-01 10:12:03 +0000
commit36a7262f8ab56c7790afd0eb43f3b07413c8bc08 (patch)
tree375c0218febf0b42546934816ad66624366165f8 /src/assistant/help/qhelpcollectionhandler.cpp
parent0198964f88c938f07058fe6deefaaa79434dc002 (diff)
Create default version filter
This mimics the behavior of old filters, where in 98% of use cases the qch file provided a separate filter for its module. Change-Id: I537d8336ea3cc0c6c894b494d7f2346df7499572 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/assistant/help/qhelpcollectionhandler.cpp')
-rw-r--r--src/assistant/help/qhelpcollectionhandler.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/assistant/help/qhelpcollectionhandler.cpp b/src/assistant/help/qhelpcollectionhandler.cpp
index 375edd8d3..483ab968e 100644
--- a/src/assistant/help/qhelpcollectionhandler.cpp
+++ b/src/assistant/help/qhelpcollectionhandler.cpp
@@ -214,7 +214,7 @@ bool QHelpCollectionHandler::openCollectionFile()
const FileInfoList &docList = registeredDocumentations();
if (indexAndNamespaceFilterTablesMissing) {
for (const QHelpCollectionHandler::FileInfo &info : docList) {
- if (!registerIndexAndNamespaceFilterTables(info.namespaceName)) {
+ if (!registerIndexAndNamespaceFilterTables(info.namespaceName, true)) {
emit error(tr("Cannot register index tables in file %1.").arg(collectionFile()));
return false;
}
@@ -1915,7 +1915,8 @@ bool QHelpCollectionHandler::registerVersion(const QString &version, int namespa
return m_query->exec();
}
-bool QHelpCollectionHandler::registerIndexAndNamespaceFilterTables(const QString &nameSpace)
+bool QHelpCollectionHandler::registerIndexAndNamespaceFilterTables(
+ const QString &nameSpace, bool createDefaultVersionFilter)
{
if (!isDBOpened())
return false;
@@ -1952,9 +1953,26 @@ bool QHelpCollectionHandler::registerIndexAndNamespaceFilterTables(const QString
if (!registerIndexTable(reader.indexTable(), nsId, vfId, fileName))
return false;
+ if (createDefaultVersionFilter)
+ createVersionFilter(reader.version());
+
return true;
}
+void QHelpCollectionHandler::createVersionFilter(const QString &version)
+{
+ if (version.isEmpty())
+ return;
+
+ const QString filterName = tr("Version %1").arg(version);
+ if (filters().contains(filterName))
+ return;
+
+ QHelpFilterData filterData;
+ filterData.setVersions(QStringList() << version);
+ setFilterData(filterName, filterData);
+}
+
bool QHelpCollectionHandler::registerIndexTable(const QHelpDBReader::IndexTable &indexTable,
int nsId, int vfId, const QString &fileName)
{