1// Copyright (C) 2019 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
4#include "qcompressedhelpinfo.h"
5
6#include "qhelpdbreader_p.h"
7
8#include <QtCore/QThread>
9#include <QtCore/QVersionNumber>
10
11QT_BEGIN_NAMESPACE
12
13class QCompressedHelpInfoPrivate : public QSharedData
14{
15public:
16 QCompressedHelpInfoPrivate() = default;
17 QCompressedHelpInfoPrivate(const QCompressedHelpInfoPrivate &other)
18 : QSharedData(other)
19 , m_namespaceName(other.m_namespaceName)
20 , m_component(other.m_component)
21 , m_version(other.m_version)
22 , m_isNull(other.m_isNull)
23 { }
24 ~QCompressedHelpInfoPrivate() = default;
25
26 QString m_namespaceName;
27 QString m_component;
28 QVersionNumber m_version;
29 bool m_isNull = true;
30};
31
32/*!
33 \class QCompressedHelpInfo
34 \since 5.13
35 \inmodule QtHelp
36 \brief The QCompressedHelpInfo class provides access to
37 the details about a compressed help file.
38
39 The detailed information about the compressed
40 help file can be fetched by calling the fromCompressedHelpFile()
41 static method, providing the path to the compressed
42 help file.
43
44 The class provides access to various information about a compressed help file.
45 The namespace associated with the given compressed help file is
46 namespaceName(), the associated component name is component()
47 and version() provides version information.
48
49 \sa QHelpFilterEngine
50*/
51
52/*!
53 Constructs empty information about a compressed help file.
54*/
55QCompressedHelpInfo::QCompressedHelpInfo()
56 : d(new QCompressedHelpInfoPrivate)
57{
58}
59
60/*!
61 Constructs a copy of \a other.
62*/
63QCompressedHelpInfo::QCompressedHelpInfo(const QCompressedHelpInfo &) = default;
64
65/*!
66 Move-constructs a QCompressedHelpInfo instance,
67 making it point to the same object that \a other was pointing to,
68 so that it contains the information the \a other used to contain.
69*/
70QCompressedHelpInfo::QCompressedHelpInfo(QCompressedHelpInfo &&) = default;
71
72/*!
73 Destroys the QCompressedHelpInfo.
74*/
75QCompressedHelpInfo::~QCompressedHelpInfo() = default;
76
77/*!
78 Makes this QHelpCollectionDetails into a copy of \a other, so the two
79 are identical, and returns a reference to this QHelpCollectionDetails.
80*/
81QCompressedHelpInfo &QCompressedHelpInfo::operator=(const QCompressedHelpInfo &) = default;
82
83/*!
84 Move-assigns \a other to this QCompressedHelpInfo instance.
85*/
86QCompressedHelpInfo &QCompressedHelpInfo::operator=(QCompressedHelpInfo &&) = default;
87
88/*!
89 \fn void QCompressedHelpInfo::swap(QCompressedHelpInfo &other)
90
91 Swaps the compressed help file \a other with this compressed help file. This
92 operation is very fast and never fails.
93*/
94
95/*!
96 Returns the namespace name of the compressed help file.
97*/
98QString QCompressedHelpInfo::namespaceName() const
99{
100 return d->m_namespaceName;
101}
102
103/*!
104 Returns the component of the compressed help file.
105*/
106QString QCompressedHelpInfo::component() const
107{
108 return d->m_component;
109}
110
111/*!
112 Returns the version of the compressed help file.
113*/
114QVersionNumber QCompressedHelpInfo::version() const
115{
116 return d->m_version;
117}
118
119/*!
120 Returns \c true if the info is invalid, otherwise returns
121 \c false.
122*/
123bool QCompressedHelpInfo::isNull() const
124{
125 return d->m_isNull;
126}
127
128/*!
129 Returns the QCompressedHelpInfo instance for the
130 \a documentationFileName of the existing qch file.
131*/
132QCompressedHelpInfo QCompressedHelpInfo::fromCompressedHelpFile(const QString &documentationFileName)
133{
134 QHelpDBReader reader(documentationFileName,
135 QHelpGlobal::uniquifyConnectionName(name: QLatin1String("GetCompressedHelpInfo"),
136 pointer: QThread::currentThread()), nullptr);
137 if (reader.init()) {
138 QCompressedHelpInfo info;
139 info.d->m_namespaceName = reader.namespaceName();
140 info.d->m_component = reader.virtualFolder();
141 info.d->m_version = QVersionNumber::fromString(string: reader.version());
142 info.d->m_isNull = false;
143 return info;
144 }
145 return QCompressedHelpInfo();
146}
147
148QT_END_NAMESPACE
149

source code of qttools/src/assistant/help/qcompressedhelpinfo.cpp