From 613e15dba6a92b56d05c2e76c43cb682ceaa5952 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 20 Mar 2019 13:20:00 +0100 Subject: [PATCH] QmlDesigner: Remove redundancy Remove redudant occurrences of QtQuick.Window.Window/QtQuick.Dialogs.Dialog Change-Id: I6d3c37f2badfc90d53993d55679e1bc97d70705f Reviewed-by: Tim Jenssen --- .../components/stateseditor/stateseditorview.cpp | 10 ++++------ .../components/stateseditor/stateseditorview.h | 2 +- .../qmldesigner/designercore/model/qmlitemnode.cpp | 8 +------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 67f20b8461f..1d9f1eec84f 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -72,7 +72,7 @@ WidgetInfo StatesEditorView::widgetInfo() void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) { - checkForWindow(); + checkForStatesAvailability(); } void StatesEditorView::toggleStatesViewExpanded() @@ -200,12 +200,10 @@ void StatesEditorView::duplicateCurrentState() setCurrentState(newState); } -void StatesEditorView::checkForWindow() +void StatesEditorView::checkForStatesAvailability() { if (m_statesEditorWidget) - m_statesEditorWidget->showAddNewStatesButton(!rootModelNode().metaInfo().isSubclassOf("QtQuick.Window.Window") - && !rootModelNode().metaInfo().isSubclassOf("QtQuick.Dialogs.Dialog") - && !rootModelNode().metaInfo().isSubclassOf("QtQuick.Window.Popup")); + m_statesEditorWidget->showAddNewStatesButton(rootModelNode().metaInfo().isSubclassOf("QtQuick.Item")); } void StatesEditorView::setCurrentState(const QmlModelState &state) @@ -315,7 +313,7 @@ void StatesEditorView::modelAttached(Model *model) if (m_statesEditorWidget) m_statesEditorWidget->setNodeInstanceView(nodeInstanceView()); - checkForWindow(); + checkForStatesAvailability(); resetModel(); } diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 155029ede06..2f8bc566507 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -93,7 +93,7 @@ private: void resetModel(); void addState(); void duplicateCurrentState(); - void checkForWindow(); + void checkForStatesAvailability(); private: QPointer m_statesEditorModel; diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 5ff63f1f1f3..f02ca1ead73 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -51,13 +51,7 @@ bool QmlItemNode::isItemOrWindow(const ModelNode &modelNode) if (modelNode.metaInfo().isSubclassOf("QtQuick.Item")) return true; - if (modelNode.metaInfo().isSubclassOf("QtQuick.Window.Window") && modelNode.isRootNode()) - return true; - - if (modelNode.metaInfo().isSubclassOf("QtQuick.Dialogs.Dialog") && modelNode.isRootNode()) - return true; - - if (modelNode.metaInfo().isSubclassOf("QtQuick.Controls.Popup")) + if (modelNode.metaInfo().isGraphicalItem() && modelNode.isRootNode()) return true; return false;