Merge pull request #12291 from 1P-Cusack/FogBugz/Case_10865

[Case 10865] Make Asset Browser multi-select work with Ctrl/Cmd/Shift+Click
This commit is contained in:
John Conklin II 2018-02-14 11:14:26 -08:00 committed by GitHub
commit 6187731fdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 90 additions and 78 deletions

View file

@ -202,8 +202,4 @@ TreeView {
}
onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index)
onClicked: {
selectionModel.setCurrentIndex(index, ItemSelectionModel.ClearAndSelect);
}
}

View file

@ -37,7 +37,7 @@ Windows.ScrollingWindow {
property var assetProxyModel: Assets.proxyModel;
property var assetMappingsModel: Assets.mappingModel;
property var currentDirectory;
property var selectedItems: treeView.selection.selectedIndexes.length;
property var selectedItemCount: treeView.selection.selectedIndexes.length;
Settings {
category: "Overlay.AssetServer"
@ -75,17 +75,17 @@ Windows.ScrollingWindow {
});
}
function doDeleteFile(path) {
console.log("Deleting " + path);
function doDeleteFile(paths) {
console.log("Deleting " + paths);
Assets.deleteMappings(path, function(err) {
Assets.deleteMappings(paths, function(err) {
if (err) {
console.log("Asset browser - error deleting path: ", path, err);
console.log("Asset browser - error deleting paths: ", paths, err);
box = errorMessageBox("There was an error deleting:\n" + path + "\n" + err);
box = errorMessageBox("There was an error deleting:\n" + paths + "\n" + err);
box.selected.connect(reload);
} else {
console.log("Asset browser - finished deleting path: ", path);
console.log("Asset browser - finished deleting paths: ", paths);
reload();
}
});
@ -145,7 +145,7 @@ Windows.ScrollingWindow {
function canAddToWorld(path) {
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i, /\.jpg\b/i, /\.png\b/i];
if (selectedItems > 1) {
if (selectedItemCount > 1) {
return false;
}
@ -155,7 +155,7 @@ Windows.ScrollingWindow {
}
function canRename() {
if (treeView.selection.hasSelection && selectedItems == 1) {
if (treeView.selection.hasSelection && selectedItemCount == 1) {
return true;
} else {
return false;
@ -344,29 +344,28 @@ Windows.ScrollingWindow {
});
}
function deleteFile(index) {
var path = [];
var paths = [];
if (!index) {
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);
for (var i = 0; i < selectedItemCount; ++i) {
index = treeView.selection.selectedIndexes[i];
paths[i] = assetProxyModel.data(index, 0x100);
}
}
if (!path) {
if (!paths) {
return;
}
var modalMessage = "";
var items = selectedItems.toString();
var items = selectedItemCount.toString();
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
var typeString = isFolder ? 'folder' : 'file';
if (selectedItems > 1) {
if (selectedItemCount > 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?";
modalMessage = "You are about to delete the following " + typeString + ":\n" + paths + "\nDo you want to continue?";
}
var object = desktop.messageBox({
@ -378,7 +377,7 @@ Windows.ScrollingWindow {
});
object.selected.connect(function(button) {
if (button === OriginalDialogs.StandardButton.Yes) {
doDeleteFile(path);
doDeleteFile(paths);
}
});
}
@ -705,7 +704,7 @@ Windows.ScrollingWindow {
}
}
}
}
}// End_OF( itemLoader )
Rectangle {
id: treeLabelToolTip
@ -742,50 +741,59 @@ Windows.ScrollingWindow {
showTimer.stop();
treeLabelToolTip.visible = false;
}
}
}// End_OF( treeLabelToolTip )
MouseArea {
propagateComposedEvents: true
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
if (!HMD.active) { // Popup only displays properly on desktop
var index = treeView.indexAt(mouse.x, mouse.y);
treeView.selection.setCurrentIndex(index, 0x0002);
contextMenu.currentIndex = index;
contextMenu.popup();
if (treeView.selection.hasSelection && !HMD.active) { // Popup only displays properly on desktop
// Only display the popup if the click triggered within
// the selection.
var clickedIndex = treeView.indexAt(mouse.x, mouse.y);
var displayContextMenu = false;
for ( var i = 0; i < selectedItemCount; ++i) {
var currentSelectedIndex = treeView.selection.selectedIndexes[i];
if (clickedIndex === currentSelectedIndex) {
contextMenu.popup();
break;
}
}
}
}
}
Menu {
id: contextMenu
title: "Edit"
property var url: ""
property var currentIndex: null
MenuItem {
text: "Copy URL"
enabled: (selectedItemCount == 1)
onTriggered: {
copyURLToClipboard(contextMenu.currentIndex);
copyURLToClipboard(treeView.selection.currentIndex);
}
}
MenuItem {
text: "Rename"
enabled: (selectedItemCount == 1)
onTriggered: {
renameFile(contextMenu.currentIndex);
renameFile(treeView.selection.currentIndex);
}
}
MenuItem {
text: "Delete"
enabled: (selectedItemCount > 0)
onTriggered: {
deleteFile(contextMenu.currentIndex);
deleteFile();
}
}
}
}
}// End_OF( contextMenu )
}// End_OF( treeView )
Row {
id: infoRow
@ -798,8 +806,8 @@ Windows.ScrollingWindow {
function makeText() {
var numPendingBakes = assetMappingsModel.numPendingBakes;
if (selectedItems > 1 || numPendingBakes === 0) {
return selectedItems + " items selected";
if (selectedItemCount > 1 || numPendingBakes === 0) {
return selectedItemCount + " items selected";
} else {
return numPendingBakes + " bakes pending"
}
@ -896,7 +904,7 @@ Windows.ScrollingWindow {
"Baking compresses and optimizes files for faster network transfer and display. We recommend you bake your content to reduce initial load times for your visitors.");
}
}
}
}// End_OF( infoRow )
HifiControls.ContentSection {
id: uploadSection
@ -956,7 +964,7 @@ Windows.ScrollingWindow {
}
}
}
}
}// End_OF( uploadSection )
}
}

