forked from qt-creator/qt-creator
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:
@@ -292,17 +292,10 @@ double FormEditorWidget::containerPadding() const
|
||||
|
||||
QString FormEditorWidget::contextHelpId() const
|
||||
{
|
||||
if (!m_formEditorView)
|
||||
return QString();
|
||||
if (m_formEditorView)
|
||||
return m_formEditorView->contextHelpId();
|
||||
|
||||
QList<ModelNode> nodes = m_formEditorView->selectedModelNodes();
|
||||
QString helpId;
|
||||
if (!nodes.isEmpty()) {
|
||||
helpId = nodes.first().type();
|
||||
helpId.replace("QtQuick", "QML");
|
||||
}
|
||||
|
||||
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);
|
||||
if (view())
|
||||
view()->contextHelpId();
|
||||
|
||||
QList<ModelNode> nodes = view.selectedModelNodes();
|
||||
QString helpId;
|
||||
if (!nodes.isEmpty()) {
|
||||
helpId = nodes.first().type();
|
||||
helpId.replace("QtQuick", "QML");
|
||||
}
|
||||
|
||||
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();
|
||||
if (navigatorView())
|
||||
return navigatorView()->contextHelpId();
|
||||
|
||||
QList<ModelNode> nodes = navigatorView()->selectedModelNodes();
|
||||
QString helpId;
|
||||
if (!nodes.isEmpty()) {
|
||||
helpId = nodes.first().type();
|
||||
helpId.replace("QtQuick", "QML");
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user