Commit dd6fb08b authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Share contextHelpId

Moved the code to AbstractView::contextHelpId so it can be shared.

Change-Id: I0a95b5ee079cbc26c87d53587f7766f1c333a245
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 5794ad01
......@@ -292,17 +292,10 @@ double FormEditorWidget::containerPadding() const
QString FormEditorWidget::contextHelpId() const
{
if (!m_formEditorView)
return QString();
QList<ModelNode> nodes = m_formEditorView->selectedModelNodes();
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick", "QML");
}
if (m_formEditorView)
return m_formEditorView->contextHelpId();
return helpId;
return QString();
}
void FormEditorWidget::setRootItemRect(const QRectF &rect)
......
......@@ -674,17 +674,10 @@ void DesignDocument::updateActiveQtVersion()
QString DesignDocument::contextHelpId() const
{
DesignDocumentView view;
currentModel()->attachView(&view);
QList<ModelNode> nodes = view.selectedModelNodes();
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick", "QML");
}
if (view())
view()->contextHelpId();
return helpId;
return QString();
}
} // namespace QmlDesigner
......@@ -34,7 +34,7 @@
#include <QToolButton>
#include <QAbstractItemModel>
#include <QHeaderView>
#include <QtDebug>
#include <utils/fileutils.h>
......@@ -108,17 +108,10 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
QString NavigatorWidget::contextHelpId() const
{
if (!navigatorView())
return QString();
QList<ModelNode> nodes = navigatorView()->selectedModelNodes();
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick", "QML");
}
if (navigatorView())
return navigatorView()->contextHelpId();
return helpId;
return QString();
}
NavigatorView *NavigatorWidget::navigatorView() const
......
......@@ -246,6 +246,8 @@ public:
virtual bool hasWidget() const;
virtual WidgetInfo widgetInfo();
QString contextHelpId() const;
protected:
void setModel(Model * model);
void removeModel();
......
......@@ -424,6 +424,18 @@ WidgetInfo AbstractView::widgetInfo()
return createWidgetInfo();
}
QString AbstractView::contextHelpId() const
{
QString helpId;
if (hasSelectedModelNodes()) {
helpId = firstSelectedModelNode().type();
helpId.replace(QStringLiteral("QtQuick"), QStringLiteral("QML"));
}
return helpId;
}
QList<ModelNode> AbstractView::allModelNodes() const
{
return toModelNodeList(model()->d->allNodes());
......
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