mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 01:44:21 +02:00
Merge pull request #11064 from highfidelity/bug/6513
Enabled multiple selection and deletion in Asset Browser
This commit is contained in:
commit
f407bf6f5a
2 changed files with 73 additions and 16 deletions
|
@ -28,6 +28,7 @@ ScrollingWindow {
|
||||||
minSize: Qt.vector2d(200, 300)
|
minSize: Qt.vector2d(200, 300)
|
||||||
|
|
||||||
property int colorScheme: hifi.colorSchemes.dark
|
property int colorScheme: hifi.colorSchemes.dark
|
||||||
|
property int selectionMode: SelectionMode.ExtendedSelection
|
||||||
|
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
|
@ -35,7 +36,8 @@ ScrollingWindow {
|
||||||
property var assetProxyModel: Assets.proxyModel;
|
property var assetProxyModel: Assets.proxyModel;
|
||||||
property var assetMappingsModel: Assets.mappingModel;
|
property var assetMappingsModel: Assets.mappingModel;
|
||||||
property var currentDirectory;
|
property var currentDirectory;
|
||||||
|
property var selectedItems: treeView.selection.selectedIndexes.length;
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
category: "Overlay.AssetServer"
|
category: "Overlay.AssetServer"
|
||||||
property alias x: root.x
|
property alias x: root.x
|
||||||
|
@ -48,7 +50,7 @@ ScrollingWindow {
|
||||||
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function doDeleteFile(path) {
|
function doDeleteFile(path) {
|
||||||
console.log("Deleting " + path);
|
console.log("Deleting " + path);
|
||||||
|
|
||||||
|
@ -118,11 +120,23 @@ ScrollingWindow {
|
||||||
|
|
||||||
function canAddToWorld(path) {
|
function canAddToWorld(path) {
|
||||||
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i];
|
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i];
|
||||||
|
|
||||||
|
if (selectedItems > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return supportedExtensions.reduce(function(total, current) {
|
return supportedExtensions.reduce(function(total, current) {
|
||||||
return total | new RegExp(current).test(path);
|
return total | new RegExp(current).test(path);
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canRename() {
|
||||||
|
if (treeView.selection.hasSelection && selectedItems == 1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
Assets.mappingModel.clear();
|
Assets.mappingModel.clear();
|
||||||
|
@ -299,23 +313,37 @@ ScrollingWindow {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function deleteFile(index) {
|
function deleteFile(index) {
|
||||||
|
var path = [];
|
||||||
|
|
||||||
if (!index) {
|
if (!index) {
|
||||||
index = treeView.selection.currentIndex;
|
for (var i = 0; i < selectedItems; i++) {
|
||||||
|
treeView.selection.setCurrentIndex(treeView.selection.selectedIndexes[i], 0x100);
|
||||||
|
index = treeView.selection.currentIndex;
|
||||||
|
path[i] = assetProxyModel.data(index, 0x100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var path = assetProxyModel.data(index, 0x100);
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var modalMessage = "";
|
||||||
|
var items = selectedItems.toString();
|
||||||
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
|
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
|
||||||
var typeString = isFolder ? 'folder' : 'file';
|
var typeString = isFolder ? 'folder' : 'file';
|
||||||
|
|
||||||
|
if (selectedItems > 1) {
|
||||||
|
modalMessage = "You are about to delete " + items + " items \nDo you want to continue?";
|
||||||
|
} else {
|
||||||
|
modalMessage = "You are about to delete the following " + typeString + ":\n" + path + "\nDo you want to continue?";
|
||||||
|
}
|
||||||
|
|
||||||
var object = desktop.messageBox({
|
var object = desktop.messageBox({
|
||||||
icon: hifi.icons.question,
|
icon: hifi.icons.question,
|
||||||
buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No,
|
buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No,
|
||||||
defaultButton: OriginalDialogs.StandardButton.Yes,
|
defaultButton: OriginalDialogs.StandardButton.Yes,
|
||||||
title: "Delete",
|
title: "Delete",
|
||||||
text: "You are about to delete the following " + typeString + ":\n" + path + "\nDo you want to continue?"
|
text: modalMessage
|
||||||
});
|
});
|
||||||
object.selected.connect(function(button) {
|
object.selected.connect(function(button) {
|
||||||
if (button === OriginalDialogs.StandardButton.Yes) {
|
if (button === OriginalDialogs.StandardButton.Yes) {
|
||||||
|
@ -455,20 +483,20 @@ ScrollingWindow {
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
width: 120
|
width: 120
|
||||||
|
|
||||||
enabled: canAddToWorld(assetProxyModel.data(treeView.selection.currentIndex, 0x100))
|
enabled: canAddToWorld(assetProxyModel.data(treeView.selection.currentIndex, 0x100))
|
||||||
|
|
||||||
onClicked: root.addToWorld()
|
onClicked: root.addToWorld()
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
text: "Rename"
|
text: "Rename"
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
width: 80
|
width: 80
|
||||||
|
|
||||||
onClicked: root.renameFile()
|
onClicked: root.renameFile()
|
||||||
enabled: treeView.selection.hasSelection
|
enabled: canRename()
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -524,6 +552,7 @@ ScrollingWindow {
|
||||||
treeModel: assetProxyModel
|
treeModel: assetProxyModel
|
||||||
canEdit: true
|
canEdit: true
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
|
selectionMode: SelectionMode.ExtendedSelection
|
||||||
|
|
||||||
modifyEl: renameEl
|
modifyEl: renameEl
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ Rectangle {
|
||||||
property var assetProxyModel: Assets.proxyModel;
|
property var assetProxyModel: Assets.proxyModel;
|
||||||
property var assetMappingsModel: Assets.mappingModel;
|
property var assetMappingsModel: Assets.mappingModel;
|
||||||
property var currentDirectory;
|
property var currentDirectory;
|
||||||
|
property var selectedItems: treeView.selection.selectedIndexes.length;
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
category: "Overlay.AssetServer"
|
category: "Overlay.AssetServer"
|
||||||
|
@ -119,11 +120,23 @@ Rectangle {
|
||||||
|
|
||||||
function canAddToWorld(path) {
|
function canAddToWorld(path) {
|
||||||
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i];
|
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i];
|
||||||
|
|
||||||
|
if (selectedItems > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return supportedExtensions.reduce(function(total, current) {
|
return supportedExtensions.reduce(function(total, current) {
|
||||||
return total | new RegExp(current).test(path);
|
return total | new RegExp(current).test(path);
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canRename() {
|
||||||
|
if (treeView.selection.hasSelection && selectedItems == 1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
Assets.mappingModel.clear();
|
Assets.mappingModel.clear();
|
||||||
|
@ -300,23 +313,37 @@ Rectangle {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function deleteFile(index) {
|
function deleteFile(index) {
|
||||||
|
var path = [];
|
||||||
|
|
||||||
if (!index) {
|
if (!index) {
|
||||||
index = treeView.selection.currentIndex;
|
for (var i = 0; i < selectedItems; i++) {
|
||||||
|
treeView.selection.setCurrentIndex(treeView.selection.selectedIndexes[i], 0x100);
|
||||||
|
index = treeView.selection.currentIndex;
|
||||||
|
path[i] = assetProxyModel.data(index, 0x100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var path = assetProxyModel.data(index, 0x100);
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var modalMessage = "";
|
||||||
|
var items = selectedItems.toString();
|
||||||
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
|
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
|
||||||
var typeString = isFolder ? 'folder' : 'file';
|
var typeString = isFolder ? 'folder' : 'file';
|
||||||
|
|
||||||
|
if (selectedItems > 1) {
|
||||||
|
modalMessage = "You are about to delete " + items + " items \nDo you want to continue?";
|
||||||
|
} else {
|
||||||
|
modalMessage = "You are about to delete the following " + typeString + ":\n" + path + "\nDo you want to continue?";
|
||||||
|
}
|
||||||
|
|
||||||
var object = tabletRoot.messageBox({
|
var object = tabletRoot.messageBox({
|
||||||
icon: hifi.icons.question,
|
icon: hifi.icons.question,
|
||||||
buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No,
|
buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No,
|
||||||
defaultButton: OriginalDialogs.StandardButton.Yes,
|
defaultButton: OriginalDialogs.StandardButton.Yes,
|
||||||
title: "Delete",
|
title: "Delete",
|
||||||
text: "You are about to delete the following " + typeString + ":\n" + path + "\nDo you want to continue?"
|
text: modalMessage
|
||||||
});
|
});
|
||||||
object.selected.connect(function(button) {
|
object.selected.connect(function(button) {
|
||||||
if (button === OriginalDialogs.StandardButton.Yes) {
|
if (button === OriginalDialogs.StandardButton.Yes) {
|
||||||
|
@ -469,7 +496,7 @@ Rectangle {
|
||||||
width: 80
|
width: 80
|
||||||
|
|
||||||
onClicked: root.renameFile()
|
onClicked: root.renameFile()
|
||||||
enabled: treeView.selection.hasSelection
|
enabled: canRename()
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -525,6 +552,7 @@ Rectangle {
|
||||||
treeModel: assetProxyModel
|
treeModel: assetProxyModel
|
||||||
canEdit: true
|
canEdit: true
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
|
selectionMode: SelectionMode.ExtendedSelection
|
||||||
|
|
||||||
modifyEl: renameEl
|
modifyEl: renameEl
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue