QmlDesigner: Fix help

The designer used a over simplified lookup,
that did not distinguish between e.g. Controls 1 and Controls 2.
Instead of fixing the lookup we simply use the working lookup from
the QmlJSEditor.

Change-Id: I2d31e633eaadc67e211d44bad307b26993f21fc9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-03-22 12:17:28 +01:00
parent 316ed6943c
commit 970496b24c
5 changed files with 23 additions and 16 deletions

View File

@@ -146,13 +146,18 @@ WidgetInfo TextEditorView::widgetInfo()
} }
QString TextEditorView::contextHelpId() const QString TextEditorView::contextHelpId() const
{
return AbstractView::contextHelpId();
}
QString TextEditorView::qmlJSEditorHelpId() const
{ {
if (m_widget->textEditor()) { if (m_widget->textEditor()) {
QString contextHelpId = m_widget->textEditor()->contextHelpId(); QString contextHelpId = m_widget->textEditor()->contextHelpId();
if (!contextHelpId.isEmpty()) if (!contextHelpId.isEmpty())
return m_widget->textEditor()->contextHelpId(); return m_widget->textEditor()->contextHelpId();
} }
return AbstractView::contextHelpId(); return QString();
} }
void TextEditorView::nodeIdChanged(const ModelNode& /*node*/, const QString &/*newId*/, const QString &/*oldId*/) void TextEditorView::nodeIdChanged(const ModelNode& /*node*/, const QString &/*newId*/, const QString &/*oldId*/)

View File

@@ -69,6 +69,8 @@ public:
WidgetInfo widgetInfo() override; WidgetInfo widgetInfo() override;
QString contextHelpId() const override; QString contextHelpId() const override;
QString qmlJSEditorHelpId() const;
TextEditor::BaseTextEditor *textEditor(); TextEditor::BaseTextEditor *textEditor();
bool changeToMoveTool(); bool changeToMoveTool();

View File

@@ -95,6 +95,8 @@ public:
void toggleStatesViewExpanded(); void toggleStatesViewExpanded();
QString qmlJSEditorHelpId() const;
private: // functions private: // functions
Q_DISABLE_COPY(ViewManager) Q_DISABLE_COPY(ViewManager)

View File

@@ -31,6 +31,11 @@
#include "nodeinstanceview.h" #include "nodeinstanceview.h"
#include <qmlstate.h> #include <qmlstate.h>
#ifndef QMLDESIGNER_TEST
#include <qmldesignerplugin.h>
#include <viewmanager.h>
#endif
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -554,21 +559,9 @@ QString AbstractView::contextHelpId() const
{ {
QString helpId; QString helpId;
if (hasSelectedModelNodes()) { #ifndef QMLDESIGNER_TEST
QString className = firstSelectedModelNode().simplifiedTypeName(); helpId = QmlDesignerPlugin::instance()->viewManager().qmlJSEditorHelpId();
helpId = QStringLiteral("QML.") + className; #endif
if (Core::HelpManager::linksForIdentifier(helpId).isEmpty() && firstSelectedModelNode().metaInfo().isValid()) {
foreach (className, firstSelectedModelNode().metaInfo().superClassNames()) {
helpId = QStringLiteral("QML.") + className;
if (Core::HelpManager::linksForIdentifier(helpId).isEmpty())
helpId = QString();
else
break;
}
}
}
return helpId; return helpId;
} }

View File

@@ -411,6 +411,11 @@ void ViewManager::toggleStatesViewExpanded()
d->statesEditorView.toggleStatesViewExpanded(); d->statesEditorView.toggleStatesViewExpanded();
} }
QString ViewManager::qmlJSEditorHelpId() const
{
return d->textEditorView.qmlJSEditorHelpId();
}
Model *ViewManager::currentModel() const Model *ViewManager::currentModel() const
{ {
return currentDesignDocument()->currentModel(); return currentDesignDocument()->currentModel();