View file

@ -39,7 +39,7 @@ Rectangle {
property var assetProxyModel: Assets.proxyModel;
property var assetMappingsModel: Assets.mappingModel;
property var currentDirectory;
property var selectedItems: treeView.selection.selectedIndexes.length;
property var selectedItemCount: treeView.selection.selectedIndexes.length;
Settings {
category: "Overlay.AssetServer"
@ -76,17 +76,17 @@ Rectangle {
});
}
function doDeleteFile(path) {
console.log("Deleting " + path);
function doDeleteFile(paths) {
console.log("Deleting " + paths);
Assets.deleteMappings(path, function(err) {
Assets.deleteMappings(paths, function(err) {
if (err) {
console.log("Asset browser - error deleting path: ", path, err);
console.log("Asset browser - error deleting paths: ", paths, err);
box = errorMessageBox("There was an error deleting:\n" + path + "\n" + err);
box = errorMessageBox("There was an error deleting:\n" + paths + "\n" + err);
box.selected.connect(reload);
} else {
console.log("Asset browser - finished deleting path: ", path);
console.log("Asset browser - finished deleting paths: ", paths);
reload();
}
});
@ -146,7 +146,7 @@ Rectangle {
function canAddToWorld(path) {
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i];
if (selectedItems > 1) {
if (selectedItemCount > 1) {
return false;
}
@ -156,7 +156,7 @@ Rectangle {
}
function canRename() {
if (treeView.selection.hasSelection && selectedItems == 1) {
if (treeView.selection.hasSelection && selectedItemCount == 1) {
return true;
} else {
return false;
@ -345,29 +345,28 @@ Rectangle {
});
}
function deleteFile(index) {
var path = [];
var paths = [];
if (!index) {
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);
for (var i = 0; i < selectedItemCount; ++i) {
index = treeView.selection.selectedIndexes[i];
paths[i] = assetProxyModel.data(index, 0x100);
}
}
if (!path) {
if (!paths) {
return;
}
var modalMessage = "";
var items = selectedItems.toString();
var items = selectedItemCount.toString();
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
var typeString = isFolder ? 'folder' : 'file';
if (selectedItems > 1) {
if (selectedItemCount > 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?";
modalMessage = "You are about to delete the following " + typeString + ":\n" + paths + "\nDo you want to continue?";
}
var object = tabletRoot.messageBox({
@ -379,7 +378,7 @@ Rectangle {
});
object.selected.connect(function(button) {
if (button === OriginalDialogs.StandardButton.Yes) {
doDeleteFile(path);
doDeleteFile(paths);
}
});
}
@ -704,7 +703,7 @@ Rectangle {
}
}
}
}
}// End_OF( itemLoader )
Rectangle {
id: treeLabelToolTip
@ -741,50 +740,59 @@ Rectangle {
showTimer.stop();
treeLabelToolTip.visible = false;
}
}
}// End_OF( treeLabelToolTip )
MouseArea {
propagateComposedEvents: true
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
if (!HMD.active) { // Popup only displays properly on desktop
var index = treeView.indexAt(mouse.x, mouse.y);
treeView.selection.setCurrentIndex(index, 0x0002);
contextMenu.currentIndex = index;
contextMenu.popup();
if (treeView.selection.hasSelection && !HMD.active) { // Popup only displays properly on desktop
// Only display the popup if the click triggered within
// the selection.
var clickedIndex = treeView.indexAt(mouse.x, mouse.y);
var displayContextMenu = false;
for ( var i = 0; i < selectedItemCount; ++i) {
var currentSelectedIndex = treeView.selection.selectedIndexes[i];
if (clickedIndex === currentSelectedIndex) {
contextMenu.popup();
break;
}
}
}
}
}
Menu {
id: contextMenu
title: "Edit"
property var url: ""
property var currentIndex: null
MenuItem {
text: "Copy URL"
enabled: (selectedItemCount == 1)
onTriggered: {
copyURLToClipboard(contextMenu.currentIndex);
copyURLToClipboard(treeView.selection.currentIndex);
}
}
MenuItem {
text: "Rename"
enabled: (selectedItemCount == 1)
onTriggered: {
renameFile(contextMenu.currentIndex);
renameFile(treeView.selection.currentIndex);
}
}
MenuItem {
text: "Delete"
enabled: (selectedItemCount > 0)
onTriggered: {
deleteFile(contextMenu.currentIndex);
deleteFile();
}
}
}
}
}// End_OF( contextMenu )
}// End_OF( treeView )
Row {
id: infoRow
@ -797,8 +805,8 @@ Rectangle {
function makeText() {
var numPendingBakes = assetMappingsModel.numPendingBakes;
if (selectedItems > 1 || numPendingBakes === 0) {
return selectedItems + " items selected";
if (selectedItemCount > 1 || numPendingBakes === 0) {
return selectedItemCount + " items selected";
} else {
return numPendingBakes + " bakes pending"
}
@ -895,7 +903,7 @@ Rectangle {
"Baking compresses and optimizes files for faster network transfer and display. We recommend you bake your content to reduce initial load times for your visitors.");
}
}
}
}// End_OF( infoRow )
HifiControls.TabletContentSection {
id: uploadSection
@ -972,7 +980,7 @@ Rectangle {
}
}
}
}
}// End_OF( uploadSection )
}
}