summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Project
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-11-27 12:22:24 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-11-29 08:50:49 +0000
commit660eb01c5b91df7fca6cc00fb25b20710cbaded4 (patch)
tree5287051005f97a728f388ea119b31a46f28b5b03 /src/Authoring/Studio/Palettes/Project
parent59553021acfe3df91a42e2ba06baf4f06777b3b0 (diff)
Fix referenced assets importing when importing a presentation
Fixes following issues when importing presentations: - Importing presentations with different relative path to project file caused some assets to be imported into wrong folders - Importing custom materials didn't import texture assets that didn't have a default asset set in .material file Task-number: QT3DS-2599 Change-Id: I38e2afa1fbf793f9808a0056529336f26e6cad7e Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Project')
-rw-r--r--src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
index efc4201b..587cb084 100644
--- a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
+++ b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp
@@ -864,6 +864,9 @@ void ProjectFileSystemModel::importPresentationAssets(
QString projPathSrc; // project absolute path for the source uip
PresentationFile::getSourcePaths(uipSrc, uipTarget, importPathMap, projPathSrc,
outPresentationNodes);
+ const QDir projDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath());
+ const QDir uipSrcDir = uipSrc.dir();
+ const QDir uipTargetDir = uipTarget.dir();
QHashIterator<QString, QString> pathIter(importPathMap);
while (pathIter.hasNext()) {
@@ -871,16 +874,9 @@ void ProjectFileSystemModel::importPresentationAssets(
QString srcAssetPath = pathIter.value();
const QString path = pathIter.key();
QString targetAssetPath;
- if (path.startsWith(QLatin1String("./"))) { // path from project root
- if (srcAssetPath.isEmpty())
- srcAssetPath = QDir(projPathSrc).absoluteFilePath(path);
- targetAssetPath = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath())
- .absoluteFilePath(path);
- } else { // relative path
- if (srcAssetPath.isEmpty())
- srcAssetPath = uipSrc.dir().absoluteFilePath(path);
- targetAssetPath = uipTarget.dir().absoluteFilePath(path);
- }
+ if (srcAssetPath.isEmpty())
+ srcAssetPath = uipSrcDir.absoluteFilePath(path);
+ targetAssetPath = uipTargetDir.absoluteFilePath(path);
overridableCopyFile(srcAssetPath, targetAssetPath, outImportedFiles, outOverrideChoice);
@@ -888,6 +884,11 @@ void ProjectFileSystemModel::importPresentationAssets(
// recursively load any uip asset's assets
importPresentationAssets(QFileInfo(srcAssetPath), QFileInfo(targetAssetPath),
outPresentationNodes, outImportedFiles, outOverrideChoice);
+
+ // update the path in outPresentationNodes to be correctly relative in target project
+ const QString subId = outPresentationNodes.take(path);
+ if (!subId.isEmpty())
+ outPresentationNodes.insert(projDir.relativeFilePath(targetAssetPath), subId);
} else if (path.endsWith(QLatin1String(".qml"))) {
// recursively load any qml stream assets
QQmlApplicationEngine qmlEngine;
@@ -897,6 +898,10 @@ void ProjectFileSystemModel::importPresentationAssets(
importQmlAssets(qmlRoot, QFileInfo(srcAssetPath).dir(),
QFileInfo(targetAssetPath).dir(), outImportedFiles,
outOverrideChoice);
+ // update path in outPresentationNodes to be correctly relative in target project
+ const QString subId = outPresentationNodes.take(path);
+ if (!subId.isEmpty())
+ outPresentationNodes.insert(projDir.relativeFilePath(targetAssetPath), subId);
}
}
}