1/****************************************************************************
2**
3** Copyright (C) 2019 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Assistant of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qcompressedhelpinfo.h"
41
42#include "qhelpdbreader_p.h"
43
44#include <QtCore/QThread>
45#include <QtCore/QVersionNumber>
46
47QT_BEGIN_NAMESPACE
48
49class QCompressedHelpInfoPrivate : public QSharedData
50{
51public:
52 QCompressedHelpInfoPrivate() = default;
53 QCompressedHelpInfoPrivate(const QCompressedHelpInfoPrivate &other)
54 : QSharedData(other)
55 , m_namespaceName(other.m_namespaceName)
56 , m_component(other.m_component)
57 , m_version(other.m_version)
58 , m_isNull(other.m_isNull)
59 { }
60 ~QCompressedHelpInfoPrivate() = default;
61
62 QString m_namespaceName;
63 QString m_component;
64 QVersionNumber m_version;
65 bool m_isNull = true;
66};
67
68/*!
69 \class QCompressedHelpInfo
70 \since 5.13
71 \inmodule QtHelp
72 \brief The QCompressedHelpInfo class provides access to
73 the details about a compressed help file.
74
75 The detailed information about the compressed
76 help file can be fetched by calling the fromCompressedHelpFile()
77 static method, providing the path to the compressed
78 help file.
79
80 The class provides access to various information about a compressed help file.
81 The namespace associated with the given compressed help file is
82 namespaceName(), the associated component name is component()
83 and version() provides version information.
84
85 \sa QHelpFilterEngine
86*/
87
88/*!
89 Constructs empty information about a compressed help file.
90*/
91QCompressedHelpInfo::QCompressedHelpInfo()
92 : d(new QCompressedHelpInfoPrivate)
93{
94}
95
96/*!
97 Constructs a copy of \a other.
98*/
99QCompressedHelpInfo::QCompressedHelpInfo(const QCompressedHelpInfo &) = default;
100
101/*!
102 Move-constructs a QCompressedHelpInfo instance,
103 making it point to the same object that \a other was pointing to,
104 so that it contains the information the \a other used to contain.
105*/
106QCompressedHelpInfo::QCompressedHelpInfo(QCompressedHelpInfo &&) = default;
107
108/*!
109 Destroys the QCompressedHelpInfo.
110*/
111QCompressedHelpInfo::~QCompressedHelpInfo() = default;
112
113/*!
114 Makes this QHelpCollectionDetails into a copy of \a other, so the two
115 are identical, and returns a reference to this QHelpCollectionDetails.
116*/
117QCompressedHelpInfo &QCompressedHelpInfo::operator=(const QCompressedHelpInfo &) = default;
118
119/*!
120 Move-assigns \a other to this QCompressedHelpInfo instance.
121*/
122QCompressedHelpInfo &QCompressedHelpInfo::operator=(QCompressedHelpInfo &&) = default;
123
124/*!
125 \fn void QCompressedHelpInfo::swap(QCompressedHelpInfo &other)
126
127 Swaps the compressed help file \a other with this compressed help file. This
128 operation is very fast and never fails.
129*/
130
131/*!
132 Returns the namespace name of the compressed help file.
133*/
134QString QCompressedHelpInfo::namespaceName() const
135{
136 return d->m_namespaceName;
137}
138
139/*!
140 Returns the component of the compressed help file.
141*/
142QString QCompressedHelpInfo::component() const
143{
144 return d->m_component;
145}
146
147/*!
148 Returns the version of the compressed help file.
149*/
150QVersionNumber QCompressedHelpInfo::version() const
151{
152 return d->m_version;
153}
154
155/*!
156 Returns \c true if the info is invalid, otherwise returns
157 \c false.
158*/
159bool QCompressedHelpInfo::isNull() const
160{
161 return d->m_isNull;
162}
163
164/*!
165 Returns the QCompressedHelpInfo instance for the
166 \a documentationFileName of the existing qch file.
167*/
168QCompressedHelpInfo QCompressedHelpInfo::fromCompressedHelpFile(const QString &documentationFileName)
169{
170 QHelpDBReader reader(documentationFileName,
171 QHelpGlobal::uniquifyConnectionName(name: QLatin1String("GetCompressedHelpInfo"),
172 pointer: QThread::currentThread()), nullptr);
173 if (reader.init()) {
174 QCompressedHelpInfo info;
175 info.d->m_namespaceName = reader.namespaceName();
176 info.d->m_component = reader.virtualFolder();
177 info.d->m_version = QVersionNumber::fromString(string: reader.version());
178 info.d->m_isNull = false;
179 return info;
180 }
181 return QCompressedHelpInfo();
182}
183
184QT_END_NAMESPACE
185

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