forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user