Merge pull request #12637 from druiz17/fix-asset-server-qml

Fix asset server qml sorting
This commit is contained in:
John Conklin II 2018-03-28 09:35:53 -07:00 committed by GitHub
commit 586fb4829c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 58 deletions

View file

@ -58,7 +58,7 @@ Windows.ScrollingWindow {
Component.onDestruction: {
assetMappingsModel.autoRefreshEnabled = false;
}
function letterbox(headerGlyph, headerText, message) {
letterboxMessage.headerGlyph = headerGlyph;
letterboxMessage.headerText = headerText;
@ -145,7 +145,7 @@ Windows.ScrollingWindow {
function canAddToWorld(path) {
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i, /\.jpg\b/i, /\.png\b/i];
if (selectedItemCount > 1) {
return false;
}
@ -154,8 +154,8 @@ Windows.ScrollingWindow {
return total | new RegExp(current).test(path);
}, false);
}
function canRename() {
function canRename() {
if (treeView.selection.hasSelection && selectedItemCount == 1) {
return true;
} else {
@ -199,7 +199,7 @@ Windows.ScrollingWindow {
var SHAPE_TYPE_STATIC_MESH = 3;
var SHAPE_TYPE_BOX = 4;
var SHAPE_TYPE_SPHERE = 5;
var SHAPE_TYPES = [];
SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision";
SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model";
@ -207,7 +207,7 @@ Windows.ScrollingWindow {
SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons";
SHAPE_TYPES[SHAPE_TYPE_BOX] = "Box";
SHAPE_TYPES[SHAPE_TYPE_SPHERE] = "Sphere";
var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_SIMPLE_COMPOUND;
var DYNAMIC_DEFAULT = false;
var prompt = desktop.customInputDialog({
@ -349,14 +349,14 @@ Windows.ScrollingWindow {
}
function deleteFile(index) {
var paths = [];
if (!index) {
for (var i = 0; i < selectedItemCount; ++i) {
index = treeView.selection.selectedIndexes[i];
paths[i] = assetProxyModel.data(index, 0x100);
}
}
if (!paths) {
return;
}
@ -365,13 +365,13 @@ Windows.ScrollingWindow {
var items = selectedItemCount.toString();
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
var typeString = isFolder ? 'folder' : 'file';
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" + paths + "\nDo you want to continue?";
}
var object = desktop.messageBox({
icon: hifi.icons.question,
buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No,
@ -476,11 +476,11 @@ Windows.ScrollingWindow {
});
}
}
Item {
width: pane.contentWidth
height: pane.height
// The letterbox used for popup messages
LetterboxMessage {
id: letterboxMessage;
@ -542,7 +542,7 @@ Windows.ScrollingWindow {
anchors.margins: hifi.dimensions.contentMargin.x + 2 // Extra for border
anchors.left: parent.left
anchors.right: parent.right
treeModel: assetProxyModel
selectionMode: SelectionMode.ExtendedSelection
headerVisible: true
@ -562,9 +562,13 @@ Windows.ScrollingWindow {
id: bakedColumn
title: "Use Baked?"
role: "baked"
width: 100
width: 170
}
onSortIndicatorOrderChanged: {
Assets.sortProxyModel(sortIndicatorColumn, sortIndicatorOrder);
}
itemDelegate: Loader {
id: itemDelegateLoader
@ -600,7 +604,7 @@ Windows.ScrollingWindow {
}
sourceComponent: getComponent()
Component {
id: labelComponent
FiraSansSemiBold {
@ -609,15 +613,15 @@ Windows.ScrollingWindow {
color: colorScheme == hifi.colorSchemes.light
? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight)
: (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText)
horizontalAlignment: styleData.column === 1 ? TextInput.AlignHCenter : TextInput.AlignLeft
elide: Text.ElideMiddle
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.NoButton
hoverEnabled: true
@ -639,7 +643,7 @@ Windows.ScrollingWindow {
color: colorScheme == hifi.colorSchemes.light
? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight)
: (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText)
elide: Text.ElideRight
horizontalAlignment: TextInput.AlignHCenter
@ -726,7 +730,7 @@ Windows.ScrollingWindow {
size: hifi.fontSizes.tableText
color: colorScheme == hifi.colorSchemes.light ? hifi.colors.black : hifi.colors.lightGrayText
}
Timer {
id: showTimer
interval: 1000
@ -745,7 +749,7 @@ Windows.ScrollingWindow {
treeLabelToolTip.visible = false;
}
}// End_OF( treeLabelToolTip )
MouseArea {
propagateComposedEvents: true
anchors.fill: parent
@ -803,7 +807,7 @@ Windows.ScrollingWindow {
anchors.left: treeView.left
anchors.right: treeView.right
anchors.bottom: uploadSection.top
RalewayRegular {
anchors.verticalCenter: parent.verticalCenter
@ -847,7 +851,7 @@ Windows.ScrollingWindow {
checked = Qt.binding(isChecked);
}
function isEnabled() {
if (!treeView.selection.hasSelection) {
return false;
@ -871,7 +875,7 @@ Windows.ScrollingWindow {
}
}
return true;
return true;
}
function isChecked() {
if (!treeView.selection.hasSelection) {
@ -879,10 +883,10 @@ Windows.ScrollingWindow {
}
var status = assetProxyModel.data(treeView.selection.currentIndex, 0x105);
return isEnabled() && status !== "Not Baked";
}
return isEnabled() && status !== "Not Baked";
}
}
Item {
anchors.verticalCenter: parent.verticalCenter
width: infoGlyph.size;
@ -906,7 +910,7 @@ Windows.ScrollingWindow {
"What is baking?",
"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 {

View file

@ -58,7 +58,7 @@ Rectangle {
Component.onDestruction: {
assetMappingsModel.autoRefreshEnabled = false;
}
function letterbox(headerGlyph, headerText, message) {
letterboxMessage.headerGlyph = headerGlyph;
letterboxMessage.headerText = headerText;
@ -66,7 +66,7 @@ Rectangle {
letterboxMessage.visible = true;
letterboxMessage.popupRadius = 0;
}
function errorMessageBox(message) {
return tabletRoot.messageBox({
icon: hifi.icons.warning,
@ -145,7 +145,7 @@ Rectangle {
function canAddToWorld(path) {
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i, /\.jpg\b/i, /\.png\b/i];
if (selectedItemCount > 1) {
return false;
}
@ -154,8 +154,8 @@ Rectangle {
return total | new RegExp(current).test(path);
}, false);
}
function canRename() {
function canRename() {
if (treeView.selection.hasSelection && selectedItemCount == 1) {
return true;
} else {
@ -199,7 +199,7 @@ Rectangle {
var SHAPE_TYPE_STATIC_MESH = 3;
var SHAPE_TYPE_BOX = 4;
var SHAPE_TYPE_SPHERE = 5;
var SHAPE_TYPES = [];
SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision";
SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model";
@ -207,7 +207,7 @@ Rectangle {
SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons";
SHAPE_TYPES[SHAPE_TYPE_BOX] = "Box";
SHAPE_TYPES[SHAPE_TYPE_SPHERE] = "Sphere";
var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_SIMPLE_COMPOUND;
var DYNAMIC_DEFAULT = false;
var prompt = tabletRoot.customInputDialog({
@ -349,14 +349,14 @@ Rectangle {
}
function deleteFile(index) {
var paths = [];
if (!index) {
for (var i = 0; i < selectedItemCount; ++i) {
index = treeView.selection.selectedIndexes[i];
paths[i] = assetProxyModel.data(index, 0x100);
}
}
if (!paths) {
return;
}
@ -365,7 +365,7 @@ Rectangle {
var items = selectedItemCount.toString();
var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101);
var typeString = isFolder ? 'folder' : 'file';
if (selectedItemCount > 1) {
modalMessage = "You are about to delete " + items + " items \nDo you want to continue?";
} else {
@ -476,7 +476,7 @@ Rectangle {
});
}
}
// The letterbox used for popup messages
LetterboxMessage {
id: letterboxMessage;
@ -540,7 +540,7 @@ Rectangle {
anchors.margins: hifi.dimensions.contentMargin.x + 2 // Extra for border
anchors.left: parent.left
anchors.right: parent.right
treeModel: assetProxyModel
selectionMode: SelectionMode.ExtendedSelection
headerVisible: true
@ -560,9 +560,13 @@ Rectangle {
id: bakedColumn
title: "Use Baked?"
role: "baked"
width: 100
width: 170
}
onSortIndicatorOrderChanged: {
Assets.sortProxyModel(sortIndicatorColumn, sortIndicatorOrder);
}
itemDelegate: Loader {
id: itemDelegateLoader
@ -598,7 +602,7 @@ Rectangle {
}
sourceComponent: getComponent()
Component {
id: labelComponent
FiraSansSemiBold {
@ -607,15 +611,15 @@ Rectangle {
color: colorScheme == hifi.colorSchemes.light
? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight)
: (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText)
horizontalAlignment: styleData.column === 1 ? TextInput.AlignHCenter : TextInput.AlignLeft
elide: Text.ElideMiddle
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.NoButton
hoverEnabled: true
@ -637,7 +641,7 @@ Rectangle {
color: colorScheme == hifi.colorSchemes.light
? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight)
: (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText)
elide: Text.ElideRight
horizontalAlignment: TextInput.AlignHCenter
@ -724,7 +728,7 @@ Rectangle {
size: hifi.fontSizes.tableText
color: colorScheme == hifi.colorSchemes.light ? hifi.colors.black : hifi.colors.lightGrayText
}
Timer {
id: showTimer
interval: 1000
@ -743,7 +747,7 @@ Rectangle {
treeLabelToolTip.visible = false;
}
}// End_OF( treeLabelToolTip )
MouseArea {
propagateComposedEvents: true
anchors.fill: parent
@ -801,7 +805,7 @@ Rectangle {
anchors.left: treeView.left
anchors.right: treeView.right
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
RalewayRegular {
anchors.verticalCenter: parent.verticalCenter
@ -845,7 +849,7 @@ Rectangle {
checked = Qt.binding(isChecked);
}
function isEnabled() {
if (!treeView.selection.hasSelection) {
return false;
@ -869,7 +873,7 @@ Rectangle {
}
}
return true;
return true;
}
function isChecked() {
if (!treeView.selection.hasSelection) {
@ -877,10 +881,10 @@ Rectangle {
}
var status = assetProxyModel.data(treeView.selection.currentIndex, 0x105);
return isEnabled() && status !== "Not Baked";
}
return isEnabled() && status !== "Not Baked";
}
}
Item {
anchors.verticalCenter: parent.verticalCenter
width: infoGlyph.size;
@ -904,7 +908,7 @@ Rectangle {
"What is baking?",
"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 {

View file

@ -152,6 +152,10 @@ void AssetMappingsScriptingInterface::deleteMappings(QStringList paths, QJSValue
request->start();
}
void AssetMappingsScriptingInterface::sortProxyModel(int column, Qt::SortOrder order) {
_proxyModel.sort(column, order);
}
void AssetMappingsScriptingInterface::getAllMappings(QJSValue callback) {
auto assetClient = DependencyManager::get<AssetClient>();
auto request = assetClient->createGetAllMappingsRequest();
@ -287,7 +291,7 @@ void AssetMappingModel::refresh() {
item->setData(parts[i], Qt::UserRole + 2);
item->setData("atp:" + fullPath, Qt::UserRole + 3);
item->setData(fullPath, Qt::UserRole + 4);
if (lastItem) {
lastItem->appendRow(item);
} else {

View file

@ -82,6 +82,7 @@ public:
Q_INVOKABLE void getAllMappings(QJSValue callback = QJSValue());
Q_INVOKABLE void renameMapping(QString oldPath, QString newPath, QJSValue callback = QJSValue());
Q_INVOKABLE void setBakingEnabled(QStringList paths, bool enabled, QJSValue callback = QJSValue());
Q_INVOKABLE void sortProxyModel(int column, Qt::SortOrder order = Qt::AscendingOrder);
protected:
QSet<AssetRequest*> _pendingRequests;