Help: Move resolution of help from multiple candidate IDs to HelpItem

No need for code duplication.

Change-Id: I3d2c795d072b8de5818e1844b8126e526339c0da
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2019-01-28 13:00:03 +01:00
parent 1f4b733cc1
commit 443931c1da
12 changed files with 81 additions and 106 deletions

View File

@@ -30,7 +30,6 @@
#include <coreplugin/helpmanager.h>
#include <texteditor/texteditor.h>
#include <utils/optional.h>
#include <utils/textutils.h>
#include <utils/executeondestruction.h>
@@ -61,19 +60,9 @@ void CppHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, Rep
const QSharedPointer<CppElement> &cppElement = evaluator.cppElement();
QStringList candidates = cppElement->helpIdCandidates;
candidates.removeDuplicates();
Utils::optional<HelpItem> helpItem;
foreach (const QString &helpId, candidates) {
if (helpId.isEmpty())
continue;
const QMap<QString, QUrl> helpLinks = HelpManager::linksForIdentifier(helpId);
if (!helpLinks.isEmpty()) {
helpItem.emplace(helpId, cppElement->helpMark, cppElement->helpCategory, helpLinks);
break;
}
}
if (helpItem)
setLastHelpItemIdentified(helpItem.value()); // tool tip appended by decorateToolTip
else
const HelpItem helpItem(candidates, cppElement->helpMark, cppElement->helpCategory);
setLastHelpItemIdentified(helpItem); // tool tip appended by decorateToolTip
if (!helpItem.isValid())
tip += cppElement->tooltip;
}
setToolTip(tip);