Commit cfa47a71 authored by con's avatar con
Browse files

Also remove old Qt Creator filters.

parent 119bb180
...@@ -574,9 +574,13 @@ void HelpPlugin::extensionsInitialized() ...@@ -574,9 +574,13 @@ void HelpPlugin::extensionsInitialized()
bool needsSetup = false; bool needsSetup = false;
bool assistantInternalDocRegistered = false; bool assistantInternalDocRegistered = false;
QStringList documentationToRemove; QStringList documentationToRemove;
QStringList filtersToRemove;
const QString &docInternal = QString("com.nokia.qtcreator.%1%2%3") const QString &docInternal = QString("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE); .arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QString filterInternal = QString("Qt Creator %1.%2.%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QRegExp filterRegExp("Qt Creator \\d*\\.\\d*\\.\\d*");
const QStringList &docs = m_helpEngine->registeredDocumentations(); const QStringList &docs = m_helpEngine->registeredDocumentations();
foreach (const QString &ns, docs) { foreach (const QString &ns, docs) {
if (ns == docInternal) { if (ns == docInternal) {
...@@ -585,36 +589,38 @@ void HelpPlugin::extensionsInitialized() ...@@ -585,36 +589,38 @@ void HelpPlugin::extensionsInitialized()
documentationToRemove << ns; documentationToRemove << ns;
} }
} }
foreach (const QString &filter, m_helpEngine->customFilters()) {
if (filterRegExp.exactMatch(filter) && filter != filterInternal) {
filtersToRemove << filter;
}
}
//remove any qtcreator documentation that doesn't belong to current version //remove any qtcreator documentation that doesn't belong to current version
if (!documentationToRemove.isEmpty()) { if (!documentationToRemove.isEmpty() || !filtersToRemove.isEmpty() || !assistantInternalDocRegistered) {
QHelpEngineCore hc(m_helpEngine->collectionFile()); QHelpEngineCore hc(m_helpEngine->collectionFile());
hc.setupData(); hc.setupData();
foreach (const QString &ns, documentationToRemove) { foreach (const QString &ns, documentationToRemove) {
if (hc.unregisterDocumentation(ns)) if (hc.unregisterDocumentation(ns))
needsSetup = true; needsSetup = true;
} }
} foreach (const QString &filter, filtersToRemove) {
if (hc.removeCustomFilter(filter))
if (!assistantInternalDocRegistered) { needsSetup = true;
QFileInfo fi(m_helpEngine->collectionFile()); }
const QString qchFileName = if (!assistantInternalDocRegistered) {
QDir::cleanPath(QCoreApplication::applicationDirPath() const QString qchFileName =
QDir::cleanPath(QCoreApplication::applicationDirPath()
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
+ QLatin1String("/../Resources/doc/qtcreator.qch")); + QLatin1String("/../Resources/doc/qtcreator.qch"));
#else #else
+ QLatin1String("../../share/doc/qtcreator/qtcreator.qch")); + QLatin1String("../../share/doc/qtcreator/qtcreator.qch"));
#endif #endif
QHelpEngineCore hc(fi.absoluteFilePath()); if (!hc.registerDocumentation(qchFileName))
hc.setupData(); qDebug() << hc.error();
QString fileNamespace = QHelpEngineCore::namespaceName(qchFileName); needsSetup = true;
if (!fileNamespace.isEmpty()
&& !hc.registeredDocumentations().contains(fileNamespace)) {
if (!hc.registerDocumentation(qchFileName))
qDebug() << hc.error();
needsSetup = true;
} }
} }
QLatin1String key("UnfilteredFilterInserted"); QLatin1String key("UnfilteredFilterInserted");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment