summaryrefslogtreecommitdiffstats
path: root/src/assistant/help/qhelpcollectionhandler.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-02-15 13:24:36 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2018-03-22 08:51:02 +0000
commitd745c2e616e953aad94eb1e899438bfab0b2baa2 (patch)
treeb57828d4eb86a605b8c0d95d33d5f126a5cfdadd /src/assistant/help/qhelpcollectionhandler.cpp
parentc6deb049d58e24fae9322d40ae79bc3f90c533af (diff)
Assistant: Don't query the database for unneeded data
If we only need registered documentations of a specific namespace we can restrict the SQL query accordingly, so that we don't have to iterate through all the results afterwards. Change-Id: I124cf16ed95e1010b8a05d8cb723c2a1f03120d4 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/assistant/help/qhelpcollectionhandler.cpp')
-rw-r--r--src/assistant/help/qhelpcollectionhandler.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/assistant/help/qhelpcollectionhandler.cpp b/src/assistant/help/qhelpcollectionhandler.cpp
index 163eefed1..5935295e6 100644
--- a/src/assistant/help/qhelpcollectionhandler.cpp
+++ b/src/assistant/help/qhelpcollectionhandler.cpp
@@ -355,12 +355,21 @@ bool QHelpCollectionHandler::addCustomFilter(const QString &filterName,
return true;
}
-QHelpCollectionHandler::DocInfoList QHelpCollectionHandler::registeredDocumentations() const
+QHelpCollectionHandler::DocInfoList QHelpCollectionHandler::registeredDocumentations(
+ const QString &namespaceName) const
{
DocInfoList list;
if (m_dbOpened) {
- m_query.exec(QLatin1String("SELECT a.Name, a.FilePath, b.Name "
- "FROM NamespaceTable a, FolderTable b WHERE a.Id=b.NamespaceId"));
+ static const QLatin1String baseQuery("SELECT a.Name, a.FilePath, b.Name "
+ "FROM NamespaceTable a, FolderTable b "
+ "WHERE a.Id=b.NamespaceId");
+ if (namespaceName.isEmpty()) {
+ m_query.prepare(baseQuery);
+ } else {
+ m_query.prepare(baseQuery + QLatin1String(" AND a.Name=? LIMIT 1"));
+ m_query.bindValue(0, namespaceName);
+ }
+ m_query.exec();
while (m_query.next()) {
DocInfo info;