QmlDesigner: Share contextHelpId

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

Change-Id: I0a95b5ee079cbc26c87d53587f7766f1c333a245
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
This commit is contained in:
Marco Bubke
2014-05-13 17:53:04 +02:00
parent 5794ad016d
commit dd6fb08bab
5 changed files with 24 additions and 31 deletions

View File

@@ -292,17 +292,10 @@ double FormEditorWidget::containerPadding() const
QString FormEditorWidget::contextHelpId() const QString FormEditorWidget::contextHelpId() const
{ {
if (!m_formEditorView) if (m_formEditorView)
return QString(); return m_formEditorView->contextHelpId();
QList<ModelNode> nodes = m_formEditorView->selectedModelNodes(); return QString();
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick", "QML");
}
return helpId;
} }
void FormEditorWidget::setRootItemRect(const QRectF &rect) void FormEditorWidget::setRootItemRect(const QRectF &rect)

View File

@@ -674,17 +674,10 @@ void DesignDocument::updateActiveQtVersion()
QString DesignDocument::contextHelpId() const QString DesignDocument::contextHelpId() const
{ {
DesignDocumentView view; if (view())
currentModel()->attachView(&view); view()->contextHelpId();
QList<ModelNode> nodes = view.selectedModelNodes(); return QString();
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick", "QML");
}
return helpId;
} }
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -34,7 +34,7 @@
#include <QToolButton> #include <QToolButton>
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QHeaderView> #include <QHeaderView>
#include <QtDebug>
#include <utils/fileutils.h> #include <utils/fileutils.h>
@@ -108,17 +108,10 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
QString NavigatorWidget::contextHelpId() const QString NavigatorWidget::contextHelpId() const
{ {
if (!navigatorView()) if (navigatorView())
return QString(); return navigatorView()->contextHelpId();
QList<ModelNode> nodes = navigatorView()->selectedModelNodes(); return QString();
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick", "QML");
}
return helpId;
} }
NavigatorView *NavigatorWidget::navigatorView() const NavigatorView *NavigatorWidget::navigatorView() const

View File

@@ -246,6 +246,8 @@ public:
virtual bool hasWidget() const; virtual bool hasWidget() const;
virtual WidgetInfo widgetInfo(); virtual WidgetInfo widgetInfo();
QString contextHelpId() const;
protected: protected:
void setModel(Model * model); void setModel(Model * model);
void removeModel(); void removeModel();

View File

@@ -424,6 +424,18 @@ WidgetInfo AbstractView::widgetInfo()
return createWidgetInfo(); 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 QList<ModelNode> AbstractView::allModelNodes() const
{ {
return toModelNodeList(model()->d->allNodes()); return toModelNodeList(model()->d->allNodes());