forked from qt-creator/qt-creator
Qt/Help: Fix the "Highest Version Only" setting for the online installer
The Qt support has the option to only register the documentation for "the highest Qt version", which is enabled by default. That is based on finding the help files for registered Qt versions and only registering the right set depending on the settings. Unfortunately the online installer additionally registers the Qt documentation path as a separate documentation set in the install settings. (This was originally introduced to support documentation for components that are not directly related to a Qt version.) The Help plugin that handles this setting doesn't know that the Qt support explicitly doesn't want the documentation of some Qt versions registered. Let the Qt support explicitly tell the Help plugin about documentation files that should not be registered, even if they appear in the separate install setting. Change-Id: I0512adc0dfe9969481ce83094f5349a49aae5d9f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -97,5 +97,11 @@ void showHelpUrl(const QString &url, HelpViewerLocation location)
|
||||
showHelpUrl(QUrl(url), location);
|
||||
}
|
||||
|
||||
void setBlockedDocumentation(const QStringList &fileNames)
|
||||
{
|
||||
if (checkInstance())
|
||||
m_instance->setBlockedDocumentation(fileNames);
|
||||
}
|
||||
|
||||
} // HelpManager
|
||||
} // Core
|
||||
|
@@ -38,6 +38,7 @@ enum HelpViewerLocation {
|
||||
CORE_EXPORT QString documentationPath();
|
||||
|
||||
CORE_EXPORT void registerDocumentation(const QStringList &fileNames);
|
||||
CORE_EXPORT void setBlockedDocumentation(const QStringList &fileNames);
|
||||
CORE_EXPORT void unregisterDocumentation(const QStringList &fileNames);
|
||||
|
||||
CORE_EXPORT QMultiMap<QString, QUrl> linksForIdentifier(const QString &id);
|
||||
|
@@ -17,6 +17,7 @@ protected:
|
||||
|
||||
public:
|
||||
virtual void registerDocumentation(const QStringList &fileNames) = 0;
|
||||
virtual void setBlockedDocumentation(const QStringList &fileNames) = 0;
|
||||
virtual void unregisterDocumentation(const QStringList &fileNames) = 0;
|
||||
virtual QMultiMap<QString, QUrl> linksForIdentifier(const QString &id) = 0;
|
||||
virtual QMultiMap<QString, QUrl> linksForKeyword(const QString &keyword) = 0;
|
||||
|
@@ -54,6 +54,7 @@ struct HelpManagerPrivate
|
||||
|
||||
// data for delayed initialization
|
||||
QSet<QString> m_filesToRegister;
|
||||
QSet<QString> m_blockedDocumentation;
|
||||
QSet<QString> m_filesToUnregister;
|
||||
QHash<QString, QVariant> m_customValues;
|
||||
|
||||
@@ -146,6 +147,12 @@ void HelpManager::registerDocumentation(const QStringList &files)
|
||||
ProgressManager::addTask(future, Tr::tr("Update Documentation"), kUpdateDocumentationTask);
|
||||
}
|
||||
|
||||
void HelpManager::setBlockedDocumentation(const QStringList &fileNames)
|
||||
{
|
||||
for (const QString &filePath : fileNames)
|
||||
d->m_blockedDocumentation.insert(filePath);
|
||||
}
|
||||
|
||||
static void unregisterDocumentationNow(QPromise<bool> &promise,
|
||||
const QString collectionFilePath,
|
||||
const QStringList &files)
|
||||
@@ -334,6 +341,12 @@ void HelpManager::setupHelpManager()
|
||||
for (const QString &filePath : d->documentationFromInstaller())
|
||||
d->m_filesToRegister.insert(filePath);
|
||||
|
||||
// The online installer registers documentation for Qt versions explicitly via an install
|
||||
// setting, which defeats that we only register the Qt versions matching the setting.
|
||||
// So the Qt support explicitly blocks the files that we do _not_ want to register, so the
|
||||
// Help plugin knows about this.
|
||||
d->m_filesToRegister -= d->m_blockedDocumentation;
|
||||
|
||||
d->cleanUpDocumentation();
|
||||
|
||||
if (!d->m_filesToUnregister.isEmpty()) {
|
||||
|
@@ -29,6 +29,7 @@ public:
|
||||
static QString collectionFilePath();
|
||||
|
||||
void registerDocumentation(const QStringList &fileNames) override;
|
||||
void setBlockedDocumentation(const QStringList &fileNames) override;
|
||||
void unregisterDocumentation(const QStringList &fileNames) override;
|
||||
|
||||
static void registerUserDocumentation(const QStringList &filePaths);
|
||||
|
@@ -120,7 +120,8 @@ public:
|
||||
|
||||
void updateDocumentation(const QtVersions &added,
|
||||
const QtVersions &removed,
|
||||
const QtVersions &allNew);
|
||||
const QtVersions &allNew,
|
||||
bool updateBlockedDocumentation = false);
|
||||
|
||||
void setNewQtVersions(const QtVersions &newVersions);
|
||||
QString qmakePath(const QString &qtchooser, const QString &version);
|
||||
@@ -174,7 +175,7 @@ void QtVersionManagerImpl::triggerQtVersionRestore()
|
||||
} // exists
|
||||
|
||||
const QtVersions vs = QtVersionManager::versions();
|
||||
updateDocumentation(vs, {}, vs);
|
||||
updateDocumentation(vs, {}, vs, /*updateBlockedDocumentation=*/true);
|
||||
}
|
||||
|
||||
bool QtVersionManager::isLoaded()
|
||||
@@ -499,9 +500,13 @@ void QtVersionManager::registerExampleSet(const QString &displayName,
|
||||
|
||||
using Path = QString;
|
||||
using FileName = QString;
|
||||
static QList<std::pair<Path, FileName>> documentationFiles(QtVersion *v)
|
||||
using DocumentationFile = std::pair<Path, FileName>;
|
||||
using DocumentationFiles = QList<DocumentationFile>;
|
||||
using AllDocumentationFiles = QHash<QtVersion *, DocumentationFiles>;
|
||||
|
||||
static DocumentationFiles allDocumentationFiles(QtVersion *v)
|
||||
{
|
||||
QList<std::pair<Path, FileName>> files;
|
||||
DocumentationFiles files;
|
||||
const QStringList docPaths = QStringList(
|
||||
{v->docsPath().toString() + QChar('/'), v->docsPath().toString() + "/qch/"});
|
||||
for (const QString &docPath : docPaths) {
|
||||
@@ -512,7 +517,17 @@ static QList<std::pair<Path, FileName>> documentationFiles(QtVersion *v)
|
||||
return files;
|
||||
}
|
||||
|
||||
static QStringList documentationFiles(const QtVersions &vs, bool highestOnly = false)
|
||||
static AllDocumentationFiles allDocumentationFiles(const QtVersions &versions)
|
||||
{
|
||||
AllDocumentationFiles result;
|
||||
for (QtVersion *v : versions)
|
||||
result.insert(v, allDocumentationFiles(v));
|
||||
return result;
|
||||
}
|
||||
|
||||
static QStringList documentationFiles(const QtVersions &vs,
|
||||
const AllDocumentationFiles &allDocumentationFiles,
|
||||
bool highestOnly = false)
|
||||
{
|
||||
// if highestOnly is true, register each file only once per major Qt version, even if
|
||||
// multiple minor or patch releases of that major version are installed
|
||||
@@ -522,7 +537,8 @@ static QStringList documentationFiles(const QtVersions &vs, bool highestOnly = f
|
||||
for (QtVersion *v : versions) {
|
||||
const int majorVersion = v->qtVersion().majorVersion();
|
||||
QSet<QString> &majorVersionFileNames = includedFileNames[majorVersion];
|
||||
for (const std::pair<Path, FileName> &file : documentationFiles(v)) {
|
||||
const DocumentationFiles files = allDocumentationFiles.value(v);
|
||||
for (const std::pair<Path, FileName> &file : files) {
|
||||
if (!highestOnly || !majorVersionFileNames.contains(file.second)) {
|
||||
filePaths.insert(file.first + file.second);
|
||||
majorVersionFileNames.insert(file.second);
|
||||
@@ -532,15 +548,23 @@ static QStringList documentationFiles(const QtVersions &vs, bool highestOnly = f
|
||||
return filePaths.values();
|
||||
}
|
||||
|
||||
static QStringList documentationFiles(const QtVersions &vs)
|
||||
{
|
||||
return documentationFiles(vs, allDocumentationFiles(vs));
|
||||
}
|
||||
|
||||
void QtVersionManagerImpl::updateDocumentation(const QtVersions &added,
|
||||
const QtVersions &removed,
|
||||
const QtVersions &allNew)
|
||||
const QtVersions &allNew,
|
||||
bool updateBlockedDocumentation)
|
||||
{
|
||||
using DocumentationSetting = QtVersionManager::DocumentationSetting;
|
||||
const DocumentationSetting setting = QtVersionManager::documentationSetting();
|
||||
const AllDocumentationFiles allNewDocFiles = allDocumentationFiles(allNew);
|
||||
const QStringList docsOfAll = setting == DocumentationSetting::None
|
||||
? QStringList()
|
||||
: documentationFiles(allNew,
|
||||
allNewDocFiles,
|
||||
setting
|
||||
== DocumentationSetting::HighestOnly);
|
||||
const QStringList docsToRemove = Utils::filtered(documentationFiles(removed),
|
||||
@@ -551,6 +575,17 @@ void QtVersionManagerImpl::updateDocumentation(const QtVersions &added,
|
||||
[&docsOfAll](const QString &f) {
|
||||
return docsOfAll.contains(f);
|
||||
});
|
||||
|
||||
if (updateBlockedDocumentation) {
|
||||
// The online installer registers documentation for Qt versions explicitly via an install
|
||||
// setting, which defeats that we only register the Qt versions matching the setting.
|
||||
// So the Qt support explicitly blocks the files that we do _not_ want to register, so the
|
||||
// Help plugin knows about this.
|
||||
const QSet<QString> reallyAllFiles = toSet(documentationFiles(allNew, allNewDocFiles));
|
||||
const QSet<QString> toBlock = reallyAllFiles - toSet(docsOfAll);
|
||||
Core::HelpManager::setBlockedDocumentation(toList(toBlock));
|
||||
}
|
||||
|
||||
Core::HelpManager::unregisterDocumentation(docsToRemove);
|
||||
Core::HelpManager::registerDocumentation(docsToAdd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user