summaryrefslogtreecommitdiff
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
parentc6deb049d58e24fae9322d40ae79bc3f90c533af (diff)
downloadqttools-d745c2e616e953aad94eb1e899438bfab0b2baa2.tar.gz
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>
-rw-r--r--src/assistant/help/qhelpcollectionhandler.cpp15
-rw-r--r--src/assistant/help/qhelpcollectionhandler_p.h2
-rw-r--r--src/assistant/help/qhelpenginecore.cpp2
3 files changed, 14 insertions, 5 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;
diff --git a/src/assistant/help/qhelpcollectionhandler_p.h b/src/assistant/help/qhelpcollectionhandler_p.h
index b2b249715..2b1b57718 100644
--- a/src/assistant/help/qhelpcollectionhandler_p.h
+++ b/src/assistant/help/qhelpcollectionhandler_p.h
@@ -88,7 +88,7 @@ public:
bool addCustomFilter(const QString &filterName,
const QStringList &attributes);
- DocInfoList registeredDocumentations() const;
+ DocInfoList registeredDocumentations(const QString &namespaceName = QString()) const;
bool registerDocumentation(const QString &fileName);
bool unregisterDocumentation(const QString &namespaceName);
diff --git a/src/assistant/help/qhelpenginecore.cpp b/src/assistant/help/qhelpenginecore.cpp
index b3396f2fe..e351c07d1 100644
--- a/src/assistant/help/qhelpenginecore.cpp
+++ b/src/assistant/help/qhelpenginecore.cpp
@@ -351,7 +351,7 @@ QString QHelpEngineCore::documentationFileName(const QString &namespaceName)
{
if (d->setup()) {
const QHelpCollectionHandler::DocInfoList &docList =
- d->collectionHandler->registeredDocumentations();
+ d->collectionHandler->registeredDocumentations(namespaceName);
for (const QHelpCollectionHandler::DocInfo &info : docList) {
if (info.namespaceName == namespaceName) {
if (QDir::isAbsolutePath(info.fileName))