QmlDesigner: Only allow goIntoComponent for existing ones

Skip the ones from Qt.

Change-Id: I4eae715b87948e8d47be8919d6b3356864fb0bd7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Thomas Hartmann
2022-04-13 16:08:40 +02:00
parent 45ca3e030b
commit ac0697780e

View File

@@ -33,6 +33,8 @@
#include <qmldesignerplugin.h>
#include <qmldesignerconstants.h>
#include <QFile>
namespace QmlDesigner {
static inline bool itemsHaveSameParent(const QList<ModelNode> &siblingList)
@@ -94,10 +96,24 @@ bool selectionHasSameParent(const SelectionContext &selectionState)
return !selectionState.selectedModelNodes().isEmpty() && itemsHaveSameParent(selectionState.selectedModelNodes());
}
bool fileComponentExists(const ModelNode &modelNode)
{
if (!modelNode.metaInfo().isFileComponent())
return true;
const QString fileName = modelNode.metaInfo().componentFileName();
if (fileName.contains("qml/QtQuick"))
return false;
return QFile::exists(fileName);
}
bool selectionIsComponent(const SelectionContext &selectionState)
{
return selectionState.currentSingleSelectedNode().isValid()
&& selectionState.currentSingleSelectedNode().isComponent();
&& selectionState.currentSingleSelectedNode().isComponent()
&& fileComponentExists(selectionState.currentSingleSelectedNode());
}
bool selectionIsImported3DAsset(const SelectionContext &selectionState)