Help plugin: Simplify code path in doc registering.

This commit is contained in:
ck
2010-01-13 15:08:07 +01:00
parent 3b7527de2e
commit e83c2e40a6

View File

@@ -99,21 +99,25 @@ void HelpManager::registerDocumentation(const QStringList &fileNames)
bool needsSetup = false; bool needsSetup = false;
{ {
QHelpEngineCore hc(m_plugin->helpEngine()->collectionFile()); QHelpEngineCore hc(m_plugin->helpEngine()->collectionFile());
if (!hc.setupData()) if (!hc.setupData()) {
qWarning() << "Could not initialize help engine:" << hc.error(); qWarning() << "Could not initialize help engine:" << hc.error();
return;
}
foreach (const QString &fileName, fileNames) { foreach (const QString &fileName, fileNames) {
if (!QFileInfo(fileName).exists()) if (!QFileInfo(fileName).exists())
continue; continue;
const QString &nameSpace = QHelpEngineCore::namespaceName(fileName); const QString &nameSpace = QHelpEngineCore::namespaceName(fileName);
if (!nameSpace.isEmpty()) { if (nameSpace.isEmpty())
if (hc.registeredDocumentations().contains(nameSpace)) {
if (!QFileInfo(hc.documentationFileName(nameSpace)).exists()) {
// remove stale documentation path first
if (!hc.unregisterDocumentation(nameSpace)) {
qWarning() << "error unregistering " << fileName << hc.error();
continue; continue;
} if (hc.registeredDocumentations().contains(nameSpace)) {
} else { if (QFileInfo(hc.documentationFileName(nameSpace)).exists())
continue;
// remove stale documentation first
if (!hc.unregisterDocumentation(nameSpace)) {
qWarning() << "error unregistering namespace '"
<< nameSpace << "' from file '" << fileName << "': "
<< hc.error();
continue; continue;
} }
} }
@@ -124,7 +128,6 @@ void HelpManager::registerDocumentation(const QStringList &fileNames)
} }
} }
} }
}
if (needsSetup) if (needsSetup)
m_plugin->helpEngine()->setupData(); m_plugin->helpEngine()->setupData();
} }