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
5
6#include <algorithm>
7#include <iterator>
8#include <memory>
9
10QT_BEGIN_NAMESPACE
11
12static std::vector<QQmlLSHelpProvider::DocumentLink>
13transformQHelpLink(QList<QHelpLink> &&qhelplinklist)
14{
15 std::vector<QQmlLSHelpProvider::DocumentLink> result(qhelplinklist.size());
16 std::transform(qhelplinklist.begin(), qhelplinklist.end(), result.begin(),
17 [&](const auto &item) {
18 QQmlLSHelpProvider::DocumentLink element;
19 element.title = item.title;
20 element.url = item.url;
21 return element;
22 });
23 return result;
24}
25
26QQmlLSHelpProvider::QQmlLSHelpProvider(const QString &qhcFilePath, QObject *parent)
27{
28 m_helpEngine.emplace(qhcFilePath, parent);
29 m_helpEngine->setReadOnly(false);
30 m_helpEngine->setupData();
31}
32
33bool QQmlLSHelpProvider::registerDocumentation(const QString &documentationFileName)
34{
35 Q_ASSERT(m_helpEngine.has_value());
36 return m_helpEngine->registerDocumentation(documentationFileName);
37}
38
39QByteArray QQmlLSHelpProvider::fileData(const QUrl &url) const
40{
41 Q_ASSERT(m_helpEngine.has_value());
42 return m_helpEngine->fileData(url);
43}
44
45std::vector<QQmlLSHelpProvider::DocumentLink>
46QQmlLSHelpProvider::documentsForIdentifier(const QString &id) const
47{
48 Q_ASSERT(m_helpEngine.has_value());
49 return transformQHelpLink(m_helpEngine->documentsForIdentifier(id));
50}
51
52std::vector<QQmlLSHelpProvider::DocumentLink>
53QQmlLSHelpProvider::documentsForIdentifier(const QString &id, const QString &filterName) const
54{
55 Q_ASSERT(m_helpEngine.has_value());
56 return transformQHelpLink(m_helpEngine->documentsForIdentifier(id, filterName));
57}
58
59std::vector<QQmlLSHelpProvider::DocumentLink>
60QQmlLSHelpProvider::documentsForKeyword(const QString &keyword) const
61{
62 Q_ASSERT(m_helpEngine.has_value());
63 return transformQHelpLink(m_helpEngine->documentsForKeyword(keyword));
64}
65
66std::vector<QQmlLSHelpProvider::DocumentLink>
67QQmlLSHelpProvider::documentsForKeyword(const QString &keyword, const QString &filter) const
68{
69 Q_ASSERT(m_helpEngine.has_value());
70 return transformQHelpLink(m_helpEngine->documentsForKeyword(keyword, filter));
71}
72
73QStringList QQmlLSHelpProvider::registeredNamespaces() const
74{
75 Q_ASSERT(m_helpEngine.has_value());
76 return m_helpEngine->registeredDocumentations();
77}
78
79QString QQmlLSHelpProvider::error() const
80{
81 Q_ASSERT(m_helpEngine.has_value());
82 return m_helpEngine->error();
83}
84
85QHelpEnginePlugin::QHelpEnginePlugin(QObject *parent) : QObject(parent) { }
86
87std::unique_ptr<QQmlLSHelpProviderBase> QHelpEnginePlugin::initialize(const QString &collectionFile,
88 QObject *parent)
89{
90 return std::make_unique<QQmlLSHelpProvider>(collectionFile, parent);
91}
92
93QT_END_NAMESPACE
94
95#include "moc_qhelpengineplugin.cpp"