aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2024-02-05 17:09:35 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2024-02-08 08:58:36 +0000
commitc491d652abf81970ca345958e954fc9e278c0a5c (patch)
tree24a6523a1857e0499ddf510f7b1e635becbb9d00
parent87dd0096b43fc8a8a413c872f82262ac1d391058 (diff)
QmlDesigner: Prioritize hiding asset_imports content in UrlChooser
If the same file is available under asset_imports and outside it, prefer hiding the copy under asset_imports in UrlChooser when duplicate hiding is enabled. Fixes: QDS-11908 Change-Id: I06ac298e1ea45f6a94c66eb20cc4c0d4655103f4 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml20
1 files changed, 15 insertions, 5 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml
index 6c0e334dec..5d65bb09fc 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml
@@ -425,7 +425,7 @@ Row {
// QtDS very slow. This will happen when selecting different items in the scene.
comboBox.model = {}
- let nameSet = new Set;
+ let nameMap = new Map;
if (root.defaultItems !== undefined) {
for (var i = 0; i < root.defaultItems.length; ++i) {
@@ -437,22 +437,32 @@ Row {
name: root.defaultItems[i],
group: 0
})
- nameSet.add(root.defaultItems[i])
+ nameMap.set(root.defaultItems[i], i)
}
}
const myModel = fileModel.model
for (var j = 0; j < myModel.length; ++j) {
let item = myModel[j]
-
- if (!root.hideDuplicates || !nameSet.has(item.fileName)) {
+ if (root.hideDuplicates && nameMap.has(item.fileName)) {
+ // Prefer hiding imported asset files rather than other project files
+ let listIndex = nameMap.get(item.fileName)
+ if (comboBox.listModel.get(listIndex).absoluteFilePath.includes("/asset_imports/")) {
+ comboBox.listModel.set(listIndex, {
+ absoluteFilePath: item.absoluteFilePath,
+ relativeFilePath: item.relativeFilePath,
+ name: item.fileName,
+ group: 1
+ })
+ }
+ } else {
comboBox.listModel.append({
absoluteFilePath: item.absoluteFilePath,
relativeFilePath: item.relativeFilePath,
name: item.fileName,
group: 1
})
- nameSet.add(item.fileName)
+ nameMap.set(item.fileName, comboBox.listModel.count - 1)
}
}