summaryrefslogtreecommitdiff
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
parent0198964f88c938f07058fe6deefaaa79434dc002 (diff)
downloadqttools-36a7262f8ab56c7790afd0eb43f3b07413c8bc08.tar.gz
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>
-rw-r--r--src/assistant/help/qhelpcollectionhandler.cpp22
-rw-r--r--src/assistant/help/qhelpcollectionhandler_p.h4
2 files changed, 23 insertions, 3 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)
{
diff --git a/src/assistant/help/qhelpcollectionhandler_p.h b/src/assistant/help/qhelpcollectionhandler_p.h
index c52498f4e..223f66012 100644
--- a/src/assistant/help/qhelpcollectionhandler_p.h
+++ b/src/assistant/help/qhelpcollectionhandler_p.h
@@ -220,7 +220,9 @@ private:
bool createTables(QSqlQuery *query);
void closeDB();
bool recreateIndexAndNamespaceFilterTables(QSqlQuery *query);
- bool registerIndexAndNamespaceFilterTables(const QString &nameSpace);
+ bool registerIndexAndNamespaceFilterTables(const QString &nameSpace,
+ bool createDefaultVersionFilter = false);
+ void createVersionFilter(const QString &version);
bool registerFilterAttributes(const QList<QStringList> &attributeSets, int nsId);
bool registerFileAttributeSets(const QList<QStringList> &attributeSets, int nsId);
bool registerIndexTable(const QHelpDBReader::IndexTable &indexTable,