diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml index 6c0e334dec6..5d65bb09fc4 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) } }