Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhelpengineplugin.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
7#include <algorithm>
8#include <iterator>
9#include <memory>
10
11QT_BEGIN_NAMESPACE
12
13static std::vector<QQmlLSHelpProvider::DocumentLink>
14transformQHelpLink(QList<QHelpLink> &&qhelplinklist)
15{
16 std::vector<QQmlLSHelpProvider::DocumentLink> result(qhelplinklist.size());
17 std::transform(qhelplinklist.begin(), qhelplinklist.end(), result.begin(),
18 [&](const auto &item) {
19 QQmlLSHelpProvider::DocumentLink element;
20 element.title = item.title;
21 element.url = item.url;
22 return element;
23 });
24 return result;
25}
26
27QQmlLSHelpProvider::QQmlLSHelpProvider(const QString &qhcFilePath, QObject *parent)
28{
29 m_helpEngine.emplace(qhcFilePath, parent);
30 m_helpEngine->setReadOnly(false);
31 m_helpEngine->setupData();
32}
33
34bool QQmlLSHelpProvider::registerDocumentation(const QString &documentationFileName)
35{
36 Q_ASSERT(m_helpEngine.has_value());
37 return m_helpEngine->registerDocumentation(documentationFileName);
38}
39
40QByteArray QQmlLSHelpProvider::fileData(const QUrl &url) const
41{
42 Q_ASSERT(m_helpEngine.has_value());
43 return m_helpEngine->fileData(url);
44}
45
46std::vector<QQmlLSHelpProvider::DocumentLink>
47QQmlLSHelpProvider::documentsForIdentifier(const QString &id) const
48{
49 Q_ASSERT(m_helpEngine.has_value());
50 return transformQHelpLink(m_helpEngine->documentsForIdentifier(id));
51}
52
53std::vector<QQmlLSHelpProvider::DocumentLink>
54QQmlLSHelpProvider::documentsForIdentifier(const QString &id, const QString &filterName) const
55{
56 Q_ASSERT(m_helpEngine.has_value());
57 return transformQHelpLink(m_helpEngine->documentsForIdentifier(id, filterName));
58}
59
60std::vector<QQmlLSHelpProvider::DocumentLink>
61QQmlLSHelpProvider::documentsForKeyword(const QString &keyword) const
62{
63 Q_ASSERT(m_helpEngine.has_value());
64 return transformQHelpLink(m_helpEngine->documentsForKeyword(keyword));
65}
66
67std::vector<QQmlLSHelpProvider::DocumentLink>
68QQmlLSHelpProvider::documentsForKeyword(const QString &keyword, const QString &filter) const
69{
70 Q_ASSERT(m_helpEngine.has_value());
71 return transformQHelpLink(m_helpEngine->documentsForKeyword(keyword, filter));
72}
73
74QStringList QQmlLSHelpProvider::registeredNamespaces() const
75{
76 Q_ASSERT(m_helpEngine.has_value());
77 return m_helpEngine->registeredDocumentations();
78}
79
80QString QQmlLSHelpProvider::error() const
81{
82 Q_ASSERT(m_helpEngine.has_value());
83 return m_helpEngine->error();
84}
85
86QHelpEnginePlugin::QHelpEnginePlugin(QObject *parent) : QObject(parent) { }
87
88std::unique_ptr<QQmlLSHelpProviderBase> QHelpEnginePlugin::initialize(const QString &collectionFile,
89 QObject *parent)
90{
91 return std::make_unique<QQmlLSHelpProvider>(collectionFile, parent);
92}
93
94QT_END_NAMESPACE
95
96#include "moc_qhelpengineplugin.cpp"