QmlDesigner: Fix component file path

Change-Id: I9e5f5dc4906c9c498e4a54f92a7d8a105e0399a1
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Marco Bubke
2024-04-03 13:34:59 +02:00
parent 316d88bd12
commit 7883f15299
4 changed files with 15 additions and 11 deletions

View File

@@ -15,6 +15,8 @@
#include "qmlobjectnode.h"
#include "variantproperty.h"
#include <model/modelutils.h>
#include <utils3d.h>
#include <utils/expected.h>
@@ -292,7 +294,7 @@ bool BakeLightsDataModel::reset()
if (!hasExposedProps && node.metaInfo().isFileComponent()
&& node.metaInfo().isQtQuick3DNode()) {
const QString compFile = node.metaInfo().componentFileName();
const QString compFile = ModelUtils::componentFilePath(node);
const QString projPath = m_view->externalDependencies().currentProjectDirPath();
if (compFile.startsWith(projPath)) {
// Quick and dirty scan of the component source to check if it potentially has

View File

@@ -27,9 +27,11 @@ QT_END_NAMESPACE
# define DEPRECATED_VERSION_NUMBER \
[[deprecated( \
"In most cases you don't need them anymore because the import is setting them!")]]
# define DEPRECATED_COMPONENT_FILE_NAME [[deprecated("Use sourceId() instead.")]]
#else
# define DEPRECATED_TYPENAME
# define DEPRECATED_VERSION_NUMBER
# define DEPRECATED_COMPONENT_FILE_NAME
#endif
namespace QmlDesigner {
@@ -116,7 +118,7 @@ public:
Storage::Info::ItemLibraryEntries itemLibrariesEntries() const;
SourceId sourceId() const;
QString componentFileName() const;
DEPRECATED_COMPONENT_FILE_NAME QString componentFileName() const;
bool isBasedOn(const NodeMetaInfo &metaInfo) const;
bool isBasedOn(const NodeMetaInfo &metaInfo1, const NodeMetaInfo &metaInfo2) const;

View File

@@ -109,19 +109,19 @@ PropertyMetaInfo metainfo(const ModelNode &node, const PropertyName &propertyNam
return node.metaInfo().property(propertyName);
}
QString componentFilePath(const PathCacheType &pathCache, const NodeMetaInfo &metaInfo)
QString componentFilePath([[maybe_unused]] const PathCacheType &pathCache, const NodeMetaInfo &metaInfo)
{
if constexpr (useProjectStorage()) {
#ifdef QDS_USE_PROJECTSTORAGE
auto typeSourceId = metaInfo.sourceId();
if (typeSourceId && metaInfo.isFileComponent()) {
return pathCache.sourcePath(typeSourceId).toQString();
}
} else {
return metaInfo.componentFileName();
}
return {};
#else
return metaInfo.componentFileName();
#endif
}
QString componentFilePath(const ModelNode &node)

View File

@@ -130,7 +130,7 @@ static void openComponentSourcePropertyOfLoader(const ModelNode &modelNode)
}
Core::EditorManager::openEditor(FilePath::fromString(
componentModelNode.metaInfo().componentFileName()),
ModelUtils::componentFilePath(componentModelNode)),
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
}