1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
/*
SPDX-FileCopyrightText: 2009 Aleix Pol <aleixpol@kde.org>
SPDX-FileCopyrightText: 2009 David Nolden <david.nolden.kdevelop@art-master.de>
SPDX-FileCopyrightText: 2010 Benjamin Port <port.benjamin@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "qthelpprovider.h"
#include <QIcon>
QtHelpProvider::QtHelpProvider(QObject* parent, const QString& fileName, const QString& namespaceName,
const QString& name, const QString& iconName)
: QtHelpProviderAbstract(parent, namespaceName + QLatin1String(".qhc"))
, m_fileName(fileName)
, m_namespaceName(namespaceName)
, m_name(name)
, m_iconName(iconName)
{
Q_ASSERT(QHelpEngineCore::namespaceName(fileName) == namespaceName);
bool registerFileName = true;
cleanUpRegisteredDocumentations([®isterFileName, this](const QString& namespaceName) {
if (!registerFileName) {
// Unregister this namespace, because the namespace associated with m_fileName has already been found.
return true;
}
if (namespaceName != m_namespaceName) {
return true; // unregister this unneeded namespace
}
const auto filePath = m_engine.documentationFileName(namespaceName);
if (filePath != m_fileName) {
return true; // unregister this namespace associated with an unneeded .qch file
}
// The .qch file m_fileName is already registered and up-to-date.
registerFileName = false; // do not reregister it
return false; // keep its namespace registered with the engine
});
if (registerFileName) {
registerDocumentation(m_fileName);
}
}
QIcon QtHelpProvider::icon() const
{
return QIcon::fromTheme(m_iconName);
}
QString QtHelpProvider::name() const
{
return m_name;
}
QString QtHelpProvider::fileName() const
{
return m_fileName;
}
QString QtHelpProvider::namespaceName() const
{
return m_namespaceName;
}
QString QtHelpProvider::iconName() const
{
return m_iconName;
}
void QtHelpProvider::setName(const QString& name)
{
m_name = name;
}
void QtHelpProvider::setIconName(const QString& iconName)
{
m_iconName = iconName;
}
#include "moc_qthelpprovider.cpp"
